X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fgraphics%2FFont.java;fp=src%2Forg%2Fibex%2Fgraphics%2FFont.java;h=70451a36ed0f2adca6f05501612e4aa9d47676ba;hp=b2c30caf71570e59313bb2a31032ba68a083ecb3;hb=0db1ff365b2acfa1be6420aca33a27dd01eb78f2;hpb=faa4ae356d464a80e08540d5eb8bbee6296c1dbc diff --git a/src/org/ibex/graphics/Font.java b/src/org/ibex/graphics/Font.java index b2c30ca..70451a3 100644 --- a/src/org/ibex/graphics/Font.java +++ b/src/org/ibex/graphics/Font.java @@ -74,7 +74,7 @@ public class Font { } return path.toString(); } - public long rasterizeGlyphs(String text, PixelBuffer pb, Affine a, Mesh h, int fg, int bg) { + public long rasterizeGlyphs(String text, PixelBuffer pb, Affine a, Mesh h, Affine ha, int fg, int bg) { int width = 0, height = 0; if (!latinCharsPreloaded) { // preload the Latin-1 charset with low priority (we'll probably want it) for(int i=48; i<57; i++) if(glyphs[i]==null) toBeRasterized.append(glyphs[i]=Platform.createGlyph(this, (char)i)); @@ -88,11 +88,17 @@ public class Font { Glyph g = glyphs[c]; if (g == null) glyphs[c] = g = Platform.createGlyph(this, c); g.render(); - if (a!=null) a.premultiply(Affine.translate(0, g.font.max_ascent - g.baseline)); - if (pb != null) pb.drawGlyph(g, a, h, fg, bg); - if (a!=null) a.premultiply(Affine.translate(0, -1 * (g.font.max_ascent - g.baseline))); + if (a!=null) a.multiply(Affine.translate(0, g.font.max_ascent - g.baseline)); + if (ha!=null) ha.multiply(Affine.translate(0, g.font.max_ascent - g.baseline)); + if (pb != null) { + pb.drawGlyph(g, a, h, fg, bg); + if (h!=null) h.subtract(new Mesh().addRect(0, 0, g.width, g.height), ha); + } + if (a!=null) a.multiply(Affine.translate(0, -1 * (g.font.max_ascent - g.baseline))); + if (ha!=null) ha.multiply(Affine.translate(0, -1 * (g.font.max_ascent - g.baseline))); width += g.advance; - if (a!=null) a.premultiply(Affine.translate(g.advance, 0)); + if (a!=null) a.multiply(Affine.translate(g.advance, 0)); + if (ha!=null) ha.multiply(Affine.translate(g.advance, 0)); height = java.lang.Math.max(height, max_ascent + max_descent); } return ((((long)width) << 32) | (long)(height & 0xffffffffL)); @@ -105,13 +111,13 @@ public class Font { public long textsize(String s) { Long l = (Long)sizeCache.get(s); if (l != null) return ((Long)l).longValue(); - long ret = rasterizeGlyphs(s, null, null, null, 0, 0); + long ret = rasterizeGlyphs(s, null, null, null, null, 0, 0); sizeCache.put(s, new Long(ret)); return ret; } public Glyph getGlyph(char c) { - rasterizeGlyphs(c+"", null, null, null, 0, 0); + rasterizeGlyphs(c+"", null, null, null, null, 0, 0); Glyph g = glyphs[c]; g.render(); return g;