35#define FT_COMPONENT ttload
56 FT_LOCAL_DEF( TT_Table )
57 tt_face_lookup_table( TT_Face face,
62#ifdef FT_DEBUG_LEVEL_TRACE
63 FT_Bool zero_length = FALSE;
67 FT_TRACE4((
"tt_face_lookup_table: %p, `%c%c%c%c' -- ",
69 (FT_Char)( tag >> 24 ),
70 (FT_Char)( tag >> 16 ),
71 (FT_Char)( tag >> 8 ),
74 entry = face->dir_tables;
75 limit = entry + face->num_tables;
77 for ( ; entry < limit; entry++ )
81 if ( entry->Tag == tag )
83 if ( entry->Length != 0 )
85 FT_TRACE4((
"found table.\n" ));
88#ifdef FT_DEBUG_LEVEL_TRACE
94#ifdef FT_DEBUG_LEVEL_TRACE
96 FT_TRACE4((
"ignoring empty table\n" ));
98 FT_TRACE4((
"could not find table\n" ));
130 FT_LOCAL_DEF( FT_Error )
131 tt_face_goto_table( TT_Face face,
140 table = tt_face_lookup_table( face, tag );
144 *length = table->Length;
146 if ( FT_STREAM_SEEK( table->Offset ) )
150 error = FT_THROW( Table_Missing );
175 check_table_dir( SFNT_Header sfnt,
180 FT_UShort nn, valid_entries = 0;
181 FT_UInt has_head = 0, has_sing = 0, has_meta = 0;
182 FT_ULong offset = sfnt->offset + 12;
184 static const FT_Frame_Field table_dir_entry_fields[] =
187#define FT_STRUCTURE TT_TableRec
189 FT_FRAME_START( 16 ),
190 FT_FRAME_ULONG( Tag ),
191 FT_FRAME_ULONG( CheckSum ),
192 FT_FRAME_ULONG( Offset ),
193 FT_FRAME_ULONG( Length ),
198 if ( FT_STREAM_SEEK( offset ) )
201 for ( nn = 0; nn < sfnt->num_tables; nn++ )
206 if ( FT_STREAM_READ_FIELDS( table_dir_entry_fields, &table ) )
208 FT_TRACE2((
"check_table_dir:"
209 " can read only %hu table%s in font (instead of %hu)\n",
210 nn, nn == 1 ?
"" :
"s", sfnt->num_tables ));
211 sfnt->num_tables = nn;
217 if ( table.Offset > stream->size )
219 FT_TRACE2((
"check_table_dir: table entry %hu invalid\n", nn ));
222 else if ( table.Length > stream->size - table.Offset )
229 if ( table.Tag == TTAG_hmtx ||
230 table.Tag == TTAG_vmtx )
234 FT_TRACE2((
"check_table_dir: table entry %hu invalid\n", nn ));
241 if ( table.Tag == TTAG_head || table.Tag == TTAG_bhed )
246#ifndef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
247 if ( table.Tag == TTAG_head )
260 if ( table.Length < 0x36 )
262 FT_TRACE2((
"check_table_dir:"
263 " `head' or `bhed' table too small\n" ));
264 error = FT_THROW( Table_Missing );
268 if ( FT_STREAM_SEEK( table.Offset + 12 ) ||
269 FT_READ_ULONG( magic ) )
272 if ( magic != 0x5F0F3CF5UL )
273 FT_TRACE2((
"check_table_dir:"
274 " invalid magic number in `head' or `bhed' table\n"));
276 if ( FT_STREAM_SEEK( offset + ( nn + 1 ) * 16 ) )
279 else if ( table.Tag == TTAG_SING )
281 else if ( table.Tag == TTAG_META )
285 *valid = valid_entries;
287 if ( !valid_entries )
289 FT_TRACE2((
"check_table_dir: no valid tables found\n" ));
290 error = FT_THROW( Unknown_File_Format );
295 if ( has_head || ( has_sing && has_meta ) )
302 FT_TRACE2((
"check_table_dir:" ));
303#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
304 FT_TRACE2((
" neither `head', `bhed', nor `sing' table found\n" ));
306 FT_TRACE2((
" neither `head' nor `sing' table found\n" ));
308 error = FT_THROW( Table_Missing );
341 FT_LOCAL_DEF( FT_Error )
342 tt_face_load_font_dir( TT_Face face,
347 FT_Memory memory = stream->memory;
348 FT_UShort nn, valid_entries = 0;
350 static const FT_Frame_Field offset_table_fields[] =
353#define FT_STRUCTURE SFNT_HeaderRec
356 FT_FRAME_USHORT( num_tables ),
357 FT_FRAME_USHORT( search_range ),
358 FT_FRAME_USHORT( entry_selector ),
359 FT_FRAME_USHORT( range_shift ),
364 FT_TRACE2((
"tt_face_load_font_dir: %p\n", (
void *)face ));
368 sfnt.offset = FT_STREAM_POS();
370 if ( FT_READ_ULONG( sfnt.format_tag ) ||
371 FT_STREAM_READ_FIELDS( offset_table_fields, &sfnt ) )
376 if ( sfnt.search_range != 1 << ( sfnt.entry_selector + 4 ) ||
377 sfnt.search_range + sfnt.range_shift != sfnt.num_tables << 4 )
378 return FT_THROW( Unknown_File_Format );
383 FT_TRACE2((
"-- Number of tables: %10hu\n", sfnt.num_tables ));
384 FT_TRACE2((
"-- Format version: 0x%08lx\n", sfnt.format_tag ));
386 if ( sfnt.format_tag != TTAG_OTTO )
389 error = check_table_dir( &sfnt, stream, &valid_entries );
392 FT_TRACE2((
"tt_face_load_font_dir:"
393 " invalid table directory for TrueType\n" ));
399 valid_entries = sfnt.num_tables;
400 if ( !valid_entries )
402 FT_TRACE2((
"tt_face_load_font_dir: no valid tables found\n" ));
403 error = FT_THROW( Unknown_File_Format );
408 face->num_tables = valid_entries;
409 face->format_tag = sfnt.format_tag;
411 if ( FT_QNEW_ARRAY( face->dir_tables, face->num_tables ) )
414 if ( FT_STREAM_SEEK( sfnt.offset + 12 ) ||
415 FT_FRAME_ENTER( sfnt.num_tables * 16L ) )
419 FT_TRACE2((
" tag offset length checksum\n" ));
420 FT_TRACE2((
" ----------------------------------\n" ));
423 for ( nn = 0; nn < sfnt.num_tables; nn++ )
430 entry.Tag = FT_GET_TAG4();
431 entry.CheckSum = FT_GET_ULONG();
432 entry.Offset = FT_GET_ULONG();
433 entry.Length = FT_GET_ULONG();
437 if ( entry.Offset > stream->size )
439 else if ( entry.Length > stream->size - entry.Offset )
441 if ( entry.Tag == TTAG_hmtx ||
442 entry.Tag == TTAG_vmtx )
444#ifdef FT_DEBUG_LEVEL_TRACE
445 FT_ULong old_length = entry.Length;
450 entry.Length = ( stream->size - entry.Offset ) & ~3U;
452 FT_TRACE2((
" %c%c%c%c %08lx %08lx %08lx"
453 " (sanitized; original length %08lx)",
454 (FT_Char)( entry.Tag >> 24 ),
455 (FT_Char)( entry.Tag >> 16 ),
456 (FT_Char)( entry.Tag >> 8 ),
457 (FT_Char)( entry.Tag ),
466#ifdef FT_DEBUG_LEVEL_TRACE
468 FT_TRACE2((
" %c%c%c%c %08lx %08lx %08lx",
469 (FT_Char)( entry.Tag >> 24 ),
470 (FT_Char)( entry.Tag >> 16 ),
471 (FT_Char)( entry.Tag >> 8 ),
472 (FT_Char)( entry.Tag ),
480 for ( i = 0; i < valid_entries; i++ )
482 if ( face->dir_tables[i].Tag == entry.Tag )
490 FT_TRACE2((
" (duplicate, ignored)\n" ));
498 face->dir_tables[valid_entries++] = entry;
503 face->num_tables = valid_entries;
507 if ( !valid_entries )
509 FT_TRACE2((
"tt_face_load_font_dir: no valid tables found\n" ));
510 error = FT_THROW( Unknown_File_Format );
514 FT_TRACE2((
"table directory loaded\n" ));
568 FT_LOCAL_DEF( FT_Error )
569 tt_face_load_any( TT_Face face,
584 size = face->root.stream->size;
594 FT_Long idx = face->root.face_index & 0xFFFF;
597 if ( idx >= face->ttc_header.count )
600 offset += face->ttc_header.offsets[idx];
601 size = 4 + 8 + 16 * face->num_tables;
606 table = tt_face_lookup_table( face, tag );
609 error = FT_THROW( Table_Missing );
613 offset += table->Offset;
614 size = table->Length;
617 if ( length && *length == 0 )
627 stream = face->root.stream;
629 if ( FT_STREAM_READ_AT( offset, buffer, size ) )
656 tt_face_load_generic_header( TT_Face face,
663 static const FT_Frame_Field header_fields[] =
666#define FT_STRUCTURE TT_Header
668 FT_FRAME_START( 54 ),
669 FT_FRAME_ULONG ( Table_Version ),
670 FT_FRAME_ULONG ( Font_Revision ),
671 FT_FRAME_LONG ( CheckSum_Adjust ),
672 FT_FRAME_LONG ( Magic_Number ),
673 FT_FRAME_USHORT( Flags ),
674 FT_FRAME_USHORT( Units_Per_EM ),
675 FT_FRAME_ULONG ( Created[0] ),
676 FT_FRAME_ULONG ( Created[1] ),
677 FT_FRAME_ULONG ( Modified[0] ),
678 FT_FRAME_ULONG ( Modified[1] ),
679 FT_FRAME_SHORT ( xMin ),
680 FT_FRAME_SHORT ( yMin ),
681 FT_FRAME_SHORT ( xMax ),
682 FT_FRAME_SHORT ( yMax ),
683 FT_FRAME_USHORT( Mac_Style ),
684 FT_FRAME_USHORT( Lowest_Rec_PPEM ),
685 FT_FRAME_SHORT ( Font_Direction ),
686 FT_FRAME_SHORT ( Index_To_Loc_Format ),
687 FT_FRAME_SHORT ( Glyph_Data_Format ),
692 error = face->goto_table( face, tag, stream, 0 );
696 header = &face->header;
698 if ( FT_STREAM_READ_FIELDS( header_fields, header ) )
701 FT_TRACE3((
"Units per EM: %4hu\n", header->Units_Per_EM ));
702 FT_TRACE3((
"IndexToLoc: %4hd\n", header->Index_To_Loc_Format ));
709 FT_LOCAL_DEF( FT_Error )
710 tt_face_load_head( TT_Face face,
713 return tt_face_load_generic_header( face, stream, TTAG_head );
717#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
719 FT_LOCAL_DEF( FT_Error )
720 tt_face_load_bhed( TT_Face face,
723 return tt_face_load_generic_header( face, stream, TTAG_bhed );
747 FT_LOCAL_DEF( FT_Error )
748 tt_face_load_maxp( TT_Face face,
752 TT_MaxProfile* maxProfile = &face->max_profile;
754 static const FT_Frame_Field maxp_fields[] =
757#define FT_STRUCTURE TT_MaxProfile
760 FT_FRAME_LONG ( version ),
761 FT_FRAME_USHORT( numGlyphs ),
765 static const FT_Frame_Field maxp_fields_extra[] =
767 FT_FRAME_START( 26 ),
768 FT_FRAME_USHORT( maxPoints ),
769 FT_FRAME_USHORT( maxContours ),
770 FT_FRAME_USHORT( maxCompositePoints ),
771 FT_FRAME_USHORT( maxCompositeContours ),
772 FT_FRAME_USHORT( maxZones ),
773 FT_FRAME_USHORT( maxTwilightPoints ),
774 FT_FRAME_USHORT( maxStorage ),
775 FT_FRAME_USHORT( maxFunctionDefs ),
776 FT_FRAME_USHORT( maxInstructionDefs ),
777 FT_FRAME_USHORT( maxStackElements ),
778 FT_FRAME_USHORT( maxSizeOfInstructions ),
779 FT_FRAME_USHORT( maxComponentElements ),
780 FT_FRAME_USHORT( maxComponentDepth ),
785 error = face->goto_table( face, TTAG_maxp, stream, 0 );
789 if ( FT_STREAM_READ_FIELDS( maxp_fields, maxProfile ) )
792 maxProfile->maxPoints = 0;
793 maxProfile->maxContours = 0;
794 maxProfile->maxCompositePoints = 0;
795 maxProfile->maxCompositeContours = 0;
796 maxProfile->maxZones = 0;
797 maxProfile->maxTwilightPoints = 0;
798 maxProfile->maxStorage = 0;
799 maxProfile->maxFunctionDefs = 0;
800 maxProfile->maxInstructionDefs = 0;
801 maxProfile->maxStackElements = 0;
802 maxProfile->maxSizeOfInstructions = 0;
803 maxProfile->maxComponentElements = 0;
804 maxProfile->maxComponentDepth = 0;
806 if ( maxProfile->version >= 0x10000L )
808 if ( FT_STREAM_READ_FIELDS( maxp_fields_extra, maxProfile ) )
817 if ( maxProfile->maxFunctionDefs < 64 )
818 maxProfile->maxFunctionDefs = 64;
821 if ( maxProfile->maxTwilightPoints > ( 0xFFFFU - 4 ) )
823 FT_TRACE0((
"tt_face_load_maxp:"
824 " too much twilight points in `maxp' table;\n" ));
826 " some glyphs might be rendered incorrectly\n" ));
828 maxProfile->maxTwilightPoints = 0xFFFFU - 4;
832 FT_TRACE3((
"numGlyphs: %hu\n", maxProfile->numGlyphs ));
857 FT_LOCAL_DEF( FT_Error )
858 tt_face_load_name( TT_Face face,
862 FT_Memory memory = stream->memory;
863 FT_ULong table_pos, table_len;
864 FT_ULong storage_start, storage_limit;
866 TT_Name names = NULL;
867 TT_LangTag langTags = NULL;
869 static const FT_Frame_Field name_table_fields[] =
872#define FT_STRUCTURE TT_NameTableRec
875 FT_FRAME_USHORT( format ),
876 FT_FRAME_USHORT( numNameRecords ),
877 FT_FRAME_USHORT( storageOffset ),
881 static const FT_Frame_Field name_record_fields[] =
884#define FT_STRUCTURE TT_NameRec
887 FT_FRAME_USHORT( platformID ),
888 FT_FRAME_USHORT( encodingID ),
889 FT_FRAME_USHORT( languageID ),
890 FT_FRAME_USHORT( nameID ),
891 FT_FRAME_USHORT( stringLength ),
892 FT_FRAME_USHORT( stringOffset ),
896 static const FT_Frame_Field langTag_record_fields[] =
899#define FT_STRUCTURE TT_LangTagRec
902 FT_FRAME_USHORT( stringLength ),
903 FT_FRAME_USHORT( stringOffset ),
908 table = &face->name_table;
909 table->stream = stream;
911 error = face->goto_table( face, TTAG_name, stream, &table_len );
915 table_pos = FT_STREAM_POS();
917 if ( FT_STREAM_READ_FIELDS( name_table_fields, table ) )
927 storage_start = table_pos + 6 + 12 * table->numNameRecords;
928 storage_limit = table_pos + table_len;
930 if ( storage_start > storage_limit )
932 FT_ERROR((
"tt_face_load_name: invalid `name' table\n" ));
933 error = FT_THROW( Name_Table_Missing );
939 if ( table->format == 1 )
941 if ( FT_STREAM_SEEK( storage_start ) ||
942 FT_READ_USHORT( table->numLangTagRecords ) )
945 storage_start += 2 + 4 * table->numLangTagRecords;
948 if ( FT_QNEW_ARRAY( langTags, table->numLangTagRecords ) ||
949 FT_FRAME_ENTER( table->numLangTagRecords * 4 ) )
954 TT_LangTag entry = langTags;
955 TT_LangTag limit = FT_OFFSET( entry, table->numLangTagRecords );
958 for ( ; entry < limit; entry++ )
960 (void)FT_STREAM_READ_FIELDS( langTag_record_fields, entry );
963 entry->stringOffset += table_pos + table->storageOffset;
964 if ( entry->stringOffset < storage_start ||
965 entry->stringOffset + entry->stringLength > storage_limit )
968 entry->stringLength = 0;
972 entry->string = NULL;
975 table->langTags = langTags;
981 (void)FT_STREAM_SEEK( table_pos + 6 );
985 if ( FT_QNEW_ARRAY( names, table->numNameRecords ) ||
986 FT_FRAME_ENTER( table->numNameRecords * 12 ) )
991 TT_Name entry = names;
992 FT_UInt count = table->numNameRecords;
996 for ( ; count > 0; count-- )
998 if ( FT_STREAM_READ_FIELDS( name_record_fields, entry ) )
1002 if ( entry->stringLength == 0 )
1006 entry->stringOffset += table_pos + table->storageOffset;
1007 if ( entry->stringOffset < storage_start ||
1008 entry->stringOffset + entry->stringLength > storage_limit )
1016 if ( table->format == 1 && entry->languageID >= 0x8000U )
1018 if ( entry->languageID - 0x8000U >= table->numLangTagRecords ||
1019 !table->langTags[entry->languageID - 0x8000U].stringLength )
1027 entry->string = NULL;
1034 FT_MEM_QRENEW_ARRAY( names,
1035 table->numNameRecords,
1037 table->names = names;
1039 table->numNameRecords = valid;
1045 face->num_names = (FT_UShort)table->numNameRecords;
1049 FT_FREE( langTags );
1066 FT_LOCAL_DEF(
void )
1067 tt_face_free_name( TT_Face face )
1069 FT_Memory memory = face->root.memory;
1070 TT_NameTable table = &face->name_table;
1075 TT_Name entry = table->names;
1076 TT_Name limit = entry + table->numNameRecords;
1079 for ( ; entry < limit; entry++ )
1080 FT_FREE( entry->string );
1082 FT_FREE( table->names );
1085 if ( table->langTags )
1087 TT_LangTag entry = table->langTags;
1088 TT_LangTag limit = entry + table->numLangTagRecords;
1091 for ( ; entry < limit; entry++ )
1092 FT_FREE( entry->string );
1094 FT_FREE( table->langTags );
1097 table->numNameRecords = 0;
1098 table->numLangTagRecords = 0;
1100 table->storageOffset = 0;
1124 FT_LOCAL_DEF( FT_Error )
1125 tt_face_load_cmap( TT_Face face,
1131 error = face->goto_table( face, TTAG_cmap, stream, &face->cmap_size );
1135 if ( FT_FRAME_EXTRACT( face->cmap_size, face->cmap_table ) )
1136 face->cmap_size = 0;
1162 FT_LOCAL_DEF( FT_Error )
1163 tt_face_load_os2( TT_Face face,
1169 static const FT_Frame_Field os2_fields[] =
1172#define FT_STRUCTURE TT_OS2
1174 FT_FRAME_START( 78 ),
1175 FT_FRAME_USHORT( version ),
1176 FT_FRAME_SHORT ( xAvgCharWidth ),
1177 FT_FRAME_USHORT( usWeightClass ),
1178 FT_FRAME_USHORT( usWidthClass ),
1179 FT_FRAME_SHORT ( fsType ),
1180 FT_FRAME_SHORT ( ySubscriptXSize ),
1181 FT_FRAME_SHORT ( ySubscriptYSize ),
1182 FT_FRAME_SHORT ( ySubscriptXOffset ),
1183 FT_FRAME_SHORT ( ySubscriptYOffset ),
1184 FT_FRAME_SHORT ( ySuperscriptXSize ),
1185 FT_FRAME_SHORT ( ySuperscriptYSize ),
1186 FT_FRAME_SHORT ( ySuperscriptXOffset ),
1187 FT_FRAME_SHORT ( ySuperscriptYOffset ),
1188 FT_FRAME_SHORT ( yStrikeoutSize ),
1189 FT_FRAME_SHORT ( yStrikeoutPosition ),
1190 FT_FRAME_SHORT ( sFamilyClass ),
1191 FT_FRAME_BYTE ( panose[0] ),
1192 FT_FRAME_BYTE ( panose[1] ),
1193 FT_FRAME_BYTE ( panose[2] ),
1194 FT_FRAME_BYTE ( panose[3] ),
1195 FT_FRAME_BYTE ( panose[4] ),
1196 FT_FRAME_BYTE ( panose[5] ),
1197 FT_FRAME_BYTE ( panose[6] ),
1198 FT_FRAME_BYTE ( panose[7] ),
1199 FT_FRAME_BYTE ( panose[8] ),
1200 FT_FRAME_BYTE ( panose[9] ),
1201 FT_FRAME_ULONG ( ulUnicodeRange1 ),
1202 FT_FRAME_ULONG ( ulUnicodeRange2 ),
1203 FT_FRAME_ULONG ( ulUnicodeRange3 ),
1204 FT_FRAME_ULONG ( ulUnicodeRange4 ),
1205 FT_FRAME_BYTE ( achVendID[0] ),
1206 FT_FRAME_BYTE ( achVendID[1] ),
1207 FT_FRAME_BYTE ( achVendID[2] ),
1208 FT_FRAME_BYTE ( achVendID[3] ),
1210 FT_FRAME_USHORT( fsSelection ),
1211 FT_FRAME_USHORT( usFirstCharIndex ),
1212 FT_FRAME_USHORT( usLastCharIndex ),
1213 FT_FRAME_SHORT ( sTypoAscender ),
1214 FT_FRAME_SHORT ( sTypoDescender ),
1215 FT_FRAME_SHORT ( sTypoLineGap ),
1216 FT_FRAME_USHORT( usWinAscent ),
1217 FT_FRAME_USHORT( usWinDescent ),
1222 static const FT_Frame_Field os2_fields_extra1[] =
1224 FT_FRAME_START( 8 ),
1225 FT_FRAME_ULONG( ulCodePageRange1 ),
1226 FT_FRAME_ULONG( ulCodePageRange2 ),
1231 static const FT_Frame_Field os2_fields_extra2[] =
1233 FT_FRAME_START( 10 ),
1234 FT_FRAME_SHORT ( sxHeight ),
1235 FT_FRAME_SHORT ( sCapHeight ),
1236 FT_FRAME_USHORT( usDefaultChar ),
1237 FT_FRAME_USHORT( usBreakChar ),
1238 FT_FRAME_USHORT( usMaxContext ),
1243 static const FT_Frame_Field os2_fields_extra5[] =
1245 FT_FRAME_START( 4 ),
1246 FT_FRAME_USHORT( usLowerOpticalPointSize ),
1247 FT_FRAME_USHORT( usUpperOpticalPointSize ),
1255 error = face->goto_table( face, TTAG_OS2, stream, 0 );
1261 if ( FT_STREAM_READ_FIELDS( os2_fields, os2 ) )
1264 os2->ulCodePageRange1 = 0;
1265 os2->ulCodePageRange2 = 0;
1267 os2->sCapHeight = 0;
1268 os2->usDefaultChar = 0;
1269 os2->usBreakChar = 0;
1270 os2->usMaxContext = 0;
1271 os2->usLowerOpticalPointSize = 0;
1272 os2->usUpperOpticalPointSize = 0xFFFF;
1274 if ( os2->version >= 0x0001 )
1277 if ( FT_STREAM_READ_FIELDS( os2_fields_extra1, os2 ) )
1280 if ( os2->version >= 0x0002 )
1283 if ( FT_STREAM_READ_FIELDS( os2_fields_extra2, os2 ) )
1286 if ( os2->version >= 0x0005 )
1289 if ( FT_STREAM_READ_FIELDS( os2_fields_extra5, os2 ) )
1295 FT_TRACE3((
"sTypoAscender: %4hd\n", os2->sTypoAscender ));
1296 FT_TRACE3((
"sTypoDescender: %4hd\n", os2->sTypoDescender ));
1297 FT_TRACE3((
"usWinAscent: %4hu\n", os2->usWinAscent ));
1298 FT_TRACE3((
"usWinDescent: %4hu\n", os2->usWinDescent ));
1299 FT_TRACE3((
"fsSelection: 0x%2hx\n", os2->fsSelection ));
1324 FT_LOCAL_DEF( FT_Error )
1325 tt_face_load_post( TT_Face face,
1329 TT_Postscript* post = &face->postscript;
1331 static const FT_Frame_Field post_fields[] =
1334#define FT_STRUCTURE TT_Postscript
1336 FT_FRAME_START( 32 ),
1337 FT_FRAME_LONG ( FormatType ),
1338 FT_FRAME_LONG ( italicAngle ),
1339 FT_FRAME_SHORT( underlinePosition ),
1340 FT_FRAME_SHORT( underlineThickness ),
1341 FT_FRAME_ULONG( isFixedPitch ),
1342 FT_FRAME_ULONG( minMemType42 ),
1343 FT_FRAME_ULONG( maxMemType42 ),
1344 FT_FRAME_ULONG( minMemType1 ),
1345 FT_FRAME_ULONG( maxMemType1 ),
1350 error = face->goto_table( face, TTAG_post, stream, 0 );
1354 if ( FT_STREAM_READ_FIELDS( post_fields, post ) )
1357 if ( post->FormatType != 0x00030000L &&
1358 post->FormatType != 0x00025000L &&
1359 post->FormatType != 0x00020000L &&
1360 post->FormatType != 0x00010000L )
1361 return FT_THROW( Invalid_Post_Table_Format );
1366 FT_TRACE3((
"FormatType: 0x%lx\n", post->FormatType ));
1367 FT_TRACE3((
"isFixedPitch: %s\n", post->isFixedPitch
1368 ?
" yes" :
" no" ));
1392 FT_LOCAL_DEF( FT_Error )
1393 tt_face_load_pclt( TT_Face face,
1396 static const FT_Frame_Field pclt_fields[] =
1399#define FT_STRUCTURE TT_PCLT
1401 FT_FRAME_START( 54 ),
1402 FT_FRAME_ULONG ( Version ),
1403 FT_FRAME_ULONG ( FontNumber ),
1404 FT_FRAME_USHORT( Pitch ),
1405 FT_FRAME_USHORT( xHeight ),
1406 FT_FRAME_USHORT( Style ),
1407 FT_FRAME_USHORT( TypeFamily ),
1408 FT_FRAME_USHORT( CapHeight ),
1409 FT_FRAME_USHORT( SymbolSet ),
1410 FT_FRAME_BYTES ( TypeFace, 16 ),
1411 FT_FRAME_BYTES ( CharacterComplement, 8 ),
1412 FT_FRAME_BYTES ( FileName, 6 ),
1413 FT_FRAME_CHAR ( StrokeWeight ),
1414 FT_FRAME_CHAR ( WidthType ),
1415 FT_FRAME_BYTE ( SerifStyle ),
1416 FT_FRAME_BYTE ( Reserved ),
1421 TT_PCLT* pclt = &face->pclt;
1425 error = face->goto_table( face, TTAG_PCLT, stream, 0 );
1429 if ( FT_STREAM_READ_FIELDS( pclt_fields, pclt ) )
1455 FT_LOCAL_DEF( FT_Error )
1456 tt_face_load_gasp( TT_Face face,
1460 FT_Memory memory = stream->memory;
1462 FT_UShort j, num_ranges;
1463 TT_GaspRange gasp_ranges = NULL;
1467 error = face->goto_table( face, TTAG_gasp, stream, 0 );
1471 if ( FT_FRAME_ENTER( 4L ) )
1474 face->gasp.version = FT_GET_USHORT();
1475 num_ranges = FT_GET_USHORT();
1480 if ( face->gasp.version >= 2 )
1482 face->gasp.numRanges = 0;
1483 error = FT_THROW( Invalid_Table );
1487 FT_TRACE3((
"numRanges: %hu\n", num_ranges ));
1489 if ( FT_QNEW_ARRAY( gasp_ranges, num_ranges ) ||
1490 FT_FRAME_ENTER( num_ranges * 4L ) )
1493 for ( j = 0; j < num_ranges; j++ )
1495 gasp_ranges[j].maxPPEM = FT_GET_USHORT();
1496 gasp_ranges[j].gaspFlag = FT_GET_USHORT();
1498 FT_TRACE3((
"gaspRange %hu: rangeMaxPPEM %5hu, rangeGaspBehavior 0x%hx\n",
1500 gasp_ranges[j].maxPPEM,
1501 gasp_ranges[j].gaspFlag ));
1504 face->gasp.gaspRanges = gasp_ranges;
1506 face->gasp.numRanges = num_ranges;
1511 FT_FREE( gasp_ranges );