- void renderText(int x, int y, int clipx, int clipy, int clipw, int cliph, DoubleBuffer buf) {
- /*
- // hack because (believe it or not) libgcj doesn't support UTF16.
- byte[] b = new byte[text.length() * 2 + 2];
- for(int i=0; i<text.length(); i++) {
- b[i * 2] = (byte)((((short)text.charAt(i)) & 0xff00) >> 8);
- b[i * 2 + 1] = (byte)(((short)text.charAt(i)) & 0xff);
- }
- b[text.length()] = 0;
- b[text.length() + 1] = 0;
- */
- /*
- try {
- ImageDecoder id = org.xwt.translators.Font.render(new FileInputStream("COMIC.TTF"), 24, text, false);
- Picture p = Platform.createPicture(id);
- // FIXME: clipping (don't use setClip)
- buf.drawPicture(p,
- x + hpad, y + vpad,
- x + hpad + p.getWidth(), y + vpad + p.getHeight(),
+ 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);
+ System.out.println("rendering glyph for " + c + " as " + g + " @ " + (x+hpad) + ", " + (y+vpad));
+ 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(),