diff --git a/src/sillysagiri/BMF.java b/src/sillysagiri/BMF.java index d2fb195..ea87b92 100644 --- a/src/sillysagiri/BMF.java +++ b/src/sillysagiri/BMF.java @@ -4,6 +4,7 @@ import java.io.InputStream; import javax.microedition.lcdui.Graphics; import javax.microedition.lcdui.Image; +import javax.microedition.lcdui.game.Sprite; public class BMF { public static final byte ID = 0; @@ -128,6 +129,34 @@ public class BMF { public void Draw(Graphics g, String str, int x, int y) { short[] cursor = new short[]{0, 0}; + + for (int i=0; i 127)) index = 127; + + if (index == '\n') + { + cursor[1] += lineHeight; + cursor[0] = 0; + continue; + } + + short[] ch = chars[index-32]; + int[] offset = new int[]{x+ch[XOFF]+cursor[0], y+ch[YOFF]+cursor[1]}; + g.drawRegion( + img, + ch[X], ch[Y], ch[WIDTH], ch[HEIGHT], + Sprite.TRANS_NONE, + x+offset[0], y+offset[1], + Graphics.TOP | Graphics.LEFT); + + cursor[0] += ch[XADV]; + + /* + * TODO: handle kernings here + */ + } } } diff --git a/src/sillysagiri/scene/MainMenu.java b/src/sillysagiri/scene/MainMenu.java index 5879501..bf03e00 100644 --- a/src/sillysagiri/scene/MainMenu.java +++ b/src/sillysagiri/scene/MainMenu.java @@ -16,10 +16,11 @@ public class MainMenu extends Scene { private Image img_bg; private Image img_bandai; private Image img_ez; + private BMF bmf; public void Preload() { try { - BMF bmf = new BMF("/silly/bmf/nds12.png", "/silly/bmf/nds12.fnt"); + bmf = new BMF("/silly/bmf/nds12.png", "/silly/bmf/nds12.fnt"); Image img_loop = Image.createImage("/m_2.png"); img_bandai = Image.createImage("/c_0.png"); img_ez = Image.createImage("/pEZ.png"); @@ -63,6 +64,8 @@ public class MainMenu extends Scene { img_ez, Utils.GetScreenWidth()/2, (int)(Utils.GetScreenHeight()*0.75), Graphics.VCENTER | Graphics.HCENTER); + + bmf.Draw(g, "hello world\nthis is test text!\nthe fox jumped over the lazy dog", 5, 10); if (sagiri.input.IsKeyDownAny()) {