Text rendering using downloadable font

※上記の広告は60日以上更新のないWIKIに表示されています。更新することで広告が下部へ移動します。

This sample code shows how to render text with downloadable font.
In addition to the program, the following files are needed:

Main.java
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

名前: