2003/11/29 03:06:08
[org.ibex.core.git] / src / org / xwt / Font.java
index 2eef1f1..e14727f 100644 (file)
@@ -59,7 +59,7 @@ public class Font {
         for(int i=0; i<text.length(); i++) {
             final char c = text.charAt(i);
             Glyph g = glyphs[c];
-            if (g == null) glyphsToBeRendered.prepend(g = new Glyph(c, this));    // prepend so they are high priority
+            if (g == null) glyphsToBeRendered.prepend(g = glyphs[c] = new Glyph(c, this));    // prepend so they are high priority
             if (g.p == null) {
                 glyphsToBeRendered.prepend(g);
                 encounteredUnrenderedGlyph = true;
@@ -70,22 +70,27 @@ public class Font {
                 height = java.lang.Math.max(height, max_ascent + max_descent);
             }
         }
-        
-        if (encounteredUnrenderedGlyph && callback != null) Scheduler.add(new Scheduler.Task() { public void perform() {
-            for(int i=0; i<text.length(); i++) {
-                Glyph g = glyphs[text.charAt(i)];
-                if (g == null || g.p == null) { Scheduler.add(this); return; }
-            }
-            callback.perform();
-        }});
-    
-        if (!latinCharsPreloaded) for(int i=32; i<128; i++) glyphsToBeRendered.append(glyphs[i] = new Glyph((char)i, this));
+
+        if (encounteredUnrenderedGlyph && callback != null) Scheduler.add(new Scheduler.Task() {
+                public void perform() throws Exception{
+                    for(int i=0; i<text.length(); i++) {
+                        Glyph g = glyphs[text.charAt(i)];
+                        if (g == null || g.p == null) { Scheduler.add(this); return; }
+                    }
+                    callback.perform();
+                }});
+        if (!latinCharsPreloaded) {
+            for(int i=48; i<57; i++) glyphsToBeRendered.append(glyphs[i] = new Glyph((char)i, this));
+            for(int i=32; i<47; i++) glyphsToBeRendered.append(glyphs[i] = new Glyph((char)i, this));
+            for(int i=57; i<128; i++) glyphsToBeRendered.append(glyphs[i] = new Glyph((char)i, this));
+        }
         if (!latinCharsPreloaded || encounteredUnrenderedGlyph) Scheduler.add(glyphRenderingTask);
         latinCharsPreloaded = true;
-        return encounteredUnrenderedGlyph ? -1 : (((long)width << 16) | (long)height);
+        if (encounteredUnrenderedGlyph) return -1;
+        return ((((long)width) << 32) | (long)(height & 0xffffffffL));
     }
 
-    public int textwidth(String s) { return (int)(textsize(s) >>> 16L); }
+    public int textwidth(String s) { return (int)((textsize(s) >>> 32) & 0xffffffff); }
     public int textheight(String s) { return (int)(textsize(s) & 0xffffffffL); }
     public long textsize(String s) {
         Long l = (Long)sizeCache.get(s);