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 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 (index %d)\n",
923 face_instance_index ));
925 face_index =
FT_ABS( face_instance_index ) & 0xFFFF;
928 if ( face_instance_index < 0 )
931 if ( face_index >=
face->ttc_header.count )
933 if ( face_instance_index >= 0 )
934 return FT_THROW( Invalid_Argument );
947#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
967 instance_index =
FT_ABS( face_instance_index ) >> 16;
989 if (
version != 0x00010000UL ||
994 !( instance_size == 4 + 4 * num_axes ||
995 instance_size == 6 + 4 * num_axes ) ||
997 num_instances > 0x7EFF ||
999 axis_size * num_axes +
1000 instance_size * num_instances > fvar_len )
1018 !(
FT_ALLOC( default_values, num_axes * 4 ) ||
1019 FT_ALLOC( instance_values, num_axes * 4 ) ) )
1023 FT_ULong default_value_offset, instance_offset;
1029 default_value_offset = array_start + 8;
1032 for (
i = 0;
i < num_axes;
i++ )
1036 default_value_offset += axis_size;
1040 instance_offset = array_start + axis_size * num_axes + 4;
1042 for (
i = 0;
i < num_instances;
i++ )
1048 if ( !
ft_memcmp( default_values, instance_values, num_axes * 4 ) )
1051 instance_offset += instance_size;
1054 if (
i == num_instances )
1074 if ( instance_index > num_instances )
1076 if ( face_instance_index >= 0 )
1077 return FT_THROW( Invalid_Argument );
1082 face->root.style_flags = (
FT_Long)num_instances << 16;
1086 face->root.num_faces =
face->ttc_header.count;
1087 face->root.face_index = face_instance_index;
1096 FT_TRACE2(( "`" #x "' " )); \
1097 FT_TRACE3(( "-->\n" )); \
1099 error = sfnt->load_ ## x( face, stream ); \
1101 FT_TRACE2(( "%s\n", ( !error ) \
1103 : FT_ERR_EQ( error, Table_Missing ) \
1105 : "failed to load" )); \
1106 FT_TRACE3(( "\n" )); \
1109#define LOADM_( x, vertical ) \
1112 FT_TRACE2(( "`%s" #x "' ", \
1113 vertical ? "vertical " : "" )); \
1114 FT_TRACE3(( "-->\n" )); \
1116 error = sfnt->load_ ## x( face, stream, vertical ); \
1118 FT_TRACE2(( "%s\n", ( !error ) \
1120 : FT_ERR_EQ( error, Table_Missing ) \
1122 : "failed to load" )); \
1123 FT_TRACE3(( "\n" )); \
1126#define GET_NAME( id, field ) \
1129 error = tt_face_get_name( face, TT_NAME_ID_ ## id, field ); \
1138 FT_Int face_instance_index,
1143#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
1165 for (
i = 0;
i < num_params;
i++ )
1168 ignore_typographic_family =
TRUE;
1170 ignore_typographic_subfamily =
TRUE;
1194#ifdef FT_CONFIG_OPTION_INCREMENTAL
1195 has_outline =
FT_BOOL(
face->root.internal->incremental_interface ||
1211 if ( is_apple_sbix )
1212 has_outline =
FALSE;
1224 if ( !is_apple_sbit || is_apple_sbix )
1235 if ( has_CBLC || has_CBDT )
1236 has_outline =
FALSE;
1240 if (
face->header.Units_Per_EM < 16 ||
1241 face->header.Units_Per_EM > 16384 )
1258#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
1259 psnames_error =
error;
1264 if ( !is_apple_sbit )
1275#ifdef FT_CONFIG_OPTION_INCREMENTAL
1278 if (
face->root.internal->incremental_interface &&
1279 face->root.internal->incremental_interface->funcs->
1282 face->horizontal.number_Of_HMetrics = 0;
1293 FT_TRACE2((
"This is an SFNT Mac font.\n" ));
1302#ifdef FT_CONFIG_OPTION_INCREMENTAL
1305 if (
face->root.internal->incremental_interface &&
1306 face->root.internal->incremental_interface->funcs->
1309 face->horizontal.number_Of_HMetrics = 0;
1326 face->vertical_info = 1;
1336 face->os2.version = 0xFFFFU;
1358 face->root.num_glyphs =
face->max_profile.numGlyphs;
1368 if (
face->os2.version != 0xFFFFU &&
face->os2.fsSelection & 256 )
1370 if ( !ignore_typographic_family )
1371 GET_NAME( TYPOGRAPHIC_FAMILY, &
face->root.family_name );
1372 if ( !
face->root.family_name )
1375 if ( !ignore_typographic_subfamily )
1376 GET_NAME( TYPOGRAPHIC_SUBFAMILY, &
face->root.style_name );
1377 if ( !
face->root.style_name )
1383 if ( !
face->root.family_name && !ignore_typographic_family )
1384 GET_NAME( TYPOGRAPHIC_FAMILY, &
face->root.family_name );
1385 if ( !
face->root.family_name )
1389 if ( !
face->root.style_name && !ignore_typographic_subfamily )
1390 GET_NAME( TYPOGRAPHIC_SUBFAMILY, &
face->root.style_name );
1391 if ( !
face->root.style_name )
1410 if ( has_outline ==
TRUE )
1418#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
1419 if ( !psnames_error &&
1420 face->postscript.FormatType != 0x00030000L )
1425 if (
face->postscript.isFixedPitch )
1429 if (
face->vertical_info )
1436#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1457 if ( has_outline ==
TRUE &&
face->os2.version != 0xFFFFU )
1463 if (
face->os2.fsSelection & 512 )
1465 else if (
face->os2.fsSelection & 1 )
1468 if (
face->os2.fsSelection & 32 )
1475 if (
face->header.Mac_Style & 1 )
1478 if (
face->header.Mac_Style & 2 )
1499#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
1504 for (
m = 0;
m <
root->num_charmaps;
m++ )
1512#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
1514 if ( charmap->
encoding == FT_ENCODING_UNICODE ||
1515 charmap->
encoding == FT_ENCODING_MS_SYMBOL )
1528 cmaprec.
encoding = FT_ENCODING_UNICODE;
1544#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
1565 FT_UInt strike_idx, bsize_idx;
1568 if ( em_size == 0 ||
face->os2.version == 0xFFFFU )
1582 for ( strike_idx = 0; strike_idx <
count; strike_idx++ )
1593 ( avgwidth *
metrics.x_ppem + em_size / 2 ) / em_size );
1603 sbit_strike_map[bsize_idx++] = strike_idx;
1613 face->sbit_strike_map = sbit_strike_map;
1637 root->bbox.xMin =
face->header.xMin;
1638 root->bbox.yMin =
face->header.yMin;
1639 root->bbox.xMax =
face->header.xMax;
1640 root->bbox.yMax =
face->header.yMax;
1641 root->units_per_EM =
face->header.Units_Per_EM;
1680 if (
face->os2.version != 0xFFFFU &&
face->os2.fsSelection & 128 )
1682 root->ascender =
face->os2.sTypoAscender;
1683 root->descender =
face->os2.sTypoDescender;
1685 face->os2.sTypoLineGap;
1689 root->ascender =
face->horizontal.Ascender;
1690 root->descender =
face->horizontal.Descender;
1692 face->horizontal.Line_Gap;
1694 if ( !(
root->ascender ||
root->descender ) )
1696 if (
face->os2.version != 0xFFFFU )
1698 if (
face->os2.sTypoAscender ||
face->os2.sTypoDescender )
1700 root->ascender =
face->os2.sTypoAscender;
1701 root->descender =
face->os2.sTypoDescender;
1703 face->os2.sTypoLineGap;
1715 root->max_advance_width =
1717 root->max_advance_height =
1724 root->underline_position =
face->postscript.underlinePosition -
1725 face->postscript.underlineThickness / 2;
1726 root->underline_thickness =
face->postscript.underlineThickness;
1732 FT_TRACE2((
"sfnt_load_face: done\n" ));
1774#ifdef TT_CONFIG_OPTION_BDF
1776 tt_face_free_bdf_props(
face );
1784 face->ttc_header.count = 0;
1788 face->num_tables = 0;
1796 face->cmap_size = 0;
1799 face->horz_metrics_size = 0;
1800 face->vert_metrics_size = 0;
1803 if (
face->vertical_info )
1807 face->vertical_info = 0;
1812 face->gasp.numRanges = 0;
1825 face->root.num_fixed_sizes = 0;
1829#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1836 FT_FREE(
face->palette_data.palette_entry_name_ids );
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_Free_Table_Func free_cpal
TT_Load_Table_Func load_font_dir
TT_Free_Table_Func free_psnames
TT_Load_Table_Func load_bhed
TT_Free_Table_Func free_colr
TT_Loader_GotoTableFunc goto_table
TT_Load_Table_Func load_cpal
#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