pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r3868 - trunk/fontgen


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3868 - trunk/fontgen
Date: Fri, 18 Jul 2008 21:08:43 +0200

Author: grumbel
Date: 2008-07-18 21:08:42 +0200 (Fri, 18 Jul 2008)
New Revision: 3868

Modified:
   trunk/fontgen/fontgen.cpp
Log:
- fixed FT_Load_Char/FT_Load_Glyph mixup
- changed metadata format a bit

Modified: trunk/fontgen/fontgen.cpp
===================================================================
--- trunk/fontgen/fontgen.cpp   2008-07-18 19:06:44 UTC (rev 3867)
+++ trunk/fontgen/fontgen.cpp   2008-07-18 19:08:42 UTC (rev 3868)
@@ -33,6 +33,13 @@
                     const std::string& pgm_filename,
                     const std::string& metadata_filename)
 {
+  std::ofstream metadata(metadata_filename.c_str());
+
+  metadata << "(pingus-font" << std::endl;
+  metadata << "  (size " << font_height << ")" << std::endl;
+  metadata << "  (glyph-count " << glyphs.size() << ")" << std::endl;
+  metadata << "  (glyphs " << std::endl;
+
   Bitmap image_bitmap(image_width, 4096);
 
   int x_pos = 0;
@@ -60,18 +67,23 @@
           image_bitmap.blit(*glyph.bitmap, x_pos+border, y_pos+border);
         }
 
-      std::cout << "(char "
-                << "(code " << glyph.charcode << ") "
-                << "(offset " << glyph.x_offset << " " << glyph.y_offset << ") 
"
-                << "(advance " << glyph.advance << ") "
-                << "(rect "
-                << x_pos << " " << y_pos << " " 
-                << x_pos+glyph.bitmap->get_width()+border*2 << " " << 
y_pos+glyph.bitmap->get_height()+border*2 << ")"
-                << ")" << std::endl;
+      metadata << "    (glyph "
+               << "(unicode " << glyph.charcode << ") "
+               << "(offset " << glyph.x_offset << " " << glyph.y_offset << ") "
+               << "(advance " << glyph.advance << ") "
+               << "(rect "
+               << x_pos << " " << y_pos << " " 
+               << x_pos+glyph.bitmap->get_width()+border*2 << " " << 
y_pos+glyph.bitmap->get_height()+border*2 << ")"
+               << ")" 
+               << " ;; " << (char)glyph.charcode
+               << std::endl;
 
       x_pos += glyph.bitmap->get_width() + 2*border;
     }
 
+  metadata << "  ))" << std::endl;
+  metadata << ";; EOF ;;" << std::endl;
+
   image_bitmap.truncate_height(y_pos + row_height + border);
   image_bitmap.write_pgm(pgm_filename);
 }
@@ -92,8 +104,17 @@
     }
       
   FT_Set_Pixel_Sizes(face, px_size, px_size);
-  FT_Select_Charmap(face,  FT_ENCODING_UNICODE);
 
+  {
+    FT_Error   error;
+    error = FT_Select_Charmap(face,  FT_ENCODING_UNICODE);
+    if (error)
+      {
+        std::cout << "Error: Couldn't set Unicode charmap" << std::endl;
+        exit(EXIT_FAILURE);
+      }
+  }
+
   std::cout << "BBox: " << px_size << " "
             << px_size * face->bbox.xMin/face->units_per_EM << " " 
             << px_size * face->bbox.yMin/face->units_per_EM << " " 
@@ -102,13 +123,11 @@
             << face->units_per_EM
             << std::endl;
 
-  FT_ULong  charcode;                                              
-  FT_UInt   glyph_index;                                                
-  
-  charcode = FT_Get_First_Char( face, &glyph_index );
+  FT_UInt   glyph_index = 0;                                                
+  FT_ULong  charcode = FT_Get_First_Char( face, &glyph_index );
   while ( glyph_index != 0 )                                            
     {                                                                          
                            
-      if (FT_Load_Char( face,  glyph_index, FT_LOAD_RENDER))//| 
FT_LOAD_FORCE_AUTOHINT))
+      if (FT_Load_Glyph( face,  glyph_index, FT_LOAD_RENDER))//| 
FT_LOAD_FORCE_AUTOHINT))
         {
           std::cerr << "couldn't load char: " << glyph_index << " '" << 
char(glyph_index) << "'" << std::endl;
           //impl->characters.push_back(0);
@@ -137,6 +156,9 @@
         }
     }
 
+  std::cout << "Glyphs(intern):   " << face->num_glyphs << std::endl;
+  std::cout << "Glyphs(exported): " << glyphs.size() << std::endl;
+  
   FT_Done_Face(face);
 }
   





reply via email to

[Prev in Thread] Current Thread [Next in Thread]