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.
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
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
{
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 *,
}
+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
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++)
{
&& 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;
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')
{
/*
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;
}
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");
}