]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/pango-font.cc
Merge branch 'jneeman' of git+ssh://jneem@git.sv.gnu.org/srv/git/lilypond into jneeman
[lilypond.git] / lily / pango-font.cc
index a79c237013d44f4f3e71511da316d352fb9f7d35..3d58e0dd0ed69cbbd4a701b425d6c94e3d27549e 100644 (file)
@@ -8,17 +8,21 @@
 
 #define PANGO_ENABLE_BACKEND // ugh, why necessary?
 #include <pango/pangoft2.h>
+#include <freetype/ftxf86.h>
+
+#include <map>
 
 /* Ugh.  */
-#include "pango-font.hh"
 
+#include "pango-font.hh"
 #include "dimensions.hh"
 #include "file-name.hh"
 #include "international.hh"
-#include "lookup.hh"
+#include "lookup.hh"           // debugging
 #include "main.hh"
 #include "string-convert.hh"
 #include "warn.hh"
+#include "all-font-metrics.hh"
 
 #if HAVE_PANGO_FT2
 #include "stencil.hh"
@@ -76,16 +80,10 @@ Pango_font::derived_mark () const
 }
 
 
-Index_to_charcode_map const *
-Pango_font::get_index_to_charcode_map (string key, FT_Face face)
+void
+get_glyph_index_name (char *s, FT_ULong code)
 {
-  if (charcode_maps_.find (key) == charcode_maps_.end ())
-    charcode_maps_[key] = make_index_to_charcode_map (face);
-
-  if (charcode_maps_.find (key) == charcode_maps_.end ())
-    return 0;
-  
-  return &charcode_maps_[key];
+  sprintf (s, "glyphIndex%lX", code);
 }
 
 void
@@ -149,8 +147,9 @@ Pango_font::pango_item_string_stencil (PangoItem const *item, string str,
   Index_to_charcode_map const *cmap = 0;
   bool has_glyph_names = ftface->face_flags & FT_FACE_FLAG_GLYPH_NAMES;
   if  (! has_glyph_names)
-    cmap = ((Pango_font*)this)->get_index_to_charcode_map (file_name, ftface);
-  
+    cmap = all_fonts_global->get_index_to_charcode_map (file_name, ftface);
+
+  bool is_ttf = string (FT_Get_X11_Font_Format (ftface)) == "TrueType";
   bool cid_keyed = false;
   for (int i = 0; i < pgs->num_glyphs; i++)
     {
@@ -166,14 +165,12 @@ Pango_font::pango_item_string_stencil (PangoItem const *item, string str,
          if (errorcode)
            programming_error ("FT_Get_Glyph_Name returns error");
        }
-      
+
       SCM char_id = SCM_EOL;
       if (glyph_name[0] == '\0'
          && cmap
-
-         /* Ugh should ask FreeType about font type. */
-         && (file_name.find (".ttf") != NPOS
-             || file_name.find (".TTF") != NPOS))
+         && is_ttf
+         && cmap->find (pg) != cmap->end ())
        {
          FT_ULong char_code = cmap->find (pg)->second;
          get_unicode_name (glyph_name, char_code);
@@ -187,7 +184,17 @@ Pango_font::pango_item_string_stencil (PangoItem const *item, string str,
                                 file_name.c_str ()));
          continue;
        }
+
+      
+      if (glyph_name == string (".notdef") && is_ttf)
+       glyph_name[0] = '\0';
          
+      if (glyph_name[0] == '\0' && is_ttf)
+       {
+         // access by glyph index directly.
+         get_glyph_index_name (glyph_name, pg);
+       }
+      
       if (glyph_name[0] == '\0')
        {
          /*