summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/sfnt/sfdriver.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src/sfnt/sfdriver.c')
-rw-r--r--src/3rdparty/freetype/src/sfnt/sfdriver.c259
1 files changed, 145 insertions, 114 deletions
diff --git a/src/3rdparty/freetype/src/sfnt/sfdriver.c b/src/3rdparty/freetype/src/sfnt/sfdriver.c
index 303e1ca9f1..2611685284 100644
--- a/src/3rdparty/freetype/src/sfnt/sfdriver.c
+++ b/src/3rdparty/freetype/src/sfnt/sfdriver.c
@@ -1,19 +1,19 @@
-/***************************************************************************/
-/* */
-/* sfdriver.c */
-/* */
-/* High-level SFNT driver interface (body). */
-/* */
-/* Copyright 1996-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
+/****************************************************************************
+ *
+ * sfdriver.c
+ *
+ * High-level SFNT driver interface (body).
+ *
+ * Copyright (C) 1996-2019 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
#include <ft2build.h>
@@ -25,7 +25,6 @@
#include "sfdriver.h"
#include "ttload.h"
#include "sfobjs.h"
-#include "sfntpic.h"
#include "sferrors.h"
@@ -33,6 +32,11 @@
#include "ttsbit.h"
#endif
+#ifdef TT_CONFIG_OPTION_COLOR_LAYERS
+#include "ttcolr.h"
+#include "ttcpal.h"
+#endif
+
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
#include "ttpost.h"
#endif
@@ -57,18 +61,18 @@
#endif
- /*************************************************************************/
- /* */
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
- /* messages during execution. */
- /* */
+ /**************************************************************************
+ *
+ * The macro FT_COMPONENT is used in trace mode. It is an implicit
+ * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
+ * messages during execution.
+ */
#undef FT_COMPONENT
-#define FT_COMPONENT trace_sfdriver
+#define FT_COMPONENT sfdriver
/*
- * SFNT TABLE SERVICE
+ * SFNT TABLE SERVICE
*
*/
@@ -155,7 +159,7 @@
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
/*
- * GLYPH DICT SERVICE
+ * GLYPH DICT SERVICE
*
*/
@@ -178,8 +182,8 @@
static FT_UInt
- sfnt_get_name_index( FT_Face face,
- FT_String* glyph_name )
+ sfnt_get_name_index( FT_Face face,
+ const FT_String* glyph_name )
{
TT_Face ttface = (TT_Face)face;
@@ -222,7 +226,7 @@
/*
- * POSTSCRIPT NAME SERVICE
+ * POSTSCRIPT NAME SERVICE
*
*/
@@ -371,47 +375,61 @@
{
case 15:
k4 ^= (FT_UInt32)tail[14] << 16;
+ /* fall through */
case 14:
k4 ^= (FT_UInt32)tail[13] << 8;
+ /* fall through */
case 13:
k4 ^= (FT_UInt32)tail[12];
k4 *= c4;
k4 = ROTL32( k4, 18 );
k4 *= c1;
h4 ^= k4;
+ /* fall through */
case 12:
k3 ^= (FT_UInt32)tail[11] << 24;
+ /* fall through */
case 11:
k3 ^= (FT_UInt32)tail[10] << 16;
+ /* fall through */
case 10:
k3 ^= (FT_UInt32)tail[9] << 8;
+ /* fall through */
case 9:
k3 ^= (FT_UInt32)tail[8];
k3 *= c3;
k3 = ROTL32( k3, 17 );
k3 *= c4;
h3 ^= k3;
+ /* fall through */
case 8:
k2 ^= (FT_UInt32)tail[7] << 24;
+ /* fall through */
case 7:
k2 ^= (FT_UInt32)tail[6] << 16;
+ /* fall through */
case 6:
k2 ^= (FT_UInt32)tail[5] << 8;
+ /* fall through */
case 5:
k2 ^= (FT_UInt32)tail[4];
k2 *= c2;
k2 = ROTL32( k2, 16 );
k2 *= c3;
h2 ^= k2;
+ /* fall through */
case 4:
k1 ^= (FT_UInt32)tail[3] << 24;
+ /* fall through */
case 3:
k1 ^= (FT_UInt32)tail[2] << 16;
+ /* fall through */
case 2:
k1 ^= (FT_UInt32)tail[1] << 8;
+ /* fall through */
case 1:
k1 ^= (FT_UInt32)tail[0];
k1 *= c1;
@@ -460,14 +478,12 @@
typedef int (*char_type_func)( int c );
- /* handling of PID/EID 3/0 and 3/1 is the same */
+ /* Handling of PID/EID 3/0 and 3/1 is the same. */
#define IS_WIN( n ) ( (n)->platformID == 3 && \
- ( (n)->encodingID == 1 || (n)->encodingID == 0 ) && \
- (n)->languageID == 0x409 )
+ ( (n)->encodingID == 1 || (n)->encodingID == 0 ) )
#define IS_APPLE( n ) ( (n)->platformID == 1 && \
- (n)->encodingID == 0 && \
- (n)->languageID == 0 )
+ (n)->encodingID == 0 )
static char*
get_win_string( FT_Memory memory,
@@ -491,42 +507,40 @@
if ( FT_STREAM_SEEK( entry->stringOffset ) ||
FT_FRAME_ENTER( entry->stringLength ) )
- {
- FT_FREE( result );
- entry->stringLength = 0;
- entry->stringOffset = 0;
- FT_FREE( entry->string );
-
- return NULL;
- }
+ goto get_win_string_error;
r = (FT_String*)result;
p = (FT_Char*)stream->cursor;
for ( len = entry->stringLength / 2; len > 0; len--, p += 2 )
{
- if ( p[0] == 0 )
+ if ( p[0] == 0 && char_type( p[1] ) )
+ *r++ = p[1];
+ else
{
- if ( char_type( p[1] ) )
- *r++ = p[1];
- else
- {
- if ( report_invalid_characters )
- {
- FT_TRACE0(( "get_win_string:"
- " Character `%c' (0x%X) invalid in PS name string\n",
- p[1], p[1] ));
- /* it's not the job of FreeType to correct PS names... */
- *r++ = p[1];
- }
- }
+ if ( report_invalid_characters )
+ FT_TRACE0(( "get_win_string:"
+ " Character 0x%X invalid in PS name string\n",
+ ((unsigned)p[0])*256 + (unsigned)p[1] ));
+ break;
}
}
- *r = '\0';
+ if ( !len )
+ *r = '\0';
FT_FRAME_EXIT();
- return result;
+ if ( !len )
+ return result;
+
+ get_win_string_error:
+ FT_FREE( result );
+
+ entry->stringLength = 0;
+ entry->stringOffset = 0;
+ FT_FREE( entry->string );
+
+ return NULL;
}
@@ -552,14 +566,7 @@
if ( FT_STREAM_SEEK( entry->stringOffset ) ||
FT_FRAME_ENTER( entry->stringLength ) )
- {
- FT_FREE( result );
- entry->stringOffset = 0;
- entry->stringLength = 0;
- FT_FREE( entry->string );
-
- return NULL;
- }
+ goto get_apple_string_error;
r = (FT_String*)result;
p = (FT_Char*)stream->cursor;
@@ -571,20 +578,28 @@
else
{
if ( report_invalid_characters )
- {
FT_TRACE0(( "get_apple_string:"
" Character `%c' (0x%X) invalid in PS name string\n",
*p, *p ));
- /* it's not the job of FreeType to correct PS names... */
- *r++ = *p;
- }
+ break;
}
}
- *r = '\0';
+ if ( !len )
+ *r = '\0';
FT_FRAME_EXIT();
- return result;
+ if ( !len )
+ return result;
+
+ get_apple_string_error:
+ FT_FREE( result );
+
+ entry->stringOffset = 0;
+ entry->stringLength = 0;
+ FT_FREE( entry->string );
+
+ return NULL;
}
@@ -607,10 +622,10 @@
if ( name->nameID == id && name->stringLength > 0 )
{
- if ( IS_WIN( name ) )
+ if ( IS_WIN( name ) && ( name->languageID == 0x409 || *win == -1 ) )
*win = n;
- if ( IS_APPLE( name ) )
+ if ( IS_APPLE( name ) && ( name->languageID == 0 || *apple == -1 ) )
*apple = n;
}
}
@@ -643,9 +658,9 @@
/*
- * Find the shortest decimal representation of a 16.16 fixed point
- * number. The function fills `buf' with the result, returning a pointer
- * to the position after the representation's last byte.
+ * Find the shortest decimal representation of a 16.16 fixed point
+ * number. The function fills `buf' with the result, returning a pointer
+ * to the position after the representation's last byte.
*/
static char*
@@ -673,7 +688,7 @@
if ( fixed < 0 )
{
*p++ = '-';
- fixed = -fixed;
+ fixed = NEG_INT( fixed );
}
int_part = ( fixed >> 16 ) & 0xFFFF;
@@ -828,13 +843,20 @@
face->name_table.names + win,
sfnt_is_alphanumeric,
0 );
- else
+ if ( !result && apple != -1 )
result = get_apple_string( face->root.memory,
face->name_table.stream,
face->name_table.names + apple,
sfnt_is_alphanumeric,
0 );
+ if ( !result )
+ {
+ FT_TRACE0(( "sfnt_get_var_ps_name:"
+ " No valid PS name prefix for font instances found\n" ));
+ return NULL;
+ }
+
len = ft_strlen( result );
/* sanitize if necessary; we reserve space for 36 bytes (a 128bit */
@@ -1052,7 +1074,7 @@
face->name_table.names + win,
sfnt_is_postscript,
1 );
- else
+ if ( !result && apple != -1 )
result = get_apple_string( face->root.memory,
face->name_table.stream,
face->name_table.names + apple,
@@ -1073,7 +1095,7 @@
/*
- * TT CMAP INFO
+ * TT CMAP INFO
*/
FT_DEFINE_SERVICE_TTCMAPSREC(
tt_service_get_cmap_info,
@@ -1132,41 +1154,41 @@
/*
- * SERVICE LIST
+ * SERVICE LIST
*/
#if defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES && defined TT_CONFIG_OPTION_BDF
FT_DEFINE_SERVICEDESCREC5(
sfnt_services,
- FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET,
- FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET,
- FT_SERVICE_ID_GLYPH_DICT, &SFNT_SERVICE_GLYPH_DICT_GET,
- FT_SERVICE_ID_BDF, &SFNT_SERVICE_BDF_GET,
- FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET )
+ FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table,
+ FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name,
+ FT_SERVICE_ID_GLYPH_DICT, &sfnt_service_glyph_dict,
+ FT_SERVICE_ID_BDF, &sfnt_service_bdf,
+ FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info )
#elif defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES
FT_DEFINE_SERVICEDESCREC4(
sfnt_services,
- FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET,
- FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET,
- FT_SERVICE_ID_GLYPH_DICT, &SFNT_SERVICE_GLYPH_DICT_GET,
- FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET )
+ FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table,
+ FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name,
+ FT_SERVICE_ID_GLYPH_DICT, &sfnt_service_glyph_dict,
+ FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info )
#elif defined TT_CONFIG_OPTION_BDF
FT_DEFINE_SERVICEDESCREC4(
sfnt_services,
- FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET,
- FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET,
- FT_SERVICE_ID_BDF, &SFNT_SERVICE_BDF_GET,
- FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET )
+ FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table,
+ FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name,
+ FT_SERVICE_ID_BDF, &sfnt_service_bdf,
+ FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info )
#else
FT_DEFINE_SERVICEDESCREC3(
sfnt_services,
- FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET,
- FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET,
- FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET )
+ FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table,
+ FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name,
+ FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info )
#endif
@@ -1174,21 +1196,9 @@
sfnt_get_interface( FT_Module module,
const char* module_interface )
{
- /* SFNT_SERVICES_GET dereferences `library' in PIC mode */
-#ifdef FT_CONFIG_OPTION_PIC
- FT_Library library;
-
-
- if ( !module )
- return NULL;
- library = module->library;
- if ( !library )
- return NULL;
-#else
FT_UNUSED( module );
-#endif
- return ft_service_list_lookup( SFNT_SERVICES_GET, module_interface );
+ return ft_service_list_lookup( sfnt_services, module_interface );
}
@@ -1198,6 +1208,12 @@
#define PUT_EMBEDDED_BITMAPS( a ) NULL
#endif
+#ifdef TT_CONFIG_OPTION_COLOR_LAYERS
+#define PUT_COLOR_LAYERS( a ) a
+#else
+#define PUT_COLOR_LAYERS( a ) NULL
+#endif
+
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
#define PUT_PS_NAMES( a ) a
#else
@@ -1256,9 +1272,24 @@
/* TT_Free_Table_Func free_eblc */
PUT_EMBEDDED_BITMAPS( tt_face_set_sbit_strike ),
- /* TT_Set_SBit_Strike_Func set_sbit_strike */
+ /* TT_Set_SBit_Strike_Func set_sbit_strike */
PUT_EMBEDDED_BITMAPS( tt_face_load_strike_metrics ),
- /* TT_Load_Strike_Metrics_Func load_strike_metrics */
+ /* TT_Load_Strike_Metrics_Func load_strike_metrics */
+
+ PUT_COLOR_LAYERS( tt_face_load_cpal ),
+ /* TT_Load_Table_Func load_cpal */
+ PUT_COLOR_LAYERS( tt_face_load_colr ),
+ /* TT_Load_Table_Func load_colr */
+ PUT_COLOR_LAYERS( tt_face_free_cpal ),
+ /* TT_Free_Table_Func free_cpal */
+ PUT_COLOR_LAYERS( tt_face_free_colr ),
+ /* TT_Free_Table_Func free_colr */
+ PUT_COLOR_LAYERS( tt_face_palette_set ),
+ /* TT_Set_Palette_Func set_palette */
+ PUT_COLOR_LAYERS( tt_face_get_colr_layer ),
+ /* TT_Get_Colr_Layer_Func get_colr_layer */
+ PUT_COLOR_LAYERS( tt_face_colr_blend_layer ),
+ /* TT_Blend_Colr_Func colr_blend */
tt_face_get_metrics, /* TT_Get_Metrics_Func get_metrics */
@@ -1277,7 +1308,7 @@
0x10000L, /* driver version 1.0 */
0x20000L, /* driver requires FreeType 2.0 or higher */
- (const void*)&SFNT_INTERFACE_GET, /* module specific interface */
+ (const void*)&sfnt_interface, /* module specific interface */
(FT_Module_Constructor)NULL, /* module_init */
(FT_Module_Destructor) NULL, /* module_done */