32#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
39#ifdef TT_CONFIG_OPTION_BDF
43#ifdef TT_CONFIG_OPTION_GPOS_KERNING
55#define FT_COMPONENT sfobjs
61 tt_name_ascii_from_utf16( TT_Name entry,
64 FT_String*
string = NULL;
66 FT_Byte* read = (FT_Byte*)entry->string;
70 len = (FT_UInt)entry->stringLength / 2;
72 if ( FT_QNEW_ARRAY(
string, len + 1 ) )
75 for ( n = 0; n < len; n++ )
77 code = FT_NEXT_USHORT( read );
82 if ( code < 32 || code > 127 )
85 string[n] = (char)
code;
96 tt_name_ascii_from_other( TT_Name entry,
99 FT_String*
string = NULL;
100 FT_UInt len,
code, n;
101 FT_Byte* read = (FT_Byte*)entry->string;
105 len = (FT_UInt)entry->stringLength;
107 if ( FT_QNEW_ARRAY(
string, len + 1 ) )
110 for ( n = 0; n < len; n++ )
117 if ( code < 32 || code > 127 )
120 string[n] = (char)
code;
129 typedef FT_String* (*TT_Name_ConvertFunc)( TT_Name entry,
135 FT_LOCAL_DEF( FT_Error )
136 tt_face_get_name( TT_Face face,
140 FT_Memory memory = face->root.memory;
141 FT_Error error = FT_Err_Ok;
142 FT_String* result = NULL;
146 FT_Int found_apple = -1;
147 FT_Int found_apple_roman = -1;
148 FT_Int found_apple_english = -1;
149 FT_Int found_win = -1;
150 FT_Int found_unicode = -1;
152 FT_Bool is_english = 0;
154 TT_Name_ConvertFunc convert;
159 rec = face->name_table.names;
160 for ( n = 0; n < face->num_names; n++, rec++ )
171 if ( rec->nameID == nameid && rec->stringLength > 0 )
173 switch ( rec->platformID )
175 case TT_PLATFORM_APPLE_UNICODE:
176 case TT_PLATFORM_ISO:
184 case TT_PLATFORM_MACINTOSH:
189 if ( rec->languageID == TT_MAC_LANGID_ENGLISH )
190 found_apple_english = n;
191 else if ( rec->encodingID == TT_MAC_ID_ROMAN )
192 found_apple_roman = n;
195 case TT_PLATFORM_MICROSOFT:
199 if ( found_win == -1 || ( rec->languageID & 0x3FF ) == 0x009 )
201 switch ( rec->encodingID )
203 case TT_MS_ID_SYMBOL_CS:
204 case TT_MS_ID_UNICODE_CS:
206 is_english = FT_BOOL( ( rec->languageID & 0x3FF ) == 0x009 );
222 found_apple = found_apple_roman;
223 if ( found_apple_english >= 0 )
224 found_apple = found_apple_english;
231 if ( found_win >= 0 && !( found_apple >= 0 && !is_english ) )
233 rec = face->name_table.names + found_win;
234 switch ( rec->encodingID )
237 case TT_MS_ID_UNICODE_CS:
238 case TT_MS_ID_SYMBOL_CS:
239 convert = tt_name_ascii_from_utf16;
248 convert = tt_name_ascii_from_utf16;
255 else if ( found_apple >= 0 )
257 rec = face->name_table.names + found_apple;
258 convert = tt_name_ascii_from_other;
260 else if ( found_unicode >= 0 )
262 rec = face->name_table.names + found_unicode;
263 convert = tt_name_ascii_from_utf16;
266 if ( rec && convert )
270 FT_Stream stream = face->name_table.stream;
273 if ( FT_QNEW_ARRAY ( rec->string, rec->stringLength ) ||
274 FT_STREAM_SEEK( rec->stringOffset ) ||
275 FT_STREAM_READ( rec->string, rec->stringLength ) )
277 FT_FREE( rec->string );
278 rec->stringLength = 0;
284 result = convert( rec, memory );
294 sfnt_find_encoding(
int platform_id,
297 typedef struct TEncoding_
301 FT_Encoding encoding;
306 const TEncoding tt_encodings[] =
308 { TT_PLATFORM_ISO, -1, FT_ENCODING_UNICODE },
310 { TT_PLATFORM_APPLE_UNICODE, -1, FT_ENCODING_UNICODE },
312 { TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, FT_ENCODING_APPLE_ROMAN },
314 { TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS, FT_ENCODING_MS_SYMBOL },
315 { TT_PLATFORM_MICROSOFT, TT_MS_ID_UCS_4, FT_ENCODING_UNICODE },
316 { TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, FT_ENCODING_UNICODE },
317 { TT_PLATFORM_MICROSOFT, TT_MS_ID_SJIS, FT_ENCODING_SJIS },
318 { TT_PLATFORM_MICROSOFT, TT_MS_ID_PRC, FT_ENCODING_PRC },
319 { TT_PLATFORM_MICROSOFT, TT_MS_ID_BIG_5, FT_ENCODING_BIG5 },
320 { TT_PLATFORM_MICROSOFT, TT_MS_ID_WANSUNG, FT_ENCODING_WANSUNG },
321 { TT_PLATFORM_MICROSOFT, TT_MS_ID_JOHAB, FT_ENCODING_JOHAB }
324 const TEncoding *cur, *limit;
328 limit = cur +
sizeof ( tt_encodings ) /
sizeof ( tt_encodings[0] );
330 for ( ; cur < limit; cur++ )
332 if ( cur->platform_id == platform_id )
334 if ( cur->encoding_id == encoding_id ||
335 cur->encoding_id == -1 )
336 return cur->encoding;
340 return FT_ENCODING_NONE;
347 sfnt_open_font( FT_Stream stream,
349 FT_Int* face_instance_index,
350 FT_Long* woff2_num_faces )
352 FT_Memory memory = stream->memory;
354 FT_ULong tag, offset;
356 static const FT_Frame_Field ttc_header_fields[] =
359#define FT_STRUCTURE TTC_HeaderRec
362 FT_FRAME_LONG( version ),
363 FT_FRAME_LONG( count ),
367#ifndef FT_CONFIG_OPTION_USE_BROTLI
368 FT_UNUSED( face_instance_index );
369 FT_UNUSED( woff2_num_faces );
373 face->ttc_header.tag = 0;
374 face->ttc_header.version = 0;
375 face->ttc_header.count = 0;
377#if defined( FT_CONFIG_OPTION_USE_ZLIB ) || \
378 defined( FT_CONFIG_OPTION_USE_BROTLI )
382 offset = FT_STREAM_POS();
384 if ( FT_READ_ULONG( tag ) )
387#ifdef FT_CONFIG_OPTION_USE_ZLIB
388 if ( tag == TTAG_wOFF )
390 FT_TRACE2((
"sfnt_open_font: file is a WOFF; synthesizing SFNT\n" ));
392 if ( FT_STREAM_SEEK( offset ) )
395 error = woff_open_font( stream, face );
400 stream = face->root.stream;
405#ifdef FT_CONFIG_OPTION_USE_BROTLI
406 if ( tag == TTAG_wOF2 )
408 FT_TRACE2((
"sfnt_open_font: file is a WOFF2; synthesizing SFNT\n" ));
410 if ( FT_STREAM_SEEK( offset ) )
413 error = woff2_open_font( stream,
421 stream = face->root.stream;
426 if ( tag != 0x00010000UL &&
431 tag != TTAG_0xA5kbd &&
432 tag != TTAG_0xA5lst &&
433 tag != 0x00020000UL )
435 FT_TRACE2((
" not a font using the SFNT container format\n" ));
436 return FT_THROW( Unknown_File_Format );
439 face->ttc_header.tag = TTAG_ttcf;
441 if ( tag == TTAG_ttcf )
446 FT_TRACE3((
"sfnt_open_font: file is a collection\n" ));
448 if ( FT_STREAM_READ_FIELDS( ttc_header_fields, &face->ttc_header ) )
451 FT_TRACE3((
" with %ld subfonts\n",
452 face->ttc_header.count ));
454 if ( face->ttc_header.count == 0 )
455 return FT_THROW( Invalid_Table );
462 if ( (FT_ULong)face->ttc_header.count > stream->size / ( 28 + 4 ) )
463 return FT_THROW( Array_Too_Large );
466 if ( FT_QNEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) )
469 if ( FT_FRAME_ENTER( face->ttc_header.count * 4L ) )
472 for ( n = 0; n < face->ttc_header.count; n++ )
473 face->ttc_header.offsets[n] = FT_GET_ULONG();
479 FT_TRACE3((
"sfnt_open_font: synthesize TTC\n" ));
481 face->ttc_header.version = 1 << 16;
482 face->ttc_header.count = 1;
484 if ( FT_QNEW( face->ttc_header.offsets ) )
487 face->ttc_header.offsets[0] = offset;
494 FT_LOCAL_DEF( FT_Error )
495 sfnt_init_face( FT_Stream stream,
497 FT_Int face_instance_index,
499 FT_Parameter* params )
502 FT_Library library = face->root.driver->root.library;
505 FT_Long woff2_num_faces = 0;
509 FT_UNUSED( num_params );
513 sfnt = (SFNT_Service)face->sfnt;
516 sfnt = (SFNT_Service)FT_Get_Module_Interface( library,
"sfnt" );
519 FT_ERROR((
"sfnt_init_face: cannot access `sfnt' module\n" ));
520 return FT_THROW( Missing_Module );
524 face->goto_table = sfnt->goto_table;
527 FT_FACE_FIND_GLOBAL_SERVICE( face, face->psnames, POSTSCRIPT_CMAPS );
529#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
533 FT_Module tt_module = FT_Get_Module( library,
"truetype" );
536 face->mm = ft_module_get_service( tt_module,
537 FT_SERVICE_ID_MULTI_MASTERS,
545 FT_Module tt_module = FT_Get_Module( library,
"truetype" );
548 face->tt_var = ft_module_get_service( tt_module,
549 FT_SERVICE_ID_METRICS_VARIATIONS,
553 if ( !face->face_var )
554 face->face_var = ft_module_get_service(
555 &face->root.driver->root,
556 FT_SERVICE_ID_METRICS_VARIATIONS,
560 FT_TRACE2((
"SFNT driver\n" ));
562 error = sfnt_open_font( stream,
564 &face_instance_index,
570 stream = face->root.stream;
572 FT_TRACE2((
"sfnt_init_face: %p (index %d)\n",
574 face_instance_index ));
576 face_index = FT_ABS( face_instance_index ) & 0xFFFF;
579 if ( face_instance_index < 0 && face_index > 0 )
585 if ( face_index >= face->ttc_header.count )
587 if ( face_instance_index >= 0 )
588 return FT_THROW( Invalid_Argument );
593 if ( FT_STREAM_SEEK( face->ttc_header.offsets[face_index] ) )
597 error = sfnt->load_font_dir( face, stream );
601#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
603 FT_Memory memory = face->root.memory;
612 FT_UShort num_instances;
613 FT_UShort instance_size;
615 FT_Int instance_index;
617 FT_Byte* default_values = NULL;
618 FT_Byte* instance_values = NULL;
621 instance_index = FT_ABS( face_instance_index ) >> 16;
624 if ( face->goto_table( face, TTAG_fvar, stream, &fvar_len ) ||
626 FT_READ_ULONG( version ) ||
627 FT_READ_USHORT( offset ) ||
628 FT_STREAM_SKIP( 2 ) ||
629 FT_READ_USHORT( num_axes ) ||
630 FT_READ_USHORT( axis_size ) ||
631 FT_READ_USHORT( num_instances ) ||
632 FT_READ_USHORT( instance_size ) )
643 if ( version != 0x00010000UL ||
648 !( instance_size == 4 + 4 * num_axes ||
649 instance_size == 6 + 4 * num_axes ) ||
651 num_instances > 0x7EFF ||
653 axis_size * num_axes +
654 instance_size * num_instances > fvar_len )
657 face->variation_support |= TT_FACE_FLAG_VAR_FVAR;
671 if ( ( face->variation_support & TT_FACE_FLAG_VAR_FVAR ) &&
672 !( FT_QALLOC( default_values, num_axes * 4 ) ||
673 FT_QALLOC( instance_values, num_axes * 4 ) ) )
676 FT_ULong array_start = FT_STREAM_POS() - 16 + offset;
677 FT_ULong default_value_offset, instance_offset;
683 default_value_offset = array_start + 8;
686 for ( i = 0; i < num_axes; i++ )
688 (void)FT_STREAM_READ_AT( default_value_offset, p, 4 );
690 default_value_offset += axis_size;
694 instance_offset = array_start + axis_size * num_axes + 4;
696 for ( i = 0; i < num_instances; i++ )
698 (void)FT_STREAM_READ_AT( instance_offset,
702 if ( !ft_memcmp( default_values, instance_values, num_axes * 4 ) )
705 instance_offset += instance_size;
709 face->var_default_named_instance = i + 1;
711 if ( i == num_instances )
719 FT_FREE( default_values );
720 FT_FREE( instance_values );
724 if ( face->goto_table( face, TTAG_glyf, stream, 0 ) &&
725 face->goto_table( face, TTAG_CFF2, stream, 0 ) &&
726 !face->goto_table( face, TTAG_CFF, stream, 0 ) )
731 if ( instance_index > num_instances )
733 if ( face_instance_index >= 0 )
734 return FT_THROW( Invalid_Argument );
739 face->root.style_flags = (FT_Long)num_instances << 16;
743 face->root.num_faces = face->ttc_header.count;
744 face->root.face_index = face_instance_index;
747 if ( woff2_num_faces )
748 face->root.num_faces = woff2_num_faces;
757 FT_TRACE2(( "`" #x "' " )); \
758 FT_TRACE3(( "-->\n" )); \
760 error = sfnt->load_ ## x( face, stream ); \
762 FT_TRACE2(( "%s\n", ( !error ) \
764 : FT_ERR_EQ( error, Table_Missing ) \
766 : "failed to load" )); \
767 FT_TRACE3(( "\n" )); \
770#define LOADM_( x, vertical ) \
773 FT_TRACE2(( "`%s" #x "' ", \
774 vertical ? "vertical " : "" )); \
775 FT_TRACE3(( "-->\n" )); \
777 error = sfnt->load_ ## x( face, stream, vertical ); \
779 FT_TRACE2(( "%s\n", ( !error ) \
781 : FT_ERR_EQ( error, Table_Missing ) \
783 : "failed to load" )); \
784 FT_TRACE3(( "\n" )); \
787#define GET_NAME( id, field ) \
790 error = tt_face_get_name( face, TT_NAME_ID_ ## id, field ); \
796 FT_LOCAL_DEF( FT_Error )
797 sfnt_load_face( FT_Stream stream,
799 FT_Int face_instance_index,
801 FT_Parameter* params )
804#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
805 FT_Error psnames_error;
809 FT_Bool is_apple_sbit;
817 FT_Bool ignore_typographic_family = FALSE;
818 FT_Bool ignore_typographic_subfamily = FALSE;
819 FT_Bool ignore_sbix = FALSE;
821 SFNT_Service sfnt = (SFNT_Service)face->sfnt;
823 FT_UNUSED( face_instance_index );
832 for ( i = 0; i < num_params; i++ )
834 if ( params[i].tag == FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY )
835 ignore_typographic_family = TRUE;
836 else if ( params[i].tag == FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY )
837 ignore_typographic_subfamily = TRUE;
838 else if ( params[i].tag == FT_PARAM_TAG_IGNORE_SBIX )
860 FT_TRACE2((
"sfnt_load_face: %p\n", (
void *)face ));
864#ifdef FT_CONFIG_OPTION_INCREMENTAL
865 has_outline = FT_BOOL( face->root.internal->incremental_interface ||
866 tt_face_lookup_table( face, TTAG_glyf ) ||
867 tt_face_lookup_table( face, TTAG_CFF ) ||
868 tt_face_lookup_table( face, TTAG_CFF2 ) );
870 has_outline = FT_BOOL( tt_face_lookup_table( face, TTAG_glyf ) ||
871 tt_face_lookup_table( face, TTAG_CFF ) ||
872 tt_face_lookup_table( face, TTAG_CFF2 ) );
876 has_CBLC = !face->goto_table( face, TTAG_CBLC, stream, 0 );
877 has_CBDT = !face->goto_table( face, TTAG_CBDT, stream, 0 );
878 has_EBLC = !face->goto_table( face, TTAG_EBLC, stream, 0 );
879 has_bloc = !face->goto_table( face, TTAG_bloc, stream, 0 );
880 has_sbix = !face->goto_table( face, TTAG_sbix, stream, 0 );
882 is_apple_sbit = FALSE;
889 if ( !has_outline && sfnt->load_bhed )
892 is_apple_sbit = FT_BOOL( !error );
897 if ( !is_apple_sbit || has_sbix )
905 if ( has_CBLC || has_CBDT )
910 if ( face->header.Units_Per_EM < 16 ||
911 face->header.Units_Per_EM > 16384 )
913 error = FT_THROW( Invalid_Table );
928#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
929 psnames_error = error;
934 if ( !is_apple_sbit )
941 if ( FT_ERR_EQ( error, Table_Missing ) )
943 error = FT_THROW( Hmtx_Table_Missing );
945#ifdef FT_CONFIG_OPTION_INCREMENTAL
948 if ( face->root.internal->incremental_interface &&
949 face->root.internal->incremental_interface->funcs->
952 face->horizontal.number_Of_HMetrics = 0;
958 else if ( FT_ERR_EQ( error, Table_Missing ) )
961 if ( face->format_tag == TTAG_true )
963 FT_TRACE2((
"This is an SFNT Mac font.\n" ));
970 error = FT_THROW( Horiz_Header_Missing );
972#ifdef FT_CONFIG_OPTION_INCREMENTAL
975 if ( face->root.internal->incremental_interface &&
976 face->root.internal->incremental_interface->funcs->
979 face->horizontal.number_Of_HMetrics = 0;
996 face->vertical_info = 1;
999 if ( error && FT_ERR_NEQ( error, Table_Missing ) )
1006 face->os2.version = 0xFFFFU;
1016 if ( sfnt->load_eblc &&
1017 ( has_CBLC || has_EBLC || has_bloc || has_sbix ) )
1021 if ( sfnt->load_cpal )
1028 if ( sfnt->load_svg )
1036#ifdef TT_CONFIG_OPTION_GPOS_KERNING
1040 face->root.num_glyphs = face->max_profile.numGlyphs;
1048 face->root.family_name = NULL;
1049 face->root.style_name = NULL;
1050 if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 )
1052 if ( !ignore_typographic_family )
1053 GET_NAME( TYPOGRAPHIC_FAMILY, &face->root.family_name );
1054 if ( !face->root.family_name )
1055 GET_NAME( FONT_FAMILY, &face->root.family_name );
1057 if ( !ignore_typographic_subfamily )
1058 GET_NAME( TYPOGRAPHIC_SUBFAMILY, &face->root.style_name );
1059 if ( !face->root.style_name )
1060 GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
1064 GET_NAME( WWS_FAMILY, &face->root.family_name );
1065 if ( !face->root.family_name && !ignore_typographic_family )
1066 GET_NAME( TYPOGRAPHIC_FAMILY, &face->root.family_name );
1067 if ( !face->root.family_name )
1068 GET_NAME( FONT_FAMILY, &face->root.family_name );
1070 GET_NAME( WWS_SUBFAMILY, &face->root.style_name );
1071 if ( !face->root.style_name && !ignore_typographic_subfamily )
1072 GET_NAME( TYPOGRAPHIC_SUBFAMILY, &face->root.style_name );
1073 if ( !face->root.style_name )
1074 GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
1077#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1079 FT_Memory memory = face->root.memory;
1082 if ( FT_STRDUP( face->non_var_style_name, face->root.style_name ) )
1089 FT_Face root = &face->root;
1090 FT_Long flags = root->face_flags;
1097 if ( face->sbit_table_type == TT_SBIT_TABLE_TYPE_CBLC ||
1098 face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX ||
1101 flags |= FT_FACE_FLAG_COLOR;
1103 if ( has_outline == TRUE )
1108 flags |= FT_FACE_FLAG_SBIX;
1110 flags |= FT_FACE_FLAG_SCALABLE;
1115 flags |= FT_FACE_FLAG_SFNT |
1116 FT_FACE_FLAG_HORIZONTAL;
1118#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
1119 if ( !psnames_error &&
1120 face->postscript.FormatType != 0x00030000L )
1121 flags |= FT_FACE_FLAG_GLYPH_NAMES;
1125 if ( face->postscript.isFixedPitch )
1126 flags |= FT_FACE_FLAG_FIXED_WIDTH;
1129 if ( face->vertical_info )
1130 flags |= FT_FACE_FLAG_VERTICAL;
1133 if ( face->kern_avail_bits
1134#ifdef TT_CONFIG_OPTION_GPOS_KERNING
1135 || face->num_gpos_lookups_kerning
1138 flags |= FT_FACE_FLAG_KERNING;
1140#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1143 if ( face->variation_support & TT_FACE_FLAG_VAR_FVAR )
1144 flags |= FT_FACE_FLAG_MULTIPLE_MASTERS;
1147 root->face_flags = flags;
1155 if ( has_outline == TRUE && face->os2.version != 0xFFFFU )
1161 if ( face->os2.fsSelection & 512 )
1162 flags |= FT_STYLE_FLAG_ITALIC;
1163 else if ( face->os2.fsSelection & 1 )
1164 flags |= FT_STYLE_FLAG_ITALIC;
1166 if ( face->os2.fsSelection & 32 )
1167 flags |= FT_STYLE_FLAG_BOLD;
1173 if ( face->header.Mac_Style & 1 )
1174 flags |= FT_STYLE_FLAG_BOLD;
1176 if ( face->header.Mac_Style & 2 )
1177 flags |= FT_STYLE_FLAG_ITALIC;
1180 root->style_flags |= flags;
1191 tt_face_build_cmaps( face );
1197#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
1198 FT_Bool has_unicode = FALSE;
1202 for ( m = 0; m < root->num_charmaps; m++ )
1204 FT_CharMap charmap = root->charmaps[m];
1207 charmap->encoding = sfnt_find_encoding( charmap->platform_id,
1208 charmap->encoding_id );
1210#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
1212 if ( charmap->encoding == FT_ENCODING_UNICODE ||
1213 charmap->encoding == FT_ENCODING_MS_SYMBOL )
1218 if ( !has_unicode &&
1219 root->face_flags & FT_FACE_FLAG_GLYPH_NAMES )
1221 FT_CharMapRec cmaprec;
1224 cmaprec.face = root;
1225 cmaprec.platform_id = TT_PLATFORM_MICROSOFT;
1226 cmaprec.encoding_id = TT_MS_ID_UNICODE_CS;
1227 cmaprec.encoding = FT_ENCODING_UNICODE;
1230 error = FT_CMap_New( (FT_CMap_Class)&tt_cmap_unicode_class_rec,
1231 NULL, &cmaprec, NULL );
1233 FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) &&
1234 FT_ERR_NEQ( error, Unimplemented_Feature ) )
1243#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
1254 count = face->sbit_num_strikes;
1258 FT_Memory memory = face->root.memory;
1259 FT_UShort em_size = face->header.Units_Per_EM;
1260 FT_Short avgwidth = face->os2.xAvgCharWidth;
1261 FT_Size_Metrics metrics;
1263 FT_UInt* sbit_strike_map = NULL;
1264 FT_UInt strike_idx, bsize_idx;
1267 if ( em_size == 0 || face->os2.version == 0xFFFFU )
1276 if ( FT_NEW_ARRAY( root->available_sizes, count ) ||
1277 FT_QNEW_ARRAY( sbit_strike_map, count ) )
1281 for ( strike_idx = 0; strike_idx < count; strike_idx++ )
1283 FT_Bitmap_Size* bsize = root->available_sizes + bsize_idx;
1286 error = sfnt->load_strike_metrics( face, strike_idx, &metrics );
1290 bsize->height = (FT_Short)( metrics.height >> 6 );
1291 bsize->width = (FT_Short)(
1292 ( avgwidth * metrics.x_ppem + em_size / 2 ) / em_size );
1294 bsize->x_ppem = metrics.x_ppem << 6;
1295 bsize->y_ppem = metrics.y_ppem << 6;
1298 bsize->size = metrics.y_ppem << 6;
1301 if ( bsize->x_ppem && bsize->y_ppem )
1302 sbit_strike_map[bsize_idx++] = strike_idx;
1306 FT_MEM_QRENEW_ARRAY( sbit_strike_map, count, bsize_idx );
1312 face->sbit_strike_map = sbit_strike_map;
1314 root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
1315 root->num_fixed_sizes = (FT_Int)bsize_idx;
1324 if ( !FT_HAS_FIXED_SIZES( root ) && !FT_IS_SCALABLE( root ) )
1325 root->face_flags |= FT_FACE_FLAG_SCALABLE;
1332 if ( FT_IS_SCALABLE( root ) ||
1333 FT_HAS_SBIX( root ) )
1337 root->bbox.xMin = face->header.xMin;
1338 root->bbox.yMin = face->header.yMin;
1339 root->bbox.xMax = face->header.xMax;
1340 root->bbox.yMax = face->header.yMax;
1341 root->units_per_EM = face->header.Units_Per_EM;
1380 if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 128 )
1382 root->ascender = face->os2.sTypoAscender;
1383 root->descender = face->os2.sTypoDescender;
1384 root->height = root->ascender - root->descender +
1385 face->os2.sTypoLineGap;
1389 root->ascender = face->horizontal.Ascender;
1390 root->descender = face->horizontal.Descender;
1391 root->height = root->ascender - root->descender +
1392 face->horizontal.Line_Gap;
1394 if ( !( root->ascender || root->descender ) )
1396 if ( face->os2.version != 0xFFFFU )
1398 if ( face->os2.sTypoAscender || face->os2.sTypoDescender )
1400 root->ascender = face->os2.sTypoAscender;
1401 root->descender = face->os2.sTypoDescender;
1402 root->height = root->ascender - root->descender +
1403 face->os2.sTypoLineGap;
1407 root->ascender = (FT_Short)face->os2.usWinAscent;
1408 root->descender = -(FT_Short)face->os2.usWinDescent;
1409 root->height = root->ascender - root->descender;
1415 root->max_advance_width =
1416 (FT_Short)face->horizontal.advance_Width_Max;
1417 root->max_advance_height =
1418 (FT_Short)( face->vertical_info ? face->vertical.advance_Height_Max
1424 root->underline_position = face->postscript.underlinePosition -
1425 face->postscript.underlineThickness / 2;
1426 root->underline_thickness = face->postscript.underlineThickness;
1432 FT_TRACE2((
"sfnt_load_face: done\n" ));
1443 FT_LOCAL_DEF(
void )
1444 sfnt_done_face( TT_Face face )
1453 memory = face->root.memory;
1454 sfnt = (SFNT_Service)face->sfnt;
1459 if ( sfnt->free_psnames )
1460 sfnt->free_psnames( face );
1463 if ( sfnt->free_eblc )
1464 sfnt->free_eblc( face );
1467 if ( sfnt->free_cpal )
1469 sfnt->free_cpal( face );
1470 sfnt->free_colr( face );
1473#ifdef FT_CONFIG_OPTION_SVG
1475 if ( sfnt->free_svg )
1476 sfnt->free_svg( face );
1480#ifdef TT_CONFIG_OPTION_BDF
1482 tt_face_free_bdf_props( face );
1486 tt_face_done_kern( face );
1488#ifdef TT_CONFIG_OPTION_GPOS_KERNING
1490 tt_face_done_gpos( face );
1494 FT_FREE( face->ttc_header.offsets );
1495 face->ttc_header.count = 0;
1498 FT_FREE( face->dir_tables );
1499 face->num_tables = 0;
1502 FT_Stream stream = FT_FACE_STREAM( face );
1506 FT_FRAME_RELEASE( face->cmap_table );
1507 face->cmap_size = 0;
1510 face->horz_metrics_size = 0;
1511 face->vert_metrics_size = 0;
1514 if ( face->vertical_info )
1516 FT_FREE( face->vertical.long_metrics );
1517 FT_FREE( face->vertical.short_metrics );
1518 face->vertical_info = 0;
1522 FT_FREE( face->gasp.gaspRanges );
1523 face->gasp.numRanges = 0;
1527 sfnt->free_name( face );
1530 FT_FREE( face->root.family_name );
1531 FT_FREE( face->root.style_name );
1534 FT_FREE( face->root.available_sizes );
1535 FT_FREE( face->sbit_strike_map );
1536 face->root.num_fixed_sizes = 0;
1538 FT_FREE( face->postscript_name );
1540#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1541 FT_FREE( face->var_postscript_prefix );
1542 FT_FREE( face->non_var_style_name );
1546 FT_FREE( face->palette_data.palette_name_ids );
1547 FT_FREE( face->palette_data.palette_flags );
1548 FT_FREE( face->palette_data.palette_entry_name_ids );
1549 FT_FREE( face->palette );