X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fibex%2FFont.java;h=451672e4a3ad254ffdb6c3af31657b56e78e8f6c;hb=707b1064f56e88db0cf555a99cb4aa224484f51a;hp=2744f0e11b105b7bf3c3ccd9f86916933272d48a;hpb=3591b88b94a6bb378af3d4abe6eb5233ce583104;p=org.ibex.core.git
diff --git a/src/org/ibex/Font.java b/src/org/ibex/Font.java
index 2744f0e..451672e 100644
--- a/src/org/ibex/Font.java
+++ b/src/org/ibex/Font.java
@@ -1,8 +1,11 @@
// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL]
package org.ibex;
-import org.xwt.translators.*;
+import org.ibex.translators.*;
import org.ibex.util.*;
import java.io.*;
+import java.util.Hashtable;
+
+import org.ibex.js.JSExn;
// FEATURE: this could be cleaner
/** encapsulates a single font (a set of Glyphs) */
@@ -29,13 +32,18 @@ public class Font {
public int width = -1; ///< the width of the glyph
public int height = -1; ///< the height of the glyph
public byte[] data = null; ///< the alpha channel samples for this font
+ void render() {
+ if (!isLoaded) try { freetype.renderGlyph(this); } catch (IOException e) { Log.info(Freetype.class, e); }
+ isLoaded = true;
+ }
}
// Statics //////////////////////////////////////////////////////////////////////
- private static final Freetype freetype = new Freetype();
- static final Queue glyphsToBeRendered = new Queue(255);
+ static final Freetype freetype = new Freetype();
+ static final Hashtable glyphsToBeCached = new Hashtable();
+ static final Hashtable glyphsToBeDisplayed = new Hashtable();
private static Cache fontCache = new Cache(100);
public static Font getFont(Stream stream, int pointsize) {
Font ret = (Font)fontCache.get(stream, new Integer(pointsize));
@@ -48,62 +56,30 @@ public class Font {
/**
* Rasterize the glyphs of text
.
- *
- * If all the glyphs of text
are not yet loaded,
- * spawn a Task to load them and then invoke callback. If all
- * the glyphs are loaded, rasterize them to the
- * PixelBuffer (if non-null).
- *
- * @returns (width<<32)|height
if all glyphs are loaded; else -1
+ * @returns (width<<32)|height
*/
- public long rasterizeGlyphs(final String text, PixelBuffer pb, int textcolor,
- int x, int y, int cx1, int cy1, int cx2, int cy2,
- final Scheduler.Task callback) {
- boolean encounteredUnrenderedGlyph = false;
+ public long rasterizeGlyphs(String text, PixelBuffer pb, int textcolor, int x, int y, int cx1, int cy1, int cx2, int cy2) {
int width = 0, height = 0;
- for(int i=0; i