@@ -166,6 +166,13 @@ BYTE *GetTable(struct TTFONT *font, const char *name)
166
166
167
167
} /* end of GetTable() */
168
168
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
+
169
176
/* --------------------------------------------------------------------
170
177
** Load the 'name' table, get information from it,
171
178
** and store that information in the font structure.
@@ -311,6 +318,21 @@ void Read_name(struct TTFONT *font)
311
318
font->PostName [length]=(char )NULL ;
312
319
replace_newlines_with_spaces (font->PostName );
313
320
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
+
314
336
#ifdef DEBUG_TRUETYPE
315
337
debug (" font->PostName=\" %s\" " ,font->PostName );
316
338
#endif
@@ -967,6 +989,20 @@ const char *ttfont_CharStrings_getname(struct TTFONT *font, int charindex)
967
989
char *ptr;
968
990
ULONG len;
969
991
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
+
970
1006
GlyphIndex = (int )getUSHORT ( font->post_table + 34 + (charindex * 2 ) );
971
1007
972
1008
if ( GlyphIndex <= 257 ) /* If a standard Apple name, */
@@ -1011,11 +1047,6 @@ void ttfont_CharStrings(TTStreamWriter& stream, struct TTFONT *font, std::vector
1011
1047
/* The 'post' table format number. */
1012
1048
post_format = getFixed ( font->post_table );
1013
1049
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
-
1019
1050
/* Emmit the start of the PostScript code to define the dictionary. */
1020
1051
stream.printf (" /CharStrings %d dict dup begin\n " , glyph_ids.size ());
1021
1052
0 commit comments