X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FFont.java;h=ed979b71b39737367fdfd40f3bde007491d94caa;hb=16ad8b9430571d806f2aeb18ec472a277ff69423;hp=deb3c07004ac88d585cb4be47cf3db2d513ee237;hpb=e9492ed0cd0e8c1e717ede290f11ed187f7aee8a;p=org.ibex.core.git diff --git a/src/org/xwt/Font.java b/src/org/xwt/Font.java index deb3c07..ed979b7 100644 --- a/src/org/xwt/Font.java +++ b/src/org/xwt/Font.java @@ -1,4 +1,4 @@ -// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL] +// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL] package org.xwt; import org.xwt.translators.*; import org.xwt.util.*; @@ -6,15 +6,16 @@ import org.xwt.js.*; import java.util.*; import java.io.*; +// FEATURE: this could be cleaner /** encapsulates a single font (a set of Glyphs) */ public class Font { - private Font(Stream res, int pointsize) { this.res = res; this.pointsize = pointsize; } + private Font(Stream stream, int pointsize) { this.stream = stream; this.pointsize = pointsize; } private static boolean glyphRenderingTaskIsScheduled = false; public final int pointsize; ///< the size of the font - public final Stream res; ///< the resource from which this font was loaded + public final Stream stream; ///< the stream from which this font was loaded public int max_ascent; ///< the maximum ascent, in pixels public int max_descent; ///< the maximum descent, in pixels boolean latinCharsPreloaded = false; ///< true if a request to preload ASCII 32-127 has begun @@ -27,10 +28,9 @@ public class Font { public int baseline; ///< within the alphamask, this is the y-coordinate of the baseline public int advance; ///< amount to increment the x-coordinate public boolean isLoaded = false; ///< true iff the glyph is loaded - public byte[] alphaChannel = null; public int width = -1; ///< the width of the glyph public int height = -1; ///< the height of the glyph - public byte[] data = null; + public byte[] data = null; ///< the alpha channel samples for this font } @@ -39,9 +39,9 @@ public class Font { private static final Freetype freetype = new Freetype(); static final Queue glyphsToBeRendered = new Queue(255); private static Cache fontCache = new Cache(100); - public static Font getFont(Stream res, int pointsize) { - Font ret = (Font)fontCache.get(res, new Integer(pointsize)); - if (ret == null) fontCache.put(res, new Integer(pointsize), ret = new Font(res, pointsize)); + public static Font getFont(Stream stream, int pointsize) { + Font ret = (Font)fontCache.get(stream, new Integer(pointsize)); + if (ret == null) fontCache.put(stream, new Integer(pointsize), ret = new Font(stream, pointsize)); return ret; } @@ -66,13 +66,15 @@ public class Font { for(int i=0; i