2003/10/17 07:20:15
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:39:36 +0000 (07:39 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:39:36 +0000 (07:39 +0000)
darcs-hash:20040130073936-2ba56-271739e125693d8a51b78c1901e43e4f60b01cd7.gz

src/org/xwt/Glyph.java
src/org/xwt/plat/AWT.java
src/org/xwt/translators/Freetype.c
src/org/xwt/translators/Freetype.java

index e998845..6088717 100644 (file)
@@ -25,6 +25,6 @@ public class Glyph {
 
         ret = (Glyph)glyphCache.get(res, new Integer((((int)c) << 16) | pointsize));
         if (ret != null) return ret;
-        throw new JS.Exn("error rendering glyph " + c);
+        throw new JS.Exn("error rendering glyph " + c + "; glyph is null");
     }
 }
index 3dfd153..771bdbb 100644 (file)
@@ -131,7 +131,15 @@ public class AWT extends JVM {
             mediatracker.addImage(img, 1);
             try { mediatracker.waitForAll(); } catch (InterruptedException e) { }
             mediatracker.removeImage(img);
-            this.i = img;
+            synchronized(AWTPixelBuffer.class) { 
+                if (AWTPixelBuffer.component == null) {
+                    AWTPixelBuffer.component = new Frame();
+                    AWTPixelBuffer.component.setVisible(false);
+                    AWTPixelBuffer.component.addNotify();
+                }
+            }
+            this.i = AWTPixelBuffer.component.createImage(w, h);
+            this.i.getGraphics().drawImage(img, 0, 0, null);
         }
     }
     
index 03a3fbe..fad6018 100644 (file)
@@ -72,7 +72,7 @@ int main(int argc, char** argv) {
             _user_info[6]  = (char*)face->glyph->bitmap.width;
             _user_info[7]  = (char*)face->glyph->bitmap.rows;
             _user_info[8]  = (char*)(face->size->metrics.ascender >> 6);
-            _user_info[9]  = (char*)(face->size->metrics.height >> 6);
+            _user_info[9]  = (char*)(face->size->metrics.descender >> 6);
             _user_info[10] = (char*)(face->glyph->metrics.horiBearingY >> 6);
             _user_info[11] = (char*)(face->glyph->advance.x >> 6);
 
index 1608a75..3a7f3ca 100644 (file)
@@ -44,28 +44,24 @@ public class Freetype {
                 
                 Glyph glyph = new Glyph();
                 glyph.max_ascent = vm.getUserInfo(8);
-                glyph.max_descent = vm.getUserInfo(9) - glyph.max_ascent;
+                glyph.max_descent = vm.getUserInfo(9);
                 glyph.baseline = vm.getUserInfo(10);
                 glyph.advance = vm.getUserInfo(11);
                 glyph.c = (char)g;
                 
                 int width = vm.getUserInfo(6);
                 int height = vm.getUserInfo(7);
-                byte[] data = new byte[width * height];
-                int addr = vm.getUserInfo(5);
 
-                vm.copyin(addr,data,width*height);
-                
-                /*for(int i=0; i<width * height; i += 4) {
-                    int val = vm.memRead(addr + i);
-                    for (int k = 3; k >= 0; k--) {
-                        if (i + k < width * height)
-                            data[i + k] = (val & 0xff) << 24;
-                        val >>>= 8;
-                    }
-                }*/
-                
-                glyph.p = Platform.createAlphaOnlyPicture(data, width, height);
+                if (width == 0 || height == 0) {
+                    Log.log(Freetype.class, "warning glyph " + g + " has zero width/height");
+
+                } else {
+                    byte[] data = new byte[width * height];
+                    int addr = vm.getUserInfo(5);
+                    vm.copyin(addr,data,width*height);
+                    glyph.p = Platform.createAlphaOnlyPicture(data, width, height);
+                }
+
                 glyphCache.put(res, new Integer((g << 16) | pointsize), glyph);
             }
         } catch (Exception e) {