]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/ttf.cc (print_trailer): if all else fails: use
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 20 Oct 2006 16:43:47 +0000 (16:43 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 20 Oct 2006 16:43:47 +0000 (16:43 +0000)
glyphIndexXXXX as glyph name.

* lily/pango-font.cc (pango_item_string_stencil): only use cmap
entry if cmap contains glyph.
(get_index_to_charcode_map): remove from Pango_font class, use
global filename -> font mapping.
(get_glyph_index_name): new function.
(pango_item_string_stencil): use glyphIndexXXXX as glyph name,
only for TTF.

ChangeLog
lily/include/open-type-font.hh
lily/include/pango-font.hh
lily/pango-font.cc
lily/ttf.cc

index 5495d56b808cd4783bc68974424303ce50482672..62c4b1ae93bee23e4975715a01386a7ed54c99d8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,15 @@
 2006-10-20  Han-Wen Nienhuys  <hanwen@lilypond.org>
 
+       * lily/ttf.cc (print_trailer): if all else fails: use
+       glyphIndexXXXX as glyph name.
+
        * lily/pango-font.cc (pango_item_string_stencil): only use cmap
        entry if cmap contains glyph.
+       (get_index_to_charcode_map): remove from Pango_font class, use
+       global filename -> font mapping.
+       (get_glyph_index_name): new function.
+       (pango_item_string_stencil): use glyphIndexXXXX as glyph name,
+       only for TTF. 
 
        * scripts/lilypond-book.py (main): use -deps-box-padding=-3
 
index be1f85bf7accd9f04d06c47d2912beed86e2e191..c0490be6e5042f0c28c4908ad2313841888015a6 100644 (file)
@@ -18,6 +18,7 @@ using namespace std;
 typedef map<FT_UInt, FT_ULong> Index_to_charcode_map;
 Index_to_charcode_map make_index_to_charcode_map (FT_Face face);
 void get_unicode_name (char*s, FT_ULong code);
+void get_glyph_index_name (char*s, FT_ULong code);
 
 class Open_type_font : public Font_metric
 {
index 9e330faeab9c7bef4bd0c6cfdaa0eaeccf6cea2b..5449ec0a422cb400b0f9d8d1747060643b48c513 100644 (file)
@@ -29,9 +29,6 @@ class Pango_font : public Font_metric
   SCM physical_font_tab_;
   Direction text_direction_;
 
-  map<string, Index_to_charcode_map > charcode_maps_;
-
-  Index_to_charcode_map const *get_index_to_charcode_map (string postscript_name, FT_Face face);
 public:
   SCM physical_font_tab () const;
   Pango_font (PangoFT2FontMap *,
index 63029b3bbcd4593b9ca55ed320669ce9f8c68e45..7da47e6672a3e9885b52984eea3eca86b9238d62 100644 (file)
@@ -76,16 +76,26 @@ Pango_font::derived_mark () const
 }
 
 
+map<string, Index_to_charcode_map > filename_charcode_maps_map;
+Index_to_charcode_map const *get_index_to_charcode_map (string postscript_name, FT_Face face);
+
+
 Index_to_charcode_map const *
-Pango_font::get_index_to_charcode_map (string key, FT_Face face)
+get_index_to_charcode_map (string filename, FT_Face face)
 {
-  if (charcode_maps_.find (key) == charcode_maps_.end ())
-    charcode_maps_[key] = make_index_to_charcode_map (face);
+  if (filename_charcode_maps_map.find (filename) == filename_charcode_maps_map.end ())
+    filename_charcode_maps_map[filename] = make_index_to_charcode_map (face);
 
-  if (charcode_maps_.find (key) == charcode_maps_.end ())
+  if (filename_charcode_maps_map.find (filename) == filename_charcode_maps_map.end ())
     return 0;
   
-  return &charcode_maps_[key];
+  return &filename_charcode_maps_map[filename];
+}
+
+void
+get_glyph_index_name (char *s, FT_ULong code)
+{
+  sprintf (s, "glyphIndex%lX", code);
 }
 
 void
@@ -149,8 +159,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 = get_index_to_charcode_map (file_name, ftface);
+  bool is_ttf = (file_name.find (".ttf") != NPOS
+                || file_name.find (".TTF") != NPOS);
   bool cid_keyed = false;
   for (int i = 0; i < pgs->num_glyphs; i++)
     {
@@ -172,8 +183,7 @@ Pango_font::pango_item_string_stencil (PangoItem const *item, string str,
          && 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;
@@ -188,7 +198,13 @@ Pango_font::pango_item_string_stencil (PangoItem const *item, string str,
                                 file_name.c_str ()));
          continue;
        }
-         
+
+      if (glyph_name[0] == '\0' && is_ttf)
+       {
+         // access by glyph index directly.
+         get_glyph_index_name (glyph_name, pg);
+       }
+      
       if (glyph_name[0] == '\0')
        {
          /*
index 9f5fbfb8a29a408fe75d8c380a839900c5854e62..4f2d6c8748f71db98ea33fb6ed1a7a0732c0aa8c 100644 (file)
@@ -26,11 +26,18 @@ make_index_to_charcode_map (FT_Face face)
   FT_UInt gindex;
 
   FT_CharMap current_cmap = face->charmap;
-  FT_Select_Charmap(face, FT_ENCODING_UNICODE);
+  //  FT_Select_Charmap(face, FT_ENCODING_UNICODE);
+  FT_Select_Charmap(face, FT_ENCODING_NONE);  
+
+  int j = 0;
   for (charcode = FT_Get_First_Char (face, &gindex); gindex != 0;
        charcode = FT_Get_Next_Char (face, charcode, &gindex))
-    m[gindex] = charcode;
+    {
+      m[gindex] = charcode;
+      j++;
+    }
   FT_Set_Charmap (face, current_cmap);
+
   
   return m;
 }
@@ -174,12 +181,21 @@ print_trailer (void *out,
          get_unicode_name (glyph_name, ucode);
        }
 
+      if (!glyph_name[0])
+       {
+         get_glyph_index_name (glyph_name, i);
+       }
+      
       if (glyph_name[0])
        {
          lily_cookie_fprintf (out, "/%s %d def ", glyph_name, i);
          output_count ++;
        }
-      
+      else
+       {
+         programming_error (to_string ("no name for glyph %d", i));
+       }
+                            
       if (! (output_count % 5))
        lily_cookie_fprintf (out, "\n");
     }