X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=lily%2Fttf.cc;h=2e5eb8865d14a6223f787afda487d1745d49eab3;hb=e1679a36d8dcf7535bd5e91b9fae3609bf37a0b6;hp=a3f85297672cebd36c8faceb32f93341df363ee2;hpb=599b553ec94402c5a35c787c847e9ef05188103c;p=lilypond.git diff --git a/lily/ttf.cc b/lily/ttf.cc index a3f8529767..2e5eb8865d 100644 --- a/lily/ttf.cc +++ b/lily/ttf.cc @@ -10,7 +10,6 @@ #include -#include "lily-proto.hh" #include "memory-stream.hh" #include "warn.hh" #include "lily-guile.hh" @@ -24,11 +23,20 @@ make_index_to_charcode_map (FT_Face face) Index_to_charcode_map m; FT_ULong charcode; FT_UInt gindex; - + + FT_CharMap current_cmap = face->charmap; FT_Select_Charmap(face, FT_ENCODING_UNICODE); + + 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; } @@ -44,7 +52,7 @@ print_header (void *out, FT_Face face) = (TT_Postscript *) FT_Get_Sfnt_Table (face, ft_sfnt_post); if (pt->maxMemType42) - lily_cookie_fprintf (out, "%%%%VMUsage: %ld %ld\n", 0, 0); + lily_cookie_fprintf (out, "%%%%VMUsage: %d %d\n", 0, 0); lily_cookie_fprintf (out, "%d dict begin\n", 11); lily_cookie_fprintf (out, "/FontName /%s def\n", @@ -66,8 +74,8 @@ print_header (void *out, FT_Face face) lily_cookie_fprintf (out, "/FontType 42 def\n"); lily_cookie_fprintf (out, "/FontInfo 8 dict dup begin\n"); lily_cookie_fprintf (out, "/version (%d.%d) def\n", - (ht->Font_Revision >> 16), - (ht->Font_Revision &((1 << 16) -1))); + int (ht->Font_Revision >> 16), + int (ht->Font_Revision &((1 << 16) -1))); #if 0 if (strings[0]) @@ -150,6 +158,7 @@ print_trailer (void *out, Index_to_charcode_map ic_map (make_index_to_charcode_map (face)); + int output_count = 0; for (int i = 0; i < mp->numGlyphs; i++) { glyph_name[0] = 0; @@ -158,19 +167,38 @@ print_trailer (void *out, FT_Error error = FT_Get_Glyph_Name (face, i, glyph_name, GLYPH_NAME_LEN); if (error) - programming_error ("print_trailer(): FT_Get_Glyph_Name() returned error"); - else - glyph_name[0] = 0; + { + programming_error ("print_trailer(): FT_Get_Glyph_Name() returned error"); + glyph_name[0] = 0; + } } + if (!glyph_name[0] && ic_map.find (i) != ic_map.end ()) + { + FT_ULong ucode = ic_map[i]; + get_unicode_name (glyph_name, ucode); + } + + if (glyph_name == string (".notdef")) + glyph_name[0] = '\0'; + + if (!glyph_name[0]) { - get_unicode_name (glyph_name, ic_map[i]); + get_glyph_index_name (glyph_name, i); } - lily_cookie_fprintf (out, "/%s %d def ", glyph_name, i); - - if (! (i % 5)) + 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"); }