1 // Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL]
3 import org.xwt.translators.*;
8 public int max_ascent; // same value for every glyph in font; the max ascent of all chars
9 public int max_descent; // same value for every glyph in font; the max descent of all chars
10 public int baseline; // within the picture, this is the y-coordinate of the baseline
11 public int advance; // amount to increment the x-coordinate
14 // k1=font.res k2=(c << 16 | pointsize)
15 private static Cache glyphCache = new Cache();
17 public static Glyph getGlyph(Res res, int pointsize, char c) {
18 Glyph ret = (Glyph)glyphCache.get(res, new Integer((((int)c) << 16) | pointsize));
19 if (ret != null) return ret;
21 // FEATURE: be smarter here
23 Font.renderGlyphs(res, pointsize, 0, 255, glyphCache);
25 Font.renderGlyphs(res, pointsize, (int)c, (int)c, glyphCache);
27 ret = (Glyph)glyphCache.get(res, new Integer((((int)c) << 16) | pointsize));
28 if (ret != null) return ret;
29 throw new RuntimeException("renderGlyphs didn't create the glyph we wanted");