2003/10/17 07:20:15
[org.ibex.core.git] / src / org / xwt / translators / Freetype.java
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) {