Text rendering using downloadable font


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(
            Graphics g = hs.getGraphics();
            // Obtaining font instance
            f = new FontFactory().createFont("mika", java.awt.Font.PLAIN, 48);
            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