2003/12/29 22:29:34
[org.ibex.core.git] / src / org / xwt / translators / Freetype.c
index 03a3fbe..50fe6fd 100644 (file)
 
 */
 
+#if 0
+/* Use this when org.xwt.mips is updated to the latest org.xwt.mips cvs */
+extern char *user_info[1024];
+#else
 extern char **_user_info;
-
-FT_Library  library;   /* handle to library     */
-FT_Face     face;      /* handle to face object */
+#define user_info _user_info
+#define _pause emu_pause
+#endif
 
 #define FT_Check(expr) do { \
     if((expr) != 0) { \
@@ -48,35 +52,36 @@ FT_Face     face;      /* handle to face object */
 #define max(a, b) ((a) > (b) ? (a) : (b))
 #define min(a, b) ((a) < (b) ? (a) : (b))
 
-extern void emu_pause();
+extern void _pause();
 
-int main(int argc, char** argv) {
+int freetype_main() {
     char *fontdata;
     int glyph_index;
     short charcode;
-    
+    FT_Library  library;   /* handle to library     */
+    FT_Face     face;      /* handle to face object */
+
     FT_Check(FT_Init_FreeType(&library));
-    emu_pause();
+    FT_Check(FT_New_Memory_Face(library, user_info[0], (int)user_info[1], 0, &face));
 
     for(;;) {
-       FT_Check(FT_New_Memory_Face(library, _user_info[0], (int)_user_info[1], 0, &face));
-       FT_Check(FT_Set_Char_Size(face, 0, ((int)_user_info[4]) * 64, 72, 72));
-
-        for(charcode = (int)_user_info[2]; charcode <= (int)_user_info[3]; charcode++) {
+      
+        _pause();
+        FT_Check(FT_Set_Char_Size(face, 0, ((int)user_info[4]) * 64, 72, 72));
+        for(charcode = (int)user_info[2]; charcode <= (int)user_info[3]; charcode++) {
 
             glyph_index = FT_Get_Char_Index(face, charcode);
             FT_Check(FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT | FT_LOAD_FORCE_AUTOHINT));
             FT_Check(FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL));
 
-            _user_info[5]  = (char*)face->glyph->bitmap.buffer;
-            _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[10] = (char*)(face->glyph->metrics.horiBearingY >> 6);
-            _user_info[11] = (char*)(face->glyph->advance.x >> 6);
+            user_info[5]  = (char*)face->glyph->bitmap.buffer;
+            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*)((-1 * face->size->metrics.descender) >> 6);
+            user_info[10] = (char*)(face->glyph->metrics.horiBearingY >> 6);
+            user_info[11] = (char*)(face->glyph->advance.x >> 6);
 
-            emu_pause();
         }
     }
 }