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