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_GX_VAR_SUPPORT
33#include FT_SERVICE_MULTIPLE_MASTERS_H
34#include FT_SERVICE_METRICS_VARIATIONS_H
39#ifdef TT_CONFIG_OPTION_BDF
51#define FT_COMPONENT trace_sfobjs
71 for (
n = 0;
n <
len;
n++ )
78 if ( code < 32 || code > 127 )
106 for (
n = 0;
n <
len;
n++ )
113 if ( code < 32 || code > 127 )
143 FT_Int found_apple_roman = -1;
144 FT_Int found_apple_english = -1;
146 FT_Int found_unicode = -1;
155 rec =
face->name_table.names;
156 for (
n = 0;
n <
face->num_names;
n++, rec++ )
186 found_apple_english =
n;
188 found_apple_roman =
n;
195 if ( found_win == -1 || ( rec->
languageID & 0x3FF ) == 0x009 )
218 found_apple = found_apple_roman;
219 if ( found_apple_english >= 0 )
220 found_apple = found_apple_english;
227 if ( found_win >= 0 && !( found_apple >= 0 && !
is_english ) )
229 rec =
face->name_table.names + found_win;
251 else if ( found_apple >= 0 )
253 rec =
face->name_table.names + found_apple;
256 else if ( found_unicode >= 0 )
258 rec =
face->name_table.names + found_unicode;
293 typedef struct TEncoding_
302 const TEncoding tt_encodings[] =
324 limit =
cur +
sizeof ( tt_encodings ) /
sizeof ( tt_encodings[0] );
328 if (
cur->platform_id == platform_id )
330 if (
cur->encoding_id == encoding_id ||
331 cur->encoding_id == -1 )
332 return cur->encoding;
336 return FT_ENCODING_NONE;
340#define WRITE_USHORT( p, v ) \
343 *(p)++ = (FT_Byte)( (v) >> 8 ); \
344 *(p)++ = (FT_Byte)( (v) >> 0 ); \
348#define WRITE_ULONG( p, v ) \
351 *(p)++ = (FT_Byte)( (v) >> 24 ); \
352 *(p)++ = (FT_Byte)( (v) >> 16 ); \
353 *(p)++ = (FT_Byte)( (v) >> 8 ); \
354 *(p)++ = (FT_Byte)( (v) >> 0 ); \
384 if ( offset1 > offset2 )
386 else if ( offset1 < offset2 )
421#define FT_STRUCTURE WOFF_HeaderRec
462 FT_ERROR((
"woff_font_open: invalid WOFF header\n" ));
475 FT_UInt searchRange, entrySelector, rangeShift,
x;
487 searchRange = ( 1 << entrySelector ) * 16;
488 rangeShift = woff.
num_tables * 16 - searchRange;
506 " tag offset compLen origLen checksum\n"
507 " -------------------------------------------\n" ));
522 FT_TRACE2((
" %c%c%c%c %08lx %08lx %08lx %08lx\n",
532 if (
table->Tag <= old_tag )
536 FT_ERROR((
"woff_font_open: table tags are not sorted\n" ));
541 old_tag =
table->Tag;
564 if (
table->Offset != woff_offset ||
571 FT_ERROR((
"woff_font_open: invalid table offsets\n" ));
576 table->OrigOffset = sfnt_offset;
579 woff_offset += (
table->CompLength + 3 ) & ~3U;
580 sfnt_offset += (
table->OrigLength + 3 ) & ~3U;
598 " invalid `metadata' offset or length\n" ));
610 woff_offset = ( woff_offset + 3 ) & ~3U;
615 FT_ERROR((
"woff_font_open: invalid `private' offset or length\n" ));
625 woff_offset != woff.
length )
627 FT_ERROR((
"woff_font_open: invalid `sfnt' table structure\n" ));
638 sfnt_header =
sfnt + 12;
667#ifdef FT_CONFIG_OPTION_USE_ZLIB
678 if ( output_len !=
table->OrigLength )
680 FT_ERROR((
"woff_font_open: compressed table length mismatch\n" ));
697 sfnt_offset =
table->OrigOffset +
table->OrigLength;
698 while ( sfnt_offset & 3 )
700 sfnt[sfnt_offset] =
'\0';
714 face->root.stream = sfnt_stream;
716 face->root.face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
750#define FT_STRUCTURE TTC_HeaderRec
759 face->ttc_header.tag = 0;
760 face->ttc_header.version = 0;
761 face->ttc_header.count = 0;
771 FT_TRACE2((
"sfnt_open_font: file is a WOFF; synthesizing SFNT\n" ));
785 if (
tag != 0x00010000UL &&
792 tag != 0x00020000UL )
794 FT_TRACE2((
" not a font using the SFNT container format\n" ));
795 return FT_THROW( Unknown_File_Format );
805 FT_TRACE3((
"sfnt_open_font: file is a collection\n" ));
811 face->ttc_header.count ));
813 if (
face->ttc_header.count == 0 )
831 for (
n = 0;
n <
face->ttc_header.count;
n++ )
838 FT_TRACE3((
"sfnt_open_font: synthesize TTC\n" ));
840 face->ttc_header.version = 1 << 16;
841 face->ttc_header.count = 1;
856 FT_Int face_instance_index,
877 FT_ERROR((
"sfnt_init_face: cannot access `sfnt' module\n" ));
887#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
921 FT_TRACE2((
"sfnt_init_face: %08p, %d\n",
face, face_instance_index ));
923 face_index =
FT_ABS( face_instance_index ) & 0xFFFF;
926 if ( face_instance_index < 0 )
929 if ( face_index >=
face->ttc_header.count )
931 if ( face_instance_index >= 0 )
932 return FT_THROW( Invalid_Argument );
945#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
965 instance_index =
FT_ABS( face_instance_index ) >> 16;
987 if (
version != 0x00010000UL ||
992 !( instance_size == 4 + 4 * num_axes ||
993 instance_size == 6 + 4 * num_axes ) ||
995 num_instances > 0x7EFF ||
997 axis_size * num_axes +
998 instance_size * num_instances > fvar_len )
1016 !(
FT_ALLOC( default_values, num_axes * 4 ) ||
1017 FT_ALLOC( instance_values, num_axes * 4 ) ) )
1021 FT_ULong default_value_offset, instance_offset;
1027 default_value_offset = array_start + 8;
1030 for (
i = 0;
i < num_axes;
i++ )
1034 default_value_offset += axis_size;
1038 instance_offset = array_start + axis_size * num_axes + 4;
1040 for (
i = 0;
i < num_instances;
i++ )
1046 if ( !
ft_memcmp( default_values, instance_values, num_axes * 4 ) )
1049 instance_offset += instance_size;
1052 if (
i == num_instances )
1072 if ( instance_index > num_instances )
1074 if ( face_instance_index >= 0 )
1075 return FT_THROW( Invalid_Argument );
1080 face->root.style_flags = (
FT_Long)num_instances << 16;
1084 face->root.num_faces =
face->ttc_header.count;
1085 face->root.face_index = face_instance_index;
1094 FT_TRACE2(( "`" #x "' " )); \
1095 FT_TRACE3(( "-->\n" )); \
1097 error = sfnt->load_ ## x( face, stream ); \
1099 FT_TRACE2(( "%s\n", ( !error ) \
1101 : FT_ERR_EQ( error, Table_Missing ) \
1103 : "failed to load" )); \
1104 FT_TRACE3(( "\n" )); \
1107#define LOADM_( x, vertical ) \
1110 FT_TRACE2(( "`%s" #x "' ", \
1111 vertical ? "vertical " : "" )); \
1112 FT_TRACE3(( "-->\n" )); \
1114 error = sfnt->load_ ## x( face, stream, vertical ); \
1116 FT_TRACE2(( "%s\n", ( !error ) \
1118 : FT_ERR_EQ( error, Table_Missing ) \
1120 : "failed to load" )); \
1121 FT_TRACE3(( "\n" )); \
1124#define GET_NAME( id, field ) \
1127 error = tt_face_get_name( face, TT_NAME_ID_ ## id, field ); \
1136 FT_Int face_instance_index,
1141#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
1161 for (
i = 0;
i < num_params;
i++ )
1164 ignore_typographic_family =
TRUE;
1166 ignore_typographic_subfamily =
TRUE;
1190#ifdef FT_CONFIG_OPTION_INCREMENTAL
1191 has_outline =
FT_BOOL(
face->root.internal->incremental_interface ||
1207 if ( is_apple_sbix )
1208 has_outline =
FALSE;
1220 if ( !is_apple_sbit || is_apple_sbix )
1229 if (
face->header.Units_Per_EM < 16 ||
1230 face->header.Units_Per_EM > 16384 )
1247#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
1248 psnames_error =
error;
1253 if ( !is_apple_sbit )
1264#ifdef FT_CONFIG_OPTION_INCREMENTAL
1267 if (
face->root.internal->incremental_interface &&
1268 face->root.internal->incremental_interface->funcs->
1271 face->horizontal.number_Of_HMetrics = 0;
1282 FT_TRACE2((
"This is an SFNT Mac font.\n" ));
1291#ifdef FT_CONFIG_OPTION_INCREMENTAL
1294 if (
face->root.internal->incremental_interface &&
1295 face->root.internal->incremental_interface->funcs->
1298 face->horizontal.number_Of_HMetrics = 0;
1315 face->vertical_info = 1;
1325 face->os2.version = 0xFFFFU;
1340 face->root.num_glyphs =
face->max_profile.numGlyphs;
1350 if (
face->os2.version != 0xFFFFU &&
face->os2.fsSelection & 256 )
1352 if ( !ignore_typographic_family )
1353 GET_NAME( TYPOGRAPHIC_FAMILY, &
face->root.family_name );
1354 if ( !
face->root.family_name )
1357 if ( !ignore_typographic_subfamily )
1358 GET_NAME( TYPOGRAPHIC_SUBFAMILY, &
face->root.style_name );
1359 if ( !
face->root.style_name )
1365 if ( !
face->root.family_name && !ignore_typographic_family )
1366 GET_NAME( TYPOGRAPHIC_FAMILY, &
face->root.family_name );
1367 if ( !
face->root.family_name )
1371 if ( !
face->root.style_name && !ignore_typographic_subfamily )
1372 GET_NAME( TYPOGRAPHIC_SUBFAMILY, &
face->root.style_name );
1373 if ( !
face->root.style_name )
1391 if ( has_outline ==
TRUE )
1399#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
1400 if ( !psnames_error &&
1401 face->postscript.FormatType != 0x00030000L )
1406 if (
face->postscript.isFixedPitch )
1410 if (
face->vertical_info )
1417#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1438 if ( has_outline ==
TRUE &&
face->os2.version != 0xFFFFU )
1444 if (
face->os2.fsSelection & 512 )
1446 else if (
face->os2.fsSelection & 1 )
1449 if (
face->os2.fsSelection & 32 )
1456 if (
face->header.Mac_Style & 1 )
1459 if (
face->header.Mac_Style & 2 )
1480#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
1485 for (
m = 0;
m <
root->num_charmaps;
m++ )
1493#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
1495 if ( charmap->
encoding == FT_ENCODING_UNICODE ||
1496 charmap->
encoding == FT_ENCODING_MS_SYMBOL )
1509 cmaprec.
encoding = FT_ENCODING_UNICODE;
1524#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
1545 FT_UInt strike_idx, bsize_idx;
1548 if ( em_size == 0 ||
face->os2.version == 0xFFFFU )
1562 for ( strike_idx = 0; strike_idx <
count; strike_idx++ )
1573 ( avgwidth *
metrics.x_ppem + em_size / 2 ) / em_size );
1583 sbit_strike_map[bsize_idx++] = strike_idx;
1593 face->sbit_strike_map = sbit_strike_map;
1617 root->bbox.xMin =
face->header.xMin;
1618 root->bbox.yMin =
face->header.yMin;
1619 root->bbox.xMax =
face->header.xMax;
1620 root->bbox.yMax =
face->header.yMax;
1621 root->units_per_EM =
face->header.Units_Per_EM;
1653 root->ascender =
face->horizontal.Ascender;
1654 root->descender =
face->horizontal.Descender;
1657 face->horizontal.Line_Gap;
1659 if ( !(
root->ascender ||
root->descender ) )
1661 if (
face->os2.version != 0xFFFFU )
1663 if (
face->os2.sTypoAscender ||
face->os2.sTypoDescender )
1665 root->ascender =
face->os2.sTypoAscender;
1666 root->descender =
face->os2.sTypoDescender;
1669 face->os2.sTypoLineGap;
1681 root->max_advance_width =
1683 root->max_advance_height =
1690 root->underline_position =
face->postscript.underlinePosition -
1691 face->postscript.underlineThickness / 2;
1692 root->underline_thickness =
face->postscript.underlineThickness;
1698 FT_TRACE2((
"sfnt_load_face: done\n" ));
1733#ifdef TT_CONFIG_OPTION_BDF
1735 tt_face_free_bdf_props(
face );
1743 face->ttc_header.count = 0;
1747 face->num_tables = 0;
1755 face->cmap_size = 0;
1758 face->horz_metrics_size = 0;
1759 face->vert_metrics_size = 0;
1762 if (
face->vertical_info )
1766 face->vertical_info = 0;
1771 face->gasp.numRanges = 0;
1784 face->root.num_fixed_sizes = 0;
1786#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
struct outqueuenode * head
static const WCHAR version[]
#define TT_MS_ID_UNICODE_CS
#define TT_PLATFORM_MICROSOFT
#define TT_PLATFORM_MACINTOSH
#define TT_MS_ID_SYMBOL_CS
#define TT_PLATFORM_APPLE_UNICODE
struct nls_table * tables
#define FT_FACE_FLAG_KERNING
#define FT_FACE_FLAG_SFNT
#define FT_STYLE_FLAG_ITALIC
#define FT_FACE_FLAG_FIXED_SIZES
#define FT_FACE_FLAG_SCALABLE
#define FT_FACE_FLAG_FIXED_WIDTH
#define FT_HAS_FIXED_SIZES(face)
#define FT_IS_SCALABLE(face)
#define FT_FACE_FLAG_VERTICAL
#define FT_FACE_FLAG_EXTERNAL_STREAM
#define FT_FACE_FLAG_GLYPH_NAMES
enum FT_Encoding_ FT_Encoding
#define FT_FACE_FLAG_COLOR
#define FT_FACE_FLAG_MULTIPLE_MASTERS
#define FT_STYLE_FLAG_BOLD
#define FT_FACE_FLAG_HORIZONTAL
#define FT_CALLBACK_DEF(x)
#define FT_ASSERT(condition)
#define FT_ERROR(varformat)
#define FT_TRACE3(varformat)
#define FT_TRACE2(varformat)
FT_Gzip_Uncompress(FT_Memory memory, FT_Byte *output, FT_ULong *output_len, const FT_Byte *input, FT_ULong input_len)
#define FT_REALLOC(ptr, cursz, newsz)
#define FT_NEW_ARRAY(ptr, count)
#define FT_ALLOC(ptr, size)
#define FT_RENEW_ARRAY(ptr, curcnt, newcnt)
#define FT_QNEW_ARRAY(ptr, count)
FT_Get_Module(FT_Library library, const char *module_name)
ft_module_get_service(FT_Module module, const char *service_id, FT_Bool global)
#define FT_FACE_STREAM(x)
FT_CMap_New(FT_CMap_Class clazz, FT_Pointer init_data, FT_CharMap charmap, FT_CMap *acmap)
FT_Get_Module_Interface(FT_Library library, const char *mod_name)
#define FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY
#define FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY
#define FT_FACE_FIND_GLOBAL_SERVICE(face, ptr, id)
#define FT_FRAME_ENTER(size)
#define FT_READ_USHORT(var)
#define FT_FRAME_RELEASE(bytes)
#define FT_STREAM_SEEK(position)
#define FT_READ_ULONG(var)
#define FT_NEXT_USHORT(buffer)
FT_Stream_Close(FT_Stream stream)
#define FT_FRAME_ULONG(f)
#define FT_STREAM_READ_FIELDS(fields, object)
#define FT_STREAM_SKIP(distance)
#define FT_STREAM_READ_AT(position, buffer, count)
FT_Stream_Free(FT_Stream stream, FT_Int external)
#define FT_STREAM_READ(buffer, count)
#define FT_FRAME_START(size)
FT_Stream_OpenMemory(FT_Stream stream, const FT_Byte *base, FT_ULong size)
#define FT_FRAME_USHORT(f)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
FT_BEGIN_HEADER typedef unsigned char FT_Bool
GLint GLint GLint GLint GLint x
GLuint GLuint GLsizei count
GLuint GLuint GLsizei GLenum const GLvoid * indices
GLenum GLuint GLint GLenum face
GLsizei GLenum const GLvoid GLuint GLsizei GLfloat * metrics
GLboolean GLboolean GLboolean b
GLenum const GLfloat * params
GLuint GLsizei GLsizei * length
GLboolean GLboolean GLboolean GLboolean a
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
static char memory[1024 *256]
SFNT_Interface * SFNT_Service
#define WRITE_ULONG(p, v)
compare_offsets(const void *a, const void *b)
static void sfnt_stream_close(FT_Stream stream)
#define LOADM_(x, vertical)
FT_String *(* TT_Name_ConvertFunc)(TT_Name entry, FT_Memory memory)
#define GET_NAME(id, field)
tt_face_get_name(TT_Face face, FT_UShort nameid, FT_String **name)
static FT_String * tt_name_ascii_from_utf16(TT_Name entry, FT_Memory memory)
sfnt_init_face(FT_Stream stream, TT_Face face, FT_Int face_instance_index, FT_Int num_params, FT_Parameter *params)
sfnt_load_face(FT_Stream stream, TT_Face face, FT_Int face_instance_index, FT_Int num_params, FT_Parameter *params)
static FT_Error woff_open_font(FT_Stream stream, TT_Face face)
sfnt_done_face(TT_Face face)
static FT_Encoding sfnt_find_encoding(int platform_id, int encoding_id)
static FT_Error sfnt_open_font(FT_Stream stream, TT_Face face)
#define WRITE_USHORT(p, v)
static FT_String * tt_name_ascii_from_other(TT_Name entry, FT_Memory memory)
FT_Stream_CloseFunc close
TT_Free_Table_Func free_eblc
TT_Free_Table_Func free_name
TT_Load_Strike_Metrics_Func load_strike_metrics
TT_Load_Table_Func load_eblc
TT_Load_Table_Func load_font_dir
TT_Free_Table_Func free_psnames
TT_Load_Table_Func load_bhed
TT_Loader_GotoTableFunc goto_table
#define FT_SERVICE_ID_METRICS_VARIATIONS
#define FT_SERVICE_ID_MULTI_MASTERS
tt_face_build_cmaps(TT_Face face)
FT_CALLBACK_TABLE const TT_CMap_ClassRec tt_cmap_unicode_class_rec
tt_face_done_kern(TT_Face face)
#define TT_FACE_HAS_KERNING(face)
tt_face_lookup_table(TT_Face face, FT_ULong tag)
#define TT_MAC_LANGID_ENGLISH
@ TT_SBIT_TABLE_TYPE_CBLC
@ TT_SBIT_TABLE_TYPE_SBIX
#define TT_FACE_FLAG_VAR_FVAR
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList