freetype curve extraction in Font.java and readback in Box.java
[org.ibex.core.git] / src / org / ibex / graphics / Font.java
index 6df9899..9870aa6 100644 (file)
@@ -21,7 +21,7 @@ public class Font {
     public int max_ascent;                      ///< the maximum ascent, in pixels
     public int max_descent;                     ///< the maximum descent, in pixels
     boolean latinCharsPreloaded = false;        ///< true if a request to preload ASCII 32-127 has begun
-    Glyph[] glyphs = new Glyph[65535];          ///< the glyphs that comprise this font
+    public Glyph[] glyphs = new Glyph[65535];          ///< the glyphs that comprise this font
 
     public abstract static class Glyph {
         protected Glyph(Font font, char c) { this.font = font; this.c = c; }
@@ -33,6 +33,7 @@ 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
+        public String path = null; // FIXME this should be shared across point sizes
         void render() {
             if (!isLoaded) try { renderGlyph(this); } catch (IOException e) { Log.info(Font.class, e); }
             isLoaded = true;
@@ -121,7 +122,7 @@ public class Font {
         try {
             rt = (Runtime)Class.forName("org.ibex.util.MIPSApps").newInstance();
         } catch(Exception e) {
-            throw new Error("Error instansiating freetype");
+            throw new Error("Error instantiating freetype: " + e);
         }
         rt.start(new String[]{"freetype"});
         rt.execute();
@@ -167,11 +168,16 @@ public class Font {
             
             glyph.width = rt.getUserInfo(1);
             glyph.height = rt.getUserInfo(2);
-            
+
             glyph.data = new byte[glyph.width * glyph.height];
             int addr = rt.getUserInfo(0);
             rt.copyin(addr, glyph.data, glyph.width * glyph.height);
             
+            byte[] path = new byte[rt.getUserInfo(8)];
+            rt.copyin(rt.getUserInfo(7), path, rt.getUserInfo(8));
+            glyph.path = new String(path);
+            glyph.path += " m " + (64 * glyph.advance) + " 0 "; 
+
             glyph.isLoaded = true;
         } catch (Exception e) {
             // FEATURE: Better error reporting (thow an exception?)