@@ -166,6 +166,13 @@ BYTE *GetTable(struct TTFONT *font, const char *name)
166166
167167} /* end of GetTable() */
168168
169+ static void utf16be_to_ascii (char *dst, char *src, size_t length) {
170+ ++src;
171+ for (; *src != 0 && length; dst++, src += 2 , --length) {
172+ *dst = *src;
173+ }
174+ }
175+
169176/* --------------------------------------------------------------------
170177** Load the 'name' table, get information from it,
171178** and store that information in the font structure.
@@ -311,6 +318,21 @@ void Read_name(struct TTFONT *font)
311318 font->PostName [length]=(char )NULL ;
312319 replace_newlines_with_spaces (font->PostName );
313320
321+ #ifdef DEBUG_TRUETYPE
322+ debug (" font->PostName=\" %s\" " ,font->PostName );
323+ #endif
324+ continue ;
325+ }
326+
327+ /* Microsoft-format PostScript name */
328+ if ( platform == 3 && nameid == 6 )
329+ {
330+ free (font->PostName );
331+ font->PostName = (char *)calloc (sizeof (char ),length+1 );
332+ utf16be_to_ascii (font->PostName , (char *)strings+offset, length);
333+ font->PostName [length/2 ]=(char )NULL ;
334+ replace_newlines_with_spaces (font->PostName );
335+
314336#ifdef DEBUG_TRUETYPE
315337 debug (" font->PostName=\" %s\" " ,font->PostName );
316338#endif
@@ -967,6 +989,20 @@ const char *ttfont_CharStrings_getname(struct TTFONT *font, int charindex)
967989 char *ptr;
968990 ULONG len;
969991
992+ Fixed post_format;
993+
994+ /* The 'post' table format number. */
995+ post_format = getFixed ( font->post_table );
996+
997+ if ( post_format.whole != 2 || post_format.fraction != 0 )
998+ {
999+ /* We don't have a glyph name table, so generate a name.
1000+ This generated name must match exactly the name that is
1001+ generated by FT2Font in get_glyph_name */
1002+ snprintf (temp, 80 , " uni%08x" , charindex);
1003+ return temp;
1004+ }
1005+
9701006 GlyphIndex = (int )getUSHORT ( font->post_table + 34 + (charindex * 2 ) );
9711007
9721008 if ( GlyphIndex <= 257 ) /* If a standard Apple name, */
@@ -1011,11 +1047,6 @@ void ttfont_CharStrings(TTStreamWriter& stream, struct TTFONT *font, std::vector
10111047 /* The 'post' table format number. */
10121048 post_format = getFixed ( font->post_table );
10131049
1014- if ( post_format.whole != 2 || post_format.fraction != 0 )
1015- {
1016- throw TTException (" TrueType fontdoes not have a format 2.0 'post' table" );
1017- }
1018-
10191050 /* Emmit the start of the PostScript code to define the dictionary. */
10201051 stream.printf (" /CharStrings %d dict dup begin\n " , glyph_ids.size ());
10211052
0 commit comments