2003/11/17 01:53:25
[org.ibex.core.git] / src / org / xwt / Font.java
index 2eef1f1..19c1a5c 100644 (file)
@@ -59,18 +59,18 @@ 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;
-            } else if (!encounteredUnrenderedGlyph) {
+            } else {
                 if (pb != null && g.p != null)
                     pb.drawPictureAlphaOnly(g.p, x + width, y + g.font.max_ascent - g.baseline, cx1, cy1, cx2, cy2, textcolor);
                 width += g.advance;
                 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)];
@@ -78,14 +78,13 @@ public class Font {
             }
             callback.perform();
         }});
-    
         if (!latinCharsPreloaded) for(int i=32; 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);
+        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);