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++ )
74 string[
n] = (char)code;
99 for ( n = 0; n <
len; n++ )
109 string[
n] = (char)code;
153 FT_Int found_apple_roman = -1;
154 FT_Int found_apple_english = -1;
156 FT_Int found_unicode = -1;
166 for ( n = 0; n < face->
num_names; n++, rec++ )
196 found_apple_english =
n;
198 found_apple_roman =
n;
205 if ( found_win == -1 || ( rec->
languageID & 0x3FF ) == 0x009 )
228 found_apple = found_apple_roman;
229 if ( found_apple_english >= 0 )
230 found_apple = found_apple_english;
237 if ( found_win >= 0 && !( found_apple >= 0 && !is_english ) )
245 convert = tt_name_entry_ascii_from_utf16;
254 convert = tt_name_entry_ascii_from_utf16;
261 else if ( found_apple >= 0 )
264 convert = tt_name_entry_ascii_from_other;
266 else if ( found_unicode >= 0 )
269 convert = tt_name_entry_ascii_from_utf16;
272 if ( rec && convert )
290 result = convert( rec, memory );
300 sfnt_find_encoding(
int platform_id,
303 typedef struct TEncoding_
312 const TEncoding tt_encodings[] =
330 const TEncoding *cur, *
limit;
334 limit = cur +
sizeof ( tt_encodings ) /
sizeof ( tt_encodings[0] );
336 for ( ; cur <
limit; cur++ )
338 if ( cur->platform_id == platform_id )
340 if ( cur->encoding_id == encoding_id ||
341 cur->encoding_id == -1 )
342 return cur->encoding;
346 return FT_ENCODING_NONE;
363 #define FT_STRUCTURE TTC_HeaderRec 381 if ( tag != 0x00010000UL &&
386 tag != 0x00020000UL )
388 FT_TRACE2((
" not a font using the SFNT container format\n" ));
389 return FT_THROW( Unknown_File_Format );
399 FT_TRACE3((
"sfnt_open_font: file is a collection\n" ));
422 for ( n = 0; n < face->
ttc_header.count; n++ )
429 FT_TRACE3((
"sfnt_open_font: synthesize TTC\n" ));
467 FT_ERROR((
"sfnt_init_face: cannot access `sfnt' module\n" ));
479 error = sfnt_open_font( stream, face );
483 FT_TRACE2((
"sfnt_init_face: %08p, %ld\n", face, face_index ));
485 if ( face_index < 0 )
489 return FT_THROW( Invalid_Argument );
508 FT_TRACE2(( "`" #x "' " )); \ 509 FT_TRACE3(( "-->\n" )); \ 511 error = sfnt->load_ ## x( face, stream ); \ 513 FT_TRACE2(( "%s\n", ( !error ) \ 515 : FT_ERR_EQ( error, Table_Missing ) \ 517 : "failed to load" )); \ 518 FT_TRACE3(( "\n" )); \ 521 #define LOADM_( x, vertical ) \ 523 FT_TRACE2(( "`%s" #x "' ", \ 524 vertical ? "vertical " : "" )); \ 525 FT_TRACE3(( "-->\n" )); \ 527 error = sfnt->load_ ## x( face, stream, vertical ); \ 529 FT_TRACE2(( "%s\n", ( !error ) \ 531 : FT_ERR_EQ( error, Table_Missing ) \ 533 : "failed to load" )); \ 534 FT_TRACE3(( "\n" )); \ 537 #define GET_NAME( id, field ) \ 539 error = tt_face_get_name( face, TT_NAME_ID_ ## id, field ); \ 553 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES 572 for ( i = 0; i < num_params; i++ )
575 ignore_preferred_family =
TRUE;
577 ignore_preferred_subfamily =
TRUE;
598 FT_TRACE2((
"sfnt_load_face: %08p\n\n", face ));
601 #ifdef FT_CONFIG_OPTION_INCREMENTAL 602 has_outline =
FT_BOOL( face->root.internal->incremental_interface != 0 ||
617 is_apple_sbit =
FT_BOOL( !error );
622 if ( !is_apple_sbit )
629 if ( face->header.Units_Per_EM == 0 )
646 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES 647 psnames_error =
error;
652 if ( !is_apple_sbit )
661 error =
FT_THROW( Hmtx_Table_Missing );
663 #ifdef FT_CONFIG_OPTION_INCREMENTAL 666 if ( face->root.internal->incremental_interface &&
667 face->root.internal->incremental_interface->funcs->
670 face->horizontal.number_Of_HMetrics = 0;
676 else if (
FT_ERR_EQ( error, Table_Missing ) )
681 FT_TRACE2((
"This is an SFNT Mac font.\n" ));
688 error =
FT_THROW( Horiz_Header_Missing );
690 #ifdef FT_CONFIG_OPTION_INCREMENTAL 693 if ( face->root.internal->incremental_interface &&
694 face->root.internal->incremental_interface->funcs->
697 face->horizontal.number_Of_HMetrics = 0;
714 face->vertical_info = 1;
717 if ( error &&
FT_ERR_NEQ( error, Table_Missing ) )
724 face->os2.version = 0xFFFFU;
752 face->pclt.Version = 0;
759 face->root.num_glyphs = face->max_profile.numGlyphs;
767 face->root.family_name =
NULL;
768 face->root.style_name =
NULL;
769 if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 )
771 if ( !ignore_preferred_family )
772 GET_NAME( PREFERRED_FAMILY, &face->root.family_name );
773 if ( !face->root.family_name )
774 GET_NAME( FONT_FAMILY, &face->root.family_name );
776 if ( !ignore_preferred_subfamily )
777 GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name );
778 if ( !face->root.style_name )
779 GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
783 GET_NAME( WWS_FAMILY, &face->root.family_name );
784 if ( !face->root.family_name && !ignore_preferred_family )
785 GET_NAME( PREFERRED_FAMILY, &face->root.family_name );
786 if ( !face->root.family_name )
787 GET_NAME( FONT_FAMILY, &face->root.family_name );
789 GET_NAME( WWS_SUBFAMILY, &face->root.style_name );
790 if ( !face->root.style_name && !ignore_preferred_subfamily )
791 GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name );
792 if ( !face->root.style_name )
793 GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
806 if ( has_outline ==
TRUE )
814 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES 815 if ( !psnames_error &&
816 face->postscript.FormatType != 0x00030000L )
821 if ( face->postscript.isFixedPitch )
825 if ( face->vertical_info )
832 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT 849 if ( has_outline ==
TRUE && face->os2.version != 0xFFFFU )
855 if ( face->os2.fsSelection & 512 )
857 else if ( face->os2.fsSelection & 1 )
860 if ( face->os2.fsSelection & 32 )
867 if ( face->header.Mac_Style & 1 )
870 if ( face->header.Mac_Style & 2 )
902 charmap->
encoding == FT_ENCODING_UNICODE )
911 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS 922 #ifndef FT_CONFIG_OPTION_OLD_INTERNALS 923 count = face->sbit_num_strikes;
925 count = (
FT_UInt)face->num_sbit_strikes;
930 FT_Memory memory = face->root.stream->memory;
931 FT_UShort em_size = face->header.Units_Per_EM;
932 FT_Short avgwidth = face->os2.xAvgCharWidth;
936 if ( em_size == 0 || face->os2.version == 0xFFFFU )
945 for ( i = 0; i <
count; i++ )
956 ( avgwidth * metrics.
x_ppem + em_size / 2 ) / em_size );
986 root->
bbox.
xMin = face->header.xMin;
987 root->
bbox.
yMin = face->header.yMin;
988 root->
bbox.
xMax = face->header.xMax;
989 root->
bbox.
yMax = face->header.yMax;
1022 root->
ascender = face->horizontal.Ascender;
1023 root->
descender = face->horizontal.Descender;
1026 face->horizontal.Line_Gap );
1030 if ( face->os2.version != 0xFFFFU )
1032 if ( face->os2.sTypoAscender || face->os2.sTypoDescender )
1034 root->
ascender = face->os2.sTypoAscender;
1035 root->
descender = face->os2.sTypoDescender;
1038 face->os2.sTypoLineGap );
1052 ? face->vertical.advance_Height_Max
1059 face->postscript.underlineThickness / 2;
1066 FT_TRACE2((
"sfnt_load_face: done\n" ));
1101 #ifdef TT_CONFIG_OPTION_BDF 1127 #ifndef FT_CONFIG_OPTION_OLD_INTERNALS
#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)
int read(int fd, char *buf, int nbytes)
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
FT_Short underline_thickness
#define FT_FACE_FLAG_SCALABLE
return FT_THROW(Missing_Property)
#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY
#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)
FT_ULong horz_metrics_size
#define TT_PLATFORM_MICROSOFT
TT_Loader_GotoTableFunc goto_table
FT_BEGIN_HEADER typedef unsigned char FT_Bool
FT_Short max_advance_height
GLenum GLuint GLint GLenum face
#define FT_ERROR(varformat)
#define FT_ASSERT(condition)
#define FT_STYLE_FLAG_BOLD
#define FT_FACE_FLAG_VERTICAL
#define FT_STREAM_READ_FIELDS(fields, object)
#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)
GLsizei const GLchar *const * string
TT_Load_Table_Func load_font_dir
const char * postscript_name
#define TT_MS_ID_SYMBOL_CS
enum FT_Encoding_ FT_Encoding
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
TT_NameTableRec name_table
#define FT_NEW_ARRAY(ptr, count)
#define FT_STREAM_SEEK(position)
GLuint const GLchar * name
#define FT_NEXT_USHORT(buffer)
#define FT_FRAME_RELEASE(bytes)
if(!abbox) return FT_THROW(Invalid_Argument)
#define TT_PLATFORM_MACINTOSH
#define FT_TRACE3(varformat)
TT_Free_Table_Func free_eblc
GLenum const GLfloat * params
TT_Load_Table_Func load_bhed
sfnt_done_face(TT_Face face)
FT_ULong vert_metrics_size
#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
GLuint GLuint GLsizei count
#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)
GLsizei GLenum const GLvoid GLuint GLsizei GLfloat * metrics
#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)
FT_String *(* TT_NameEntry_ConvertFunc)(TT_NameEntry entry, FT_Memory memory)
TT_Free_Table_Func free_name
#define FT_FRAME_START(size)
FT_Short underline_position