}
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));
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));
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;