From 599b553ec94402c5a35c787c847e9ef05188103c Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 28 Mar 2006 16:54:50 +0000 Subject: [PATCH] * lily/ttf.cc (print_trailer): use it. * lily/pango-font.cc (get_unicode_name): new function. * lily/ttf.cc (make_index_to_charcode_map): move function from open-type-font.cc (print_trailer): substitute uniXXXX name if applicable. * lily/pango-font.cc (get_index_to_charcode_map): new function. (pango_item_string_stencil): use it to generate uniXXXX names. --- ChangeLog | 4 ++++ lily/include/open-type-font.hh | 1 + lily/pango-font.cc | 14 ++++++++++++-- lily/ttf.cc | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 29e3ea938e..eaae776e40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2006-03-28 Han-Wen Nienhuys + * lily/ttf.cc (print_trailer): use it. + + * lily/pango-font.cc (get_unicode_name): new function. + * lily/ttf.cc (make_index_to_charcode_map): move function from open-type-font.cc (print_trailer): substitute uniXXXX name if applicable. diff --git a/lily/include/open-type-font.hh b/lily/include/open-type-font.hh index 462837e595..be1f85bf7a 100644 --- a/lily/include/open-type-font.hh +++ b/lily/include/open-type-font.hh @@ -17,6 +17,7 @@ using namespace std; typedef map 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); class Open_type_font : public Font_metric { diff --git a/lily/pango-font.cc b/lily/pango-font.cc index 76ccfbc66d..6419187dbf 100644 --- a/lily/pango-font.cc +++ b/lily/pango-font.cc @@ -88,6 +88,16 @@ Pango_font::get_index_to_charcode_map (string key, FT_Face face) return &charcode_maps_[key]; } +void +get_unicode_name (char*s, FT_ULong code) +{ + if (code > 0xFFFF) + sprintf (s, "u%06lX", char_code); + else + sprintf (s, "uni%04lX", char_code); +} + + Stencil Pango_font::pango_item_string_stencil (PangoItem const *item, string str) const { @@ -147,9 +157,9 @@ Pango_font::pango_item_string_stencil (PangoItem const *item, string str) const if (glyph_name[0] == '\0' && cmap) { FT_ULong char_code = cmap->find (pg)->second; - - sprintf (glyph_name, "uni%04lX", char_code); + get_unicode_name (glyph_name, char_code); } + if (glyph_name[0] == '\0') { diff --git a/lily/ttf.cc b/lily/ttf.cc index 8d22ccee18..a3f8529767 100644 --- a/lily/ttf.cc +++ b/lily/ttf.cc @@ -165,7 +165,7 @@ print_trailer (void *out, if (!glyph_name[0]) { - sprintf (glyph_name, "uni%04lX", ic_map[i]); + get_unicode_name (glyph_name, ic_map[i]); } lily_cookie_fprintf (out, "/%s %d def ", glyph_name, i); -- 2.39.2