1 // Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL]
3 import org.xwt.translators.*;
9 public int max_ascent; // same value for every glyph in font; the max ascent of all chars
10 public int max_descent; // same value for every glyph in font; the max descent of all chars
11 public int baseline; // within the picture, this is the y-coordinate of the baseline
12 public int advance; // amount to increment the x-coordinate
15 // k1=font.res k2=(c << 16 | pointsize)
16 private static Cache glyphCache = new Cache();
18 public static Glyph getGlyph(Res res, int pointsize, char c) {
19 Glyph ret = (Glyph)glyphCache.get(res, new Integer((((int)c) << 16) | pointsize));
20 if (ret != null) return ret;
22 // FEATURE: be smarter here
23 if (c < 256) Freetype.renderGlyphs(res, pointsize, 0, 255, glyphCache);
24 else Freetype.renderGlyphs(res, pointsize, (int)c, (int)c, glyphCache);
26 ret = (Glyph)glyphCache.get(res, new Integer((((int)c) << 16) | pointsize));
27 if (ret != null) return ret;
28 throw new JS.Exn("error rendering glyph " + c);