- void renderText(int x, int y, int clipx, int clipy, int clipw, int cliph, DoubleBuffer buf) {
-
- Log.log(this, "rendering text: " + text);
- //buf.setClip(clipx, clipy, clipw, cliph);
-
- try {
- ImageDecoder id = org.xwt.imp.Font.render(new FileInputStream("COMIC.TTF"), 24, text);
- Picture p = Platform.createPicture(id);
- buf.drawPicture(p, x, y);
- buf.setClip(0, 0, buf.getWidth(), buf.getHeight());
- } catch (Exception e) {
- Log.log(this, e);
- }
-
- /*
- buf.drawString(font(), text, x + hpad, y + vpad + Platform.getMaxAscent(font()) - 1, textcolor);
- buf.setClip(0, 0, buf.getWidth(), buf.getHeight());
- int i=0; while(i<font().length() && !Character.isDigit(font().charAt(i))) i++;
-
- if (font().lastIndexOf('d') > i) {
- for(int j = x + hpad; j < x + hpad + textdim(0); j += 2)
- buf.fillRect(j, y + vpad + (xwf == null ? Platform.getMaxAscent(font()) : xwf.getMaxAscent()) + 2,
- j + 1, y + vpad + (xwf == null ? Platform.getMaxAscent(font()) : xwf.getMaxAscent()) + 2 + 1,
- textcolor);
-
- } else if (font().lastIndexOf('u') > i) {
- buf.fillRect(x + hpad,
- y + vpad + (xwf == null ? Platform.getMaxAscent(font()) : xwf.getMaxAscent()) + 2,
- x + hpad + textdim(0),
- y + vpad + (xwf == null ? Platform.getMaxAscent(font()) : xwf.getMaxAscent()) + 2 + 1,
- textcolor);
+ void renderText(int x, int y, int clipx, int clipy, int clipw, int cliph, PixelBuffer buf) {
+ for(int i=0; i<text.length(); i++) {
+ // FIXME: clipping
+ char c = text.charAt(i);
+ Glyph g = Glyph.getGlyph(font, fontsize, c);
+ buf.drawPicture(g.p,
+ x + hpad,
+ y + vpad + g.max_ascent - g.baseline,
+ x + hpad + g.p.getWidth(),
+ y + vpad + g.max_ascent - g.baseline + g.p.getHeight(),
+ 0, 0,
+ g.p.getWidth(), g.p.getHeight());
+ x += g.advance;