This sample code shows how to render text with
downloadable font.
In addition to the program, the following files are needed:
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import javax.tv.xlet.Xlet;
import javax.tv.xlet.XletContext;
import org.dvb.ui.FontFactory;
import org.havi.ui.HScene;
import org.havi.ui.HSceneFactory;
import org.havi.ui.HScreen;
public class Main implements Xlet{
int x = 100, y = 100;
public void initXlet(XletContext context){
try {
Font f;
HScene hs= HSceneFactory.getInstance().getFullScreenScene(
HScreen.getDefaultHScreen().getDefaultHGraphicsDevice());
hs.setVisible(true);
Graphics g = hs.getGraphics();
g.setColor(Color.white);
// Obtaining font instance
f = new FontFactory().createFont("mika", java.awt.Font.PLAIN, 48);
g.setFont(f);
g.drawString("test", x, y); y += 50;
} catch (Throwable thr){
}
}
public void startXlet(){ }
public void pauseXlet(){ }
public void destroyXlet(boolean unconditional){}
}
See also
- Font:describes Downloadable Font
Message board
最終更新:2009年09月27日 19:42