24 #include FT_INTERNAL_SFNT_H
25 #include FT_INTERNAL_DEBUG_H
26 #include FT_TRUETYPE_IDS_H
27 #include FT_TRUETYPE_TAGS_H
28 #include FT_SERVICE_POSTSCRIPT_CMAPS_H
29 #include FT_SFNT_NAMES_H
32 #ifdef TT_CONFIG_OPTION_BDF
44 #define FT_COMPONENT trace_sfobjs
64 for ( n = 0; n <
len; n++ )
70 string[
n] = (char)code;
95 for ( n = 0; n <
len; n++ )
101 string[
n] = (char)code;
145 FT_Int found_apple_roman = -1;
146 FT_Int found_apple_english = -1;
148 FT_Int found_unicode = -1;
158 for ( n = 0; n < face->
num_names; n++, rec++ )
188 found_apple_english =
n;
190 found_apple_roman =
n;
197 if ( found_win == -1 || ( rec->
languageID & 0x3FF ) == 0x009 )
220 found_apple = found_apple_roman;
221 if ( found_apple_english >= 0 )
222 found_apple = found_apple_english;
229 if ( found_win >= 0 && !( found_apple >= 0 && !is_english ) )
253 else if ( found_apple >= 0 )
258 else if ( found_unicode >= 0 )
264 if ( rec && convert )
282 result = convert( rec, memory );
295 typedef struct TEncoding_
304 const TEncoding tt_encodings[] =
322 const TEncoding *cur, *
limit;
326 limit = cur +
sizeof ( tt_encodings ) /
sizeof ( tt_encodings[0] );
328 for ( ; cur <
limit; cur++ )
330 if ( cur->platform_id == platform_id )
332 if ( cur->encoding_id == encoding_id ||
333 cur->encoding_id == -1 )
334 return cur->encoding;
338 return FT_ENCODING_NONE;
355 #define FT_STRUCTURE TTC_HeaderRec
373 if ( tag != 0x00010000UL &&
378 tag != 0x00020000UL )
380 FT_TRACE2((
" not a font using the SFNT container format\n" ));
381 return SFNT_Err_Unknown_File_Format;
391 FT_TRACE3((
"sfnt_open_font: file is a collection\n" ));
397 return SFNT_Err_Invalid_Table;
405 return SFNT_Err_Array_Too_Large;
414 for ( n = 0; n < face->
ttc_header.count; n++ )
421 FT_TRACE3((
"sfnt_open_font: synthesize TTC\n" ));
459 FT_ERROR((
"sfnt_init_face: cannot access `sfnt' module\n" ));
460 return SFNT_Err_Missing_Module;
475 FT_TRACE2((
"sfnt_init_face: %08p, %ld\n", face, face_index ));
477 if ( face_index < 0 )
480 if ( face_index >= face->ttc_header.count )
481 return SFNT_Err_Invalid_Argument;
491 face->root.num_faces = face->ttc_header.count;
492 face->root.face_index = face_index;
500 FT_TRACE2(( "`" #x "' " )); \
501 FT_TRACE3(( "-->\n" )); \
503 error = sfnt->load_##x( face, stream ); \
505 FT_TRACE2(( "%s\n", ( !error ) \
507 : ( error == SFNT_Err_Table_Missing ) \
509 : "failed to load" )); \
510 FT_TRACE3(( "\n" )); \
513 #define LOADM_( x, vertical ) \
515 FT_TRACE2(( "`%s" #x "' ", \
516 vertical ? "vertical " : "" )); \
517 FT_TRACE3(( "-->\n" )); \
519 error = sfnt->load_##x( face, stream, vertical ); \
521 FT_TRACE2(( "%s\n", ( !error ) \
523 : ( error == SFNT_Err_Table_Missing ) \
525 : "failed to load" )); \
526 FT_TRACE3(( "\n" )); \
529 #define GET_NAME( id, field ) \
531 error = tt_face_get_name( face, TT_NAME_ID_##id, field ); \
545 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
563 for ( i = 0; i < num_params; i++ )
566 ignore_preferred_family =
TRUE;
568 ignore_preferred_subfamily =
TRUE;
589 FT_TRACE2((
"sfnt_load_face: %08p\n\n", face ));
592 #ifdef FT_CONFIG_OPTION_INCREMENTAL
593 has_outline =
FT_BOOL( face->root.internal->incremental_interface != 0 ||
608 is_apple_sbit =
FT_BOOL( !error );
613 if ( !is_apple_sbit )
620 if ( face->header.Units_Per_EM == 0 )
622 error = SFNT_Err_Invalid_Table;
637 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
638 psnames_error =
error;
643 if ( !is_apple_sbit )
650 if ( error == SFNT_Err_Table_Missing )
652 error = SFNT_Err_Hmtx_Table_Missing;
654 #ifdef FT_CONFIG_OPTION_INCREMENTAL
657 if ( face->root.internal->incremental_interface &&
658 face->root.internal->incremental_interface->funcs->
661 face->horizontal.number_Of_HMetrics = 0;
667 else if ( error == SFNT_Err_Table_Missing )
672 FT_TRACE2((
"This is an SFNT Mac font.\n" ));
679 error = SFNT_Err_Horiz_Header_Missing;
681 #ifdef FT_CONFIG_OPTION_INCREMENTAL
684 if ( face->root.internal->incremental_interface &&
685 face->root.internal->incremental_interface->funcs->
688 face->horizontal.number_Of_HMetrics = 0;
705 face->vertical_info = 1;
708 if ( error && error != SFNT_Err_Table_Missing )
715 face->os2.version = 0xFFFFU;
730 if ( error == SFNT_Err_Table_Missing )
740 if ( error != SFNT_Err_Table_Missing )
743 face->pclt.Version = 0;
750 face->root.num_glyphs = face->max_profile.numGlyphs;
758 face->root.family_name =
NULL;
759 face->root.style_name =
NULL;
760 if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 )
762 if ( !ignore_preferred_family )
763 GET_NAME( PREFERRED_FAMILY, &face->root.family_name );
764 if ( !face->root.family_name )
765 GET_NAME( FONT_FAMILY, &face->root.family_name );
767 if ( !ignore_preferred_subfamily )
768 GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name );
769 if ( !face->root.style_name )
770 GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
774 GET_NAME( WWS_FAMILY, &face->root.family_name );
775 if ( !face->root.family_name && !ignore_preferred_family )
776 GET_NAME( PREFERRED_FAMILY, &face->root.family_name );
777 if ( !face->root.family_name )
778 GET_NAME( FONT_FAMILY, &face->root.family_name );
780 GET_NAME( WWS_SUBFAMILY, &face->root.style_name );
781 if ( !face->root.style_name && !ignore_preferred_subfamily )
782 GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name );
783 if ( !face->root.style_name )
784 GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
797 if ( has_outline ==
TRUE )
805 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
806 if ( psnames_error == SFNT_Err_Ok &&
807 face->postscript.FormatType != 0x00030000L )
812 if ( face->postscript.isFixedPitch )
816 if ( face->vertical_info )
823 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
840 if ( has_outline ==
TRUE && face->os2.version != 0xFFFFU )
846 if ( face->os2.fsSelection & 512 )
848 else if ( face->os2.fsSelection & 1 )
851 if ( face->os2.fsSelection & 32 )
858 if ( face->header.Mac_Style & 1 )
861 if ( face->header.Mac_Style & 2 )
893 charmap->
encoding == FT_ENCODING_UNICODE )
902 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
913 #ifndef FT_CONFIG_OPTION_OLD_INTERNALS
914 count = face->sbit_num_strikes;
916 count = (
FT_UInt)face->num_sbit_strikes;
921 FT_Memory memory = face->root.stream->memory;
922 FT_UShort em_size = face->header.Units_Per_EM;
923 FT_Short avgwidth = face->os2.xAvgCharWidth;
927 if ( em_size == 0 || face->os2.version == 0xFFFFU )
936 for ( i = 0; i <
count; i++ )
947 ( avgwidth * metrics.
x_ppem + em_size / 2 ) / em_size );
977 root->
bbox.
xMin = face->header.xMin;
978 root->
bbox.
yMin = face->header.yMin;
979 root->
bbox.
xMax = face->header.xMax;
980 root->
bbox.
yMax = face->header.yMax;
1013 root->
ascender = face->horizontal.Ascender;
1014 root->
descender = face->horizontal.Descender;
1017 face->horizontal.Line_Gap );
1021 if ( face->os2.version != 0xFFFFU )
1023 if ( face->os2.sTypoAscender || face->os2.sTypoDescender )
1025 root->
ascender = face->os2.sTypoAscender;
1026 root->
descender = face->os2.sTypoDescender;
1029 face->os2.sTypoLineGap );
1043 ? face->vertical.advance_Height_Max
1050 face->postscript.underlineThickness / 2;
1057 FT_TRACE2((
"sfnt_load_face: done\n" ));
1078 memory = face->root.memory;
1092 #ifdef TT_CONFIG_OPTION_BDF
1101 FT_FREE( face->ttc_header.offsets );
1102 face->ttc_header.count = 0;
1106 face->num_tables = 0;
1114 face->cmap_size = 0;
1118 #ifndef FT_CONFIG_OPTION_OLD_INTERNALS
1125 face->horz_metrics_size = 0;
1126 face->vert_metrics_size = 0;
1129 FT_FREE( face->horizontal.long_metrics );
1130 FT_FREE( face->horizontal.short_metrics );
1134 if ( face->vertical_info )
1136 FT_FREE( face->vertical.long_metrics );
1137 FT_FREE( face->vertical.short_metrics );
1138 face->vertical_info = 0;
1142 FT_FREE( face->gasp.gaspRanges );
1143 face->gasp.numRanges = 0;
1150 FT_FREE( face->root.family_name );
1151 FT_FREE( face->root.style_name );
1154 FT_FREE( face->root.available_sizes );
1155 face->root.num_fixed_sizes = 0;
1157 FT_FREE( face->postscript_name );
#define GET_NAME(id, field)
TT_Load_Strike_Metrics_Func load_strike_metrics
SFNT_Interface * SFNT_Service
FT_BEGIN_HEADER tt_face_free_bdf_props(TT_Face face)
tt_face_done_kern(TT_Face face)
TT_Free_Table_Func free_psnames
tt_face_build_cmaps(TT_Face face)
#define TT_MAC_LANGID_ENGLISH
static FT_String * tt_name_entry_ascii_from_other(TT_NameEntry entry, FT_Memory memory)
FT_Short underline_thickness
#define FT_FACE_FLAG_SCALABLE
#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY
GLuint GLsizei GLsizei GLfloat * metrics
#define FT_FACE_FLAG_MULTIPLE_MASTERS
FT_Bitmap_Size * available_sizes
#define FT_QNEW_ARRAY(ptr, count)
sfnt_init_face(FT_Stream stream, TT_Face face, FT_Int face_index, FT_Int num_params, FT_Parameter *params)
#define FT_FACE_FLAG_FIXED_SIZES
TT_Loader_GotoTableFunc goto_table
#define FT_FACE_FIND_GLOBAL_SERVICE(face, ptr, id)
EGLImageKHR EGLint * name
#define TT_PLATFORM_MICROSOFT
FT_BEGIN_HEADER typedef unsigned char FT_Bool
FT_Short max_advance_height
#define FT_ERROR(varformat)
static FT_Error tt_face_get_name(TT_Face face, FT_UShort nameid, FT_String **name)
static FT_Error sfnt_open_font(FT_Stream stream, TT_Face face)
#define FT_ASSERT(condition)
#define FT_STYLE_FLAG_BOLD
#define FT_FACE_FLAG_VERTICAL
#define FT_STREAM_READ_FIELDS(fields, object)
static FT_Encoding sfnt_find_encoding(int platform_id, int encoding_id)
#define FT_FACE_FLAG_SFNT
#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY
#define FT_FACE_FLAG_FIXED_WIDTH
sfnt_load_face(FT_Stream stream, TT_Face face, FT_Int face_index, FT_Int num_params, FT_Parameter *params)
#define FT_READ_ULONG(var)
#define FT_HAS_FIXED_SIZES(face)
#define FT_FACE_FLAG_HORIZONTAL
#define FT_TRACE2(varformat)
TT_Load_Table_Func load_font_dir
#define TT_MS_ID_SYMBOL_CS
enum FT_Encoding_ FT_Encoding
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
FT_String *(* TT_NameEntry_ConvertFunc)(TT_NameEntry entry, FT_Memory memory)
TT_NameTableRec name_table
#define FT_NEW_ARRAY(ptr, count)
#define FT_STREAM_SEEK(position)
#define FT_NEXT_USHORT(buffer)
#define FT_FRAME_RELEASE(bytes)
#define TT_PLATFORM_MACINTOSH
#define FT_TRACE3(varformat)
TT_Free_Table_Func free_eblc
TT_Load_Table_Func load_bhed
sfnt_done_face(TT_Face face)
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
GLsizei const GLcharARB ** string
#define FT_FACE_FLAG_KERNING
#define LOADM_(x, vertical)
TT_Load_Table_Func load_eblc
tt_face_lookup_table(TT_Face face, FT_ULong tag)
#define TT_PLATFORM_APPLE_UNICODE
#define FT_FRAME_ENTER(size)
FT_Get_Module_Interface(FT_Library library, const char *mod_name)
#define TT_MS_ID_UNICODE_CS
#define TT_FACE_HAS_KERNING(face)
#define FT_STYLE_FLAG_ITALIC
#define FT_FACE_STREAM(x)
#define FT_IS_SCALABLE(face)
#define FT_FACE_FLAG_GLYPH_NAMES
FT_Short max_advance_width
#define FT_STREAM_READ(buffer, count)
static FT_String * tt_name_entry_ascii_from_utf16(TT_NameEntry entry, FT_Memory memory)
TT_Free_Table_Func free_name
#define FT_FRAME_START(size)
FT_Short underline_position