summaryrefslogtreecommitdiff
path: root/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.c')
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.c204
1 files changed, 128 insertions, 76 deletions
diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.c
index 818009ef58c..ac2e620e5d9 100644
--- a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.c
+++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.c
@@ -4,7 +4,7 @@
/* */
/* SFNT object management (base). */
/* */
-/* Copyright 1996-2016 by */
+/* Copyright 1996-2017 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -54,8 +54,8 @@
/* convert a UTF-16 name entry to ASCII */
static FT_String*
- tt_name_entry_ascii_from_utf16( TT_NameEntry entry,
- FT_Memory memory )
+ tt_name_ascii_from_utf16( TT_Name entry,
+ FT_Memory memory )
{
FT_String* string = NULL;
FT_UInt len, code, n;
@@ -89,8 +89,8 @@
/* convert an Apple Roman or symbol name entry to ASCII */
static FT_String*
- tt_name_entry_ascii_from_other( TT_NameEntry entry,
- FT_Memory memory )
+ tt_name_ascii_from_other( TT_Name entry,
+ FT_Memory memory )
{
FT_String* string = NULL;
FT_UInt len, code, n;
@@ -122,8 +122,8 @@
}
- typedef FT_String* (*TT_NameEntry_ConvertFunc)( TT_NameEntry entry,
- FT_Memory memory );
+ typedef FT_String* (*TT_Name_ConvertFunc)( TT_Name entry,
+ FT_Memory memory );
/* documentation is in sfnt.h */
@@ -133,20 +133,21 @@
FT_UShort nameid,
FT_String** name )
{
- FT_Memory memory = face->root.memory;
- FT_Error error = FT_Err_Ok;
- FT_String* result = NULL;
- FT_UShort n;
- TT_NameEntryRec* rec;
- FT_Int found_apple = -1;
- FT_Int found_apple_roman = -1;
- FT_Int found_apple_english = -1;
- FT_Int found_win = -1;
- FT_Int found_unicode = -1;
+ FT_Memory memory = face->root.memory;
+ FT_Error error = FT_Err_Ok;
+ FT_String* result = NULL;
+ FT_UShort n;
+ TT_Name rec;
- FT_Bool is_english = 0;
+ FT_Int found_apple = -1;
+ FT_Int found_apple_roman = -1;
+ FT_Int found_apple_english = -1;
+ FT_Int found_win = -1;
+ FT_Int found_unicode = -1;
- TT_NameEntry_ConvertFunc convert;
+ FT_Bool is_english = 0;
+
+ TT_Name_ConvertFunc convert;
FT_ASSERT( name );
@@ -231,7 +232,7 @@
/* all Unicode strings are encoded using UTF-16BE */
case TT_MS_ID_UNICODE_CS:
case TT_MS_ID_SYMBOL_CS:
- convert = tt_name_entry_ascii_from_utf16;
+ convert = tt_name_ascii_from_utf16;
break;
case TT_MS_ID_UCS_4:
@@ -240,7 +241,7 @@
/* MsGothic font shipped with Windows Vista shows that this really */
/* means UTF-16 encoded names (UCS-4 values are only used within */
/* charmaps). */
- convert = tt_name_entry_ascii_from_utf16;
+ convert = tt_name_ascii_from_utf16;
break;
default:
@@ -250,12 +251,12 @@
else if ( found_apple >= 0 )
{
rec = face->name_table.names + found_apple;
- convert = tt_name_entry_ascii_from_other;
+ convert = tt_name_ascii_from_other;
}
else if ( found_unicode >= 0 )
{
rec = face->name_table.names + found_unicode;
- convert = tt_name_entry_ascii_from_utf16;
+ convert = tt_name_ascii_from_utf16;
}
if ( rec && convert )
@@ -310,7 +311,7 @@
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_UCS_4, FT_ENCODING_UNICODE },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, FT_ENCODING_UNICODE },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_SJIS, FT_ENCODING_SJIS },
- { TT_PLATFORM_MICROSOFT, TT_MS_ID_GB2312, FT_ENCODING_GB2312 },
+ { TT_PLATFORM_MICROSOFT, TT_MS_ID_PRC, FT_ENCODING_PRC },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_BIG_5, FT_ENCODING_BIG5 },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_WANSUNG, FT_ENCODING_WANSUNG },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_JOHAB, FT_ENCODING_JOHAB }
@@ -893,7 +894,17 @@
0 );
}
- FT_FACE_FIND_GLOBAL_SERVICE( face, face->var, METRICS_VARIATIONS );
+ if ( !face->var )
+ {
+ /* we want the metrics variations interface */
+ /* from the `truetype' module only */
+ FT_Module tt_module = FT_Get_Module( library, "truetype" );
+
+
+ face->var = ft_module_get_service( tt_module,
+ FT_SERVICE_ID_METRICS_VARIATIONS,
+ 0 );
+ }
#endif
FT_TRACE2(( "SFNT driver\n" ));
@@ -909,6 +920,10 @@
face_index = FT_ABS( face_instance_index ) & 0xFFFF;
+ /* value -(N+1) requests information on index N */
+ if ( face_instance_index < 0 )
+ face_index--;
+
if ( face_index >= face->ttc_header.count )
{
if ( face_instance_index >= 0 )
@@ -927,6 +942,8 @@
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
{
+ FT_Memory memory = face->root.memory;
+
FT_ULong fvar_len;
FT_ULong version;
@@ -939,6 +956,9 @@
FT_Int instance_index;
+ FT_Byte* default_values = NULL;
+ FT_Byte* instance_values = NULL;
+
face->is_default_instance = 1;
@@ -949,7 +969,7 @@
fvar_len < 20 ||
FT_READ_ULONG( version ) ||
FT_READ_USHORT( offset ) ||
- FT_STREAM_SKIP( 2 ) /* count_size_pairs */ ||
+ FT_STREAM_SKIP( 2 ) /* reserved */ ||
FT_READ_USHORT( num_axes ) ||
FT_READ_USHORT( axis_size ) ||
FT_READ_USHORT( num_instances ) ||
@@ -965,18 +985,13 @@
/* check that the data is bound by the table length */
if ( version != 0x00010000UL ||
-#if 0
- /* fonts like `JamRegular.ttf' have an incorrect value for */
- /* `count_size_pairs'; since value 2 is hard-coded in `fvar' */
- /* version 1.0, we simply ignore it */
- count_size_pairs != 2 ||
-#endif
axis_size != 20 ||
num_axes == 0 ||
/* `num_axes' limit implied by 16-bit `instance_size' */
num_axes > 0x3FFE ||
!( instance_size == 4 + 4 * num_axes ||
instance_size == 6 + 4 * num_axes ) ||
+ /* `num_instances' limit implied by limited range of name IDs */
num_instances > 0x7EFF ||
offset +
axis_size * num_axes +
@@ -985,19 +1000,73 @@
else
face->variation_support |= TT_FACE_FLAG_VAR_FVAR;
- /* we don't support Multiple Master CFFs yet */
- if ( !face->goto_table( face, TTAG_CFF, stream, 0 ) )
- num_instances = 0;
+ /*
+ * As documented in the OpenType specification, an entry for the
+ * default instance may be omitted in the named instance table. In
+ * particular this means that even if there is no named instance
+ * table in the font we actually do have a named instance, namely the
+ * default instance.
+ *
+ * For consistency, we always want the default instance in our list
+ * of named instances. If it is missing, we try to synthesize it
+ * later on. Here, we have to adjust `num_instances' accordingly.
+ */
- /* we support at most 2^15 - 1 instances */
- if ( num_instances >= ( 1U << 15 ) - 1 )
+ if ( ( face->variation_support & TT_FACE_FLAG_VAR_FVAR ) &&
+ !( FT_ALLOC( default_values, num_axes * 4 ) ||
+ FT_ALLOC( instance_values, num_axes * 4 ) ) )
{
- if ( face_instance_index >= 0 )
- return FT_THROW( Invalid_Argument );
- else
- num_instances = 0;
+ /* the current stream position is 16 bytes after the table start */
+ FT_ULong array_start = FT_STREAM_POS() - 16 + offset;
+ FT_ULong default_value_offset, instance_offset;
+
+ FT_Byte* p;
+ FT_UInt i;
+
+
+ default_value_offset = array_start + 8;
+ p = default_values;
+
+ for ( i = 0; i < num_axes; i++ )
+ {
+ (void)FT_STREAM_READ_AT( default_value_offset, p, 4 );
+
+ default_value_offset += axis_size;
+ p += 4;
+ }
+
+ instance_offset = array_start + axis_size * num_axes + 4;
+
+ for ( i = 0; i < num_instances; i++ )
+ {
+ (void)FT_STREAM_READ_AT( instance_offset,
+ instance_values,
+ num_axes * 4 );
+
+ if ( !ft_memcmp( default_values, instance_values, num_axes * 4 ) )
+ break;
+
+ instance_offset += instance_size;
+ }
+
+ if ( i == num_instances )
+ {
+ /* no default instance in named instance table; */
+ /* we thus have to synthesize it */
+ num_instances++;
+ }
}
+ FT_FREE( default_values );
+ FT_FREE( instance_values );
+
+ /* we don't support Multiple Master CFFs yet; */
+ /* note that `glyf' or `CFF2' have precedence */
+ if ( face->goto_table( face, TTAG_glyf, stream, 0 ) &&
+ face->goto_table( face, TTAG_CFF2, stream, 0 ) &&
+ !face->goto_table( face, TTAG_CFF, stream, 0 ) )
+ num_instances = 0;
+
/* instance indices in `face_instance_index' start with index 1, */
/* thus `>' and not `>=' */
if ( instance_index > num_instances )
@@ -1075,8 +1144,8 @@
FT_Bool has_outline;
FT_Bool is_apple_sbit;
FT_Bool is_apple_sbix;
- FT_Bool ignore_preferred_family = FALSE;
- FT_Bool ignore_preferred_subfamily = FALSE;
+ FT_Bool ignore_typographic_family = FALSE;
+ FT_Bool ignore_typographic_subfamily = FALSE;
SFNT_Service sfnt = (SFNT_Service)face->sfnt;
@@ -1091,10 +1160,10 @@
for ( i = 0; i < num_params; i++ )
{
- if ( params[i].tag == FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY )
- ignore_preferred_family = TRUE;
- else if ( params[i].tag == FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY )
- ignore_preferred_subfamily = TRUE;
+ if ( params[i].tag == FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY )
+ ignore_typographic_family = TRUE;
+ else if ( params[i].tag == FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY )
+ ignore_typographic_subfamily = TRUE;
}
}
@@ -1258,30 +1327,10 @@
/* embedded bitmap support */
if ( sfnt->load_eblc )
- {
LOAD_( eblc );
- if ( error )
- {
- /* a font which contains neither bitmaps nor outlines is */
- /* still valid (although rather useless in most cases); */
- /* however, you can find such stripped fonts in PDFs */
- if ( FT_ERR_EQ( error, Table_Missing ) )
- error = FT_Err_Ok;
- else
- goto Exit;
- }
- }
+ /* consider the pclt, kerning, and gasp tables as optional */
LOAD_( pclt );
- if ( error )
- {
- if ( FT_ERR_NEQ( error, Table_Missing ) )
- goto Exit;
-
- face->pclt.Version = 0;
- }
-
- /* consider the kerning and gasp tables as optional */
LOAD_( gasp );
LOAD_( kern );
@@ -1297,27 +1346,27 @@
face->root.style_name = NULL;
if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 )
{
- if ( !ignore_preferred_family )
- GET_NAME( PREFERRED_FAMILY, &face->root.family_name );
+ if ( !ignore_typographic_family )
+ GET_NAME( TYPOGRAPHIC_FAMILY, &face->root.family_name );
if ( !face->root.family_name )
GET_NAME( FONT_FAMILY, &face->root.family_name );
- if ( !ignore_preferred_subfamily )
- GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name );
+ if ( !ignore_typographic_subfamily )
+ GET_NAME( TYPOGRAPHIC_SUBFAMILY, &face->root.style_name );
if ( !face->root.style_name )
GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
}
else
{
GET_NAME( WWS_FAMILY, &face->root.family_name );
- if ( !face->root.family_name && !ignore_preferred_family )
- GET_NAME( PREFERRED_FAMILY, &face->root.family_name );
+ if ( !face->root.family_name && !ignore_typographic_family )
+ GET_NAME( TYPOGRAPHIC_FAMILY, &face->root.family_name );
if ( !face->root.family_name )
GET_NAME( FONT_FAMILY, &face->root.family_name );
GET_NAME( WWS_SUBFAMILY, &face->root.style_name );
- if ( !face->root.style_name && !ignore_preferred_subfamily )
- GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name );
+ if ( !face->root.style_name && !ignore_typographic_subfamily )
+ GET_NAME( TYPOGRAPHIC_SUBFAMILY, &face->root.style_name );
if ( !face->root.style_name )
GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
}
@@ -1707,7 +1756,10 @@
FT_FREE( face->sbit_strike_map );
face->root.num_fixed_sizes = 0;
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_FREE( face->postscript_name );
+ FT_FREE( face->var_postscript_prefix );
+#endif
face->sfnt = NULL;
}