Werner Lemberg pushed to branch wl/cplusplus-casts at FreeType / FreeType
Commits:
-
d31bafcb
by Werner Lemberg at 2021-11-14T11:02:54+01:00
-
93e6b3e8
by Werner Lemberg at 2021-11-16T20:13:58+00:00
-
e4f7673e
by Werner Lemberg at 2021-11-16T20:13:58+00:00
-
238245cd
by Werner Lemberg at 2021-11-16T22:08:47+01:00
-
9079c5d9
by Werner Lemberg at 2021-11-18T19:28:07+00:00
20 changed files:
- include/freetype/config/public-macros.h
- include/freetype/freetype.h
- include/freetype/ftimage.h
- include/freetype/ftmodapi.h
- include/freetype/fttypes.h
- src/base/ftobjs.c
- src/cache/ftcmanag.c
- src/cache/ftcmru.c
- src/cff/cffdrivr.c
- src/gxvalid/gxvcommn.h
- src/gxvalid/gxvmod.c
- src/psaux/psstack.c
- src/raster/ftraster.c
- src/sdf/ftbsdf.c
- src/sdf/ftsdf.c
- src/smooth/ftgrays.c
- src/truetype/ttgxvar.c
- src/truetype/ttgxvar.h
- src/type1/t1gload.c
- src/type1/t1load.c
Changes:
... | ... | @@ -103,6 +103,7 @@ FT_BEGIN_HEADER |
103 | 103 |
*/
|
104 | 104 |
#define FT_EXPORT( x ) FT_PUBLIC_FUNCTION_ATTRIBUTE extern x
|
105 | 105 |
|
106 |
+ |
|
106 | 107 |
/*
|
107 | 108 |
* `FT_UNUSED` indicates that a given parameter is not used -- this is
|
108 | 109 |
* only used to get rid of unpleasant compiler warnings.
|
... | ... | @@ -115,6 +116,18 @@ FT_BEGIN_HEADER |
115 | 116 |
#endif
|
116 | 117 |
|
117 | 118 |
|
119 |
+ /*
|
|
120 |
+ * Support for casts in both C and C++.
|
|
121 |
+ */
|
|
122 |
+#ifdef __cplusplus
|
|
123 |
+#define FT_STATIC_CAST( type ) static_cast<type>
|
|
124 |
+#define FT_REINTERPRET_CAST( type ) reinterpret_cast<type>
|
|
125 |
+#else
|
|
126 |
+#define FT_STATIC_CAST( type ) (type)
|
|
127 |
+#define FT_REINTERPRET_CAST( type ) (type)
|
|
128 |
+#endif
|
|
129 |
+ |
|
130 |
+ |
|
118 | 131 |
FT_END_HEADER
|
119 | 132 |
|
120 | 133 |
#endif /* FREETYPE_CONFIG_PUBLIC_MACROS_H_ */
|
... | ... | @@ -616,11 +616,12 @@ FT_BEGIN_HEADER |
616 | 616 |
*/
|
617 | 617 |
|
618 | 618 |
#ifndef FT_ENC_TAG
|
619 |
-#define FT_ENC_TAG( value, a, b, c, d ) \
|
|
620 |
- value = ( ( (FT_UInt32)(a) << 24 ) | \
|
|
621 |
- ( (FT_UInt32)(b) << 16 ) | \
|
|
622 |
- ( (FT_UInt32)(c) << 8 ) | \
|
|
623 |
- (FT_UInt32)(d) )
|
|
619 |
+ |
|
620 |
+#define FT_ENC_TAG( value, a, b, c, d ) \
|
|
621 |
+ value = ( ( FT_STATIC_CAST( FT_Byte )(a) << 24 ) | \
|
|
622 |
+ ( FT_STATIC_CAST( FT_Byte )(b) << 16 ) | \
|
|
623 |
+ ( FT_STATIC_CAST( FT_Byte )(c) << 8 ) | \
|
|
624 |
+ FT_STATIC_CAST( FT_Byte )(d) )
|
|
624 | 625 |
|
625 | 626 |
#endif /* FT_ENC_TAG */
|
626 | 627 |
|
... | ... | @@ -3181,7 +3182,7 @@ FT_BEGIN_HEADER |
3181 | 3182 |
* necessary to empty the cache after a mode switch to avoid false hits.
|
3182 | 3183 |
*
|
3183 | 3184 |
*/
|
3184 |
-#define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 )
|
|
3185 |
+#define FT_LOAD_TARGET_( x ) ( FT_STATIC_CAST( FT_Int32 )( (x) & 15 ) << 16 )
|
|
3185 | 3186 |
|
3186 | 3187 |
#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL )
|
3187 | 3188 |
#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT )
|
... | ... | @@ -3200,7 +3201,8 @@ FT_BEGIN_HEADER |
3200 | 3201 |
* @FT_LOAD_TARGET_XXX value.
|
3201 | 3202 |
*
|
3202 | 3203 |
*/
|
3203 |
-#define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) )
|
|
3204 |
+#define FT_LOAD_TARGET_MODE( x ) \
|
|
3205 |
+ FT_STATIC_CAST( FT_Render_Mode )( ( (x) >> 16 ) & 15 )
|
|
3204 | 3206 |
|
3205 | 3207 |
|
3206 | 3208 |
/**************************************************************************
|
... | ... | @@ -28,11 +28,6 @@ |
28 | 28 |
#define FTIMAGE_H_
|
29 | 29 |
|
30 | 30 |
|
31 |
- /* STANDALONE_ is from ftgrays.c */
|
|
32 |
-#ifndef STANDALONE_
|
|
33 |
-#endif
|
|
34 |
- |
|
35 |
- |
|
36 | 31 |
FT_BEGIN_HEADER
|
37 | 32 |
|
38 | 33 |
|
... | ... | @@ -700,11 +695,13 @@ FT_BEGIN_HEADER |
700 | 695 |
* to get a simple enumeration without assigning special numbers.
|
701 | 696 |
*/
|
702 | 697 |
#ifndef FT_IMAGE_TAG
|
703 |
-#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \
|
|
704 |
- value = ( ( (unsigned long)_x1 << 24 ) | \
|
|
705 |
- ( (unsigned long)_x2 << 16 ) | \
|
|
706 |
- ( (unsigned long)_x3 << 8 ) | \
|
|
707 |
- (unsigned long)_x4 )
|
|
698 |
+ |
|
699 |
+#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \
|
|
700 |
+ value = ( ( FT_STATIC_CAST( unsigned char )( _x1 ) << 24 ) | \
|
|
701 |
+ ( FT_STATIC_CAST( unsigned char )( _x2 ) << 16 ) | \
|
|
702 |
+ ( FT_STATIC_CAST( unsigned char )( _x3 ) << 8 ) | \
|
|
703 |
+ FT_STATIC_CAST( unsigned char )( _x4 ) )
|
|
704 |
+ |
|
708 | 705 |
#endif /* FT_IMAGE_TAG */
|
709 | 706 |
|
710 | 707 |
|
... | ... | @@ -347,8 +347,9 @@ FT_BEGIN_HEADER |
347 | 347 |
* 2.11
|
348 | 348 |
*
|
349 | 349 |
*/
|
350 |
-#define FT_FACE_DRIVER_NAME( face ) \
|
|
351 |
- ( ( *(FT_Module_Class**)( ( face )->driver ) )->module_name )
|
|
350 |
+#define FT_FACE_DRIVER_NAME( face ) \
|
|
351 |
+ ( ( *FT_REINTERPRET_CAST( FT_Module_Class** ) \
|
|
352 |
+ ( ( face )->driver ) )->module_name )
|
|
352 | 353 |
|
353 | 354 |
|
354 | 355 |
/**************************************************************************
|
... | ... | @@ -485,12 +485,12 @@ FT_BEGIN_HEADER |
485 | 485 |
* The produced values **must** be 32-bit integers. Don't redefine this
|
486 | 486 |
* macro.
|
487 | 487 |
*/
|
488 |
-#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
|
|
489 |
- (FT_Tag) \
|
|
490 |
- ( ( (FT_ULong)_x1 << 24 ) | \
|
|
491 |
- ( (FT_ULong)_x2 << 16 ) | \
|
|
492 |
- ( (FT_ULong)_x3 << 8 ) | \
|
|
493 |
- (FT_ULong)_x4 )
|
|
488 |
+#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
|
|
489 |
+ FT_STATIC_CAST( FT_Tag ) \
|
|
490 |
+ ( ( FT_STATIC_CAST( FT_Byte )( _x1 ) << 24 ) | \
|
|
491 |
+ ( FT_STATIC_CAST( FT_Byte )( _x2 ) << 16 ) | \
|
|
492 |
+ ( FT_STATIC_CAST( FT_Byte )( _x3 ) << 8 ) | \
|
|
493 |
+ FT_STATIC_CAST( FT_Byte )( _x4 ) )
|
|
494 | 494 |
|
495 | 495 |
|
496 | 496 |
/*************************************************************************/
|
... | ... | @@ -588,7 +588,7 @@ FT_BEGIN_HEADER |
588 | 588 |
|
589 | 589 |
|
590 | 590 |
#define FT_IS_EMPTY( list ) ( (list).head == 0 )
|
591 |
-#define FT_BOOL( x ) ( (FT_Bool)( (x) != 0 ) )
|
|
591 |
+#define FT_BOOL( x ) FT_STATIC_CAST( FT_Bool )( (x) != 0 )
|
|
592 | 592 |
|
593 | 593 |
/* concatenate C tokens */
|
594 | 594 |
#define FT_ERR_XCAT( x, y ) x ## y
|
... | ... | @@ -3744,7 +3744,7 @@ |
3744 | 3744 |
FT_Error error;
|
3745 | 3745 |
FT_Face face;
|
3746 | 3746 |
FT_Memory memory;
|
3747 |
- FT_CMap cmap;
|
|
3747 |
+ FT_CMap cmap = NULL;
|
|
3748 | 3748 |
|
3749 | 3749 |
|
3750 | 3750 |
if ( !clazz || !charmap || !charmap->face )
|
... | ... | @@ -4459,7 +4459,7 @@ |
4459 | 4459 |
FT_Library library = module->library;
|
4460 | 4460 |
FT_Memory memory = library->memory;
|
4461 | 4461 |
FT_Error error;
|
4462 |
- FT_ListNode node;
|
|
4462 |
+ FT_ListNode node = NULL;
|
|
4463 | 4463 |
|
4464 | 4464 |
|
4465 | 4465 |
if ( FT_QNEW( node ) )
|
... | ... | @@ -357,7 +357,7 @@ |
357 | 357 |
{
|
358 | 358 |
FT_Error error;
|
359 | 359 |
FT_Memory memory;
|
360 |
- FTC_Manager manager;
|
|
360 |
+ FTC_Manager manager = NULL;
|
|
361 | 361 |
|
362 | 362 |
|
363 | 363 |
if ( !library )
|
... | ... | @@ -237,7 +237,7 @@ |
237 | 237 |
FTC_MruNode *anode )
|
238 | 238 |
{
|
239 | 239 |
FT_Error error;
|
240 |
- FTC_MruNode node;
|
|
240 |
+ FTC_MruNode node = NULL;
|
|
241 | 241 |
FT_Memory memory = list->memory;
|
242 | 242 |
|
243 | 243 |
|
... | ... | @@ -473,9 +473,9 @@ |
473 | 473 |
|
474 | 474 |
if ( cff && !cff->font_info )
|
475 | 475 |
{
|
476 |
- CFF_FontRecDict dict = &cff->top_font.font_dict;
|
|
477 |
- FT_Memory memory = face->root.memory;
|
|
478 |
- PS_FontInfoRec* font_info;
|
|
476 |
+ CFF_FontRecDict dict = &cff->top_font.font_dict;
|
|
477 |
+ FT_Memory memory = face->root.memory;
|
|
478 |
+ PS_FontInfoRec* font_info = NULL;
|
|
479 | 479 |
|
480 | 480 |
|
481 | 481 |
if ( FT_QNEW( font_info ) )
|
... | ... | @@ -517,9 +517,9 @@ |
517 | 517 |
|
518 | 518 |
if ( cff && !cff->font_extra )
|
519 | 519 |
{
|
520 |
- CFF_FontRecDict dict = &cff->top_font.font_dict;
|
|
521 |
- FT_Memory memory = face->root.memory;
|
|
522 |
- PS_FontExtraRec* font_extra;
|
|
520 |
+ CFF_FontRecDict dict = &cff->top_font.font_dict;
|
|
521 |
+ FT_Memory memory = face->root.memory;
|
|
522 |
+ PS_FontExtraRec* font_extra = NULL;
|
|
523 | 523 |
FT_String* embedded_postscript;
|
524 | 524 |
|
525 | 525 |
|
... | ... | @@ -61,8 +61,11 @@ FT_BEGIN_HEADER |
61 | 61 |
|
62 | 62 |
#undef GXV_LOAD_UNUSED_VARS /* debug purpose */
|
63 | 63 |
|
64 |
-#define IS_PARANOID_VALIDATION ( gxvalid->root->level >= FT_VALIDATE_PARANOID )
|
|
65 |
-#define GXV_SET_ERR_IF_PARANOID( err ) { if ( IS_PARANOID_VALIDATION ) ( err ); }
|
|
64 |
+#define IS_PARANOID_VALIDATION \
|
|
65 |
+ ( gxvalid->root->level >= FT_VALIDATE_PARANOID )
|
|
66 |
+#define GXV_SET_ERR_IF_PARANOID( err ) \
|
|
67 |
+ do { if ( IS_PARANOID_VALIDATION ) ( err ); } while ( 0 )
|
|
68 |
+ |
|
66 | 69 |
|
67 | 70 |
/*************************************************************************/
|
68 | 71 |
/*************************************************************************/
|
... | ... | @@ -76,27 +76,33 @@ |
76 | 76 |
FT_Byte* volatile _sfnt = NULL; \
|
77 | 77 |
FT_ULong len_ ## _sfnt = 0
|
78 | 78 |
|
79 |
-#define GXV_TABLE_LOAD( _sfnt ) \
|
|
80 |
- if ( ( FT_VALIDATE_ ## _sfnt ## _INDEX < table_count ) && \
|
|
81 |
- ( gx_flags & FT_VALIDATE_ ## _sfnt ) ) \
|
|
82 |
- { \
|
|
83 |
- error = gxv_load_table( face, TTAG_ ## _sfnt, \
|
|
84 |
- &_sfnt, &len_ ## _sfnt ); \
|
|
85 |
- if ( error ) \
|
|
86 |
- goto Exit; \
|
|
87 |
- }
|
|
88 |
- |
|
89 |
-#define GXV_TABLE_VALIDATE( _sfnt ) \
|
|
90 |
- if ( _sfnt ) \
|
|
91 |
- { \
|
|
92 |
- ft_validator_init( &valid, _sfnt, _sfnt + len_ ## _sfnt, \
|
|
93 |
- FT_VALIDATE_DEFAULT ); \
|
|
94 |
- if ( ft_setjmp( valid.jump_buffer ) == 0 ) \
|
|
95 |
- gxv_ ## _sfnt ## _validate( _sfnt, face, &valid ); \
|
|
96 |
- error = valid.error; \
|
|
97 |
- if ( error ) \
|
|
98 |
- goto Exit; \
|
|
99 |
- }
|
|
79 |
+#define GXV_TABLE_LOAD( _sfnt ) \
|
|
80 |
+ do \
|
|
81 |
+ { \
|
|
82 |
+ if ( ( FT_VALIDATE_ ## _sfnt ## _INDEX < table_count ) && \
|
|
83 |
+ ( gx_flags & FT_VALIDATE_ ## _sfnt ) ) \
|
|
84 |
+ { \
|
|
85 |
+ error = gxv_load_table( face, TTAG_ ## _sfnt, \
|
|
86 |
+ &_sfnt, &len_ ## _sfnt ); \
|
|
87 |
+ if ( error ) \
|
|
88 |
+ goto Exit; \
|
|
89 |
+ } \
|
|
90 |
+ } while ( 0 )
|
|
91 |
+ |
|
92 |
+#define GXV_TABLE_VALIDATE( _sfnt ) \
|
|
93 |
+ do \
|
|
94 |
+ { \
|
|
95 |
+ if ( _sfnt ) \
|
|
96 |
+ { \
|
|
97 |
+ ft_validator_init( &valid, _sfnt, _sfnt + len_ ## _sfnt, \
|
|
98 |
+ FT_VALIDATE_DEFAULT ); \
|
|
99 |
+ if ( ft_setjmp( valid.jump_buffer ) == 0 ) \
|
|
100 |
+ gxv_ ## _sfnt ## _validate( _sfnt, face, &valid ); \
|
|
101 |
+ error = valid.error; \
|
|
102 |
+ if ( error ) \
|
|
103 |
+ goto Exit; \
|
|
104 |
+ } \
|
|
105 |
+ } while ( 0 )
|
|
100 | 106 |
|
101 | 107 |
#define GXV_TABLE_SET( _sfnt ) \
|
102 | 108 |
if ( FT_VALIDATE_ ## _sfnt ## _INDEX < table_count ) \
|
... | ... | @@ -54,8 +54,8 @@ |
54 | 54 |
FT_Error* e,
|
55 | 55 |
FT_UInt stackSize )
|
56 | 56 |
{
|
57 |
- FT_Error error; /* for FT_QNEW */
|
|
58 |
- CF2_Stack stack;
|
|
57 |
+ FT_Error error; /* for FT_QNEW */
|
|
58 |
+ CF2_Stack stack = NULL;
|
|
59 | 59 |
|
60 | 60 |
|
61 | 61 |
if ( FT_QNEW( stack ) )
|
... | ... | @@ -3171,7 +3171,7 @@ |
3171 | 3171 |
black_PRaster *araster )
|
3172 | 3172 |
{
|
3173 | 3173 |
FT_Error error;
|
3174 |
- black_PRaster raster;
|
|
3174 |
+ black_PRaster raster = NULL;
|
|
3175 | 3175 |
|
3176 | 3176 |
|
3177 | 3177 |
if ( !FT_NEW( raster ) )
|
... | ... | @@ -1177,7 +1177,7 @@ |
1177 | 1177 |
BSDF_PRaster* araster )
|
1178 | 1178 |
{
|
1179 | 1179 |
FT_Error error;
|
1180 |
- BSDF_PRaster raster;
|
|
1180 |
+ BSDF_PRaster raster = NULL;
|
|
1181 | 1181 |
|
1182 | 1182 |
|
1183 | 1183 |
if ( !FT_NEW( raster ) )
|
... | ... | @@ -3710,7 +3710,7 @@ |
3710 | 3710 |
SDF_PRaster* araster )
|
3711 | 3711 |
{
|
3712 | 3712 |
FT_Error error;
|
3713 |
- SDF_PRaster raster;
|
|
3713 |
+ SDF_PRaster raster = NULL;
|
|
3714 | 3714 |
|
3715 | 3715 |
|
3716 | 3716 |
if ( !FT_NEW( raster ) )
|
... | ... | @@ -152,6 +152,8 @@ |
152 | 152 |
#define ADD_INT( a, b ) \
|
153 | 153 |
(int)( (unsigned int)(a) + (unsigned int)(b) )
|
154 | 154 |
|
155 |
+#define FT_STATIC_CAST( type ) (type)
|
|
156 |
+ |
|
155 | 157 |
|
156 | 158 |
#define ft_memset memset
|
157 | 159 |
|
... | ... | @@ -273,6 +275,8 @@ typedef ptrdiff_t FT_PtrDist; |
273 | 275 |
#else /* !STANDALONE_ */
|
274 | 276 |
|
275 | 277 |
|
278 |
+#include <ft2build.h>
|
|
279 |
+#include FT_CONFIG_CONFIG_H
|
|
276 | 280 |
#include "ftgrays.h"
|
277 | 281 |
#include <freetype/internal/ftobjs.h>
|
278 | 282 |
#include <freetype/internal/ftdebug.h>
|
... | ... | @@ -1986,8 +1990,8 @@ typedef ptrdiff_t FT_PtrDist; |
1986 | 1990 |
ras.ycells[w] = ras.cell_null;
|
1987 | 1991 |
|
1988 | 1992 |
/* memory management: skip ycells */
|
1989 |
- n = ( width * sizeof ( PCell ) + sizeof ( TCell ) - 1 ) /
|
|
1990 |
- sizeof ( TCell );
|
|
1993 |
+ n = ( (size_t)width * sizeof ( PCell ) + sizeof ( TCell ) - 1 ) /
|
|
1994 |
+ sizeof ( TCell );
|
|
1991 | 1995 |
|
1992 | 1996 |
ras.cell_free = buffer + n;
|
1993 | 1997 |
ras.cell = ras.cell_null;
|
... | ... | @@ -2151,7 +2155,7 @@ typedef ptrdiff_t FT_PtrDist; |
2151 | 2155 |
gray_PRaster* araster )
|
2152 | 2156 |
{
|
2153 | 2157 |
FT_Error error;
|
2154 |
- gray_PRaster raster;
|
|
2158 |
+ gray_PRaster raster = NULL;
|
|
2155 | 2159 |
|
2156 | 2160 |
|
2157 | 2161 |
if ( !FT_NEW( raster ) )
|
... | ... | @@ -457,7 +457,8 @@ |
457 | 457 |
FT_UShort format;
|
458 | 458 |
FT_ULong region_offset;
|
459 | 459 |
FT_UInt i, j, k;
|
460 |
- FT_UInt shortDeltaCount;
|
|
460 |
+ FT_UInt wordDeltaCount;
|
|
461 |
+ FT_Bool long_words;
|
|
461 | 462 |
|
462 | 463 |
GX_Blend blend = face->blend;
|
463 | 464 |
GX_ItemVarData varData;
|
... | ... | @@ -572,15 +573,18 @@ |
572 | 573 |
goto Exit;
|
573 | 574 |
|
574 | 575 |
if ( FT_READ_USHORT( varData->itemCount ) ||
|
575 |
- FT_READ_USHORT( shortDeltaCount ) ||
|
|
576 |
+ FT_READ_USHORT( wordDeltaCount ) ||
|
|
576 | 577 |
FT_READ_USHORT( varData->regionIdxCount ) )
|
577 | 578 |
goto Exit;
|
578 | 579 |
|
580 |
+ long_words = !!( wordDeltaCount & 0x8000 );
|
|
581 |
+ wordDeltaCount &= 0x7FFF;
|
|
582 |
+ |
|
579 | 583 |
/* check some data consistency */
|
580 |
- if ( shortDeltaCount > varData->regionIdxCount )
|
|
584 |
+ if ( wordDeltaCount > varData->regionIdxCount )
|
|
581 | 585 |
{
|
582 | 586 |
FT_TRACE2(( "bad short count %d or region count %d\n",
|
583 |
- shortDeltaCount,
|
|
587 |
+ wordDeltaCount,
|
|
584 | 588 |
varData->regionIdxCount ));
|
585 | 589 |
error = FT_THROW( Invalid_Table );
|
586 | 590 |
goto Exit;
|
... | ... | @@ -616,39 +620,52 @@ |
616 | 620 |
|
617 | 621 |
/* Parse delta set. */
|
618 | 622 |
/* */
|
619 |
- /* On input, deltas are (shortDeltaCount + regionIdxCount) bytes */
|
|
620 |
- /* each; on output, deltas are expanded to `regionIdxCount' shorts */
|
|
621 |
- /* each. */
|
|
623 |
+ /* On input, deltas are (wordDeltaCount + regionIdxCount) bytes */
|
|
624 |
+ /* each if `long_words` isn't set, and twice as much otherwise. */
|
|
625 |
+ /* */
|
|
626 |
+ /* On output, deltas are expanded to `regionIdxCount` shorts each. */
|
|
622 | 627 |
if ( FT_NEW_ARRAY( varData->deltaSet,
|
623 | 628 |
varData->regionIdxCount * varData->itemCount ) )
|
624 | 629 |
goto Exit;
|
625 | 630 |
|
626 |
- /* the delta set is stored as a 2-dimensional array of shorts; */
|
|
627 |
- /* sign-extend signed bytes to signed shorts */
|
|
628 |
- for ( j = 0; j < varData->itemCount * varData->regionIdxCount; )
|
|
631 |
+ /* the delta set is stored as a 2-dimensional array of shorts */
|
|
632 |
+ if ( long_words )
|
|
633 |
+ {
|
|
634 |
+ /* new in OpenType 1.9, currently for 'COLR' table only; */
|
|
635 |
+ /* the deltas are interpreted as 16.16 fixed-point scaling values */
|
|
636 |
+ |
|
637 |
+ /* not supported yet */
|
|
638 |
+ |
|
639 |
+ error = FT_THROW( Invalid_Table );
|
|
640 |
+ goto Exit;
|
|
641 |
+ }
|
|
642 |
+ else
|
|
629 | 643 |
{
|
630 |
- for ( k = 0; k < shortDeltaCount; k++, j++ )
|
|
644 |
+ for ( j = 0; j < varData->itemCount * varData->regionIdxCount; )
|
|
631 | 645 |
{
|
632 |
- /* read the short deltas */
|
|
633 |
- FT_Short delta;
|
|
646 |
+ for ( k = 0; k < wordDeltaCount; k++, j++ )
|
|
647 |
+ {
|
|
648 |
+ /* read the short deltas */
|
|
649 |
+ FT_Short delta;
|
|
634 | 650 |
|
635 | 651 |
|
636 |
- if ( FT_READ_SHORT( delta ) )
|
|
637 |
- goto Exit;
|
|
652 |
+ if ( FT_READ_SHORT( delta ) )
|
|
653 |
+ goto Exit;
|
|
638 | 654 |
|
639 |
- varData->deltaSet[j] = delta;
|
|
640 |
- }
|
|
655 |
+ varData->deltaSet[j] = delta;
|
|
656 |
+ }
|
|
641 | 657 |
|
642 |
- for ( ; k < varData->regionIdxCount; k++, j++ )
|
|
643 |
- {
|
|
644 |
- /* read the (signed) byte deltas */
|
|
645 |
- FT_Char delta;
|
|
658 |
+ for ( ; k < varData->regionIdxCount; k++, j++ )
|
|
659 |
+ {
|
|
660 |
+ /* read the (signed) byte deltas */
|
|
661 |
+ FT_Char delta;
|
|
646 | 662 |
|
647 | 663 |
|
648 |
- if ( FT_READ_CHAR( delta ) )
|
|
649 |
- goto Exit;
|
|
664 |
+ if ( FT_READ_CHAR( delta ) )
|
|
665 |
+ goto Exit;
|
|
650 | 666 |
|
651 |
- varData->deltaSet[j] = delta;
|
|
667 |
+ varData->deltaSet[j] = delta;
|
|
668 |
+ }
|
|
652 | 669 |
}
|
653 | 670 |
}
|
654 | 671 |
}
|
... | ... | @@ -664,37 +681,66 @@ |
664 | 681 |
ft_var_load_delta_set_index_mapping( TT_Face face,
|
665 | 682 |
FT_ULong offset,
|
666 | 683 |
GX_DeltaSetIdxMap map,
|
667 |
- GX_ItemVarStore itemStore )
|
|
684 |
+ GX_ItemVarStore itemStore,
|
|
685 |
+ FT_ULong table_len )
|
|
668 | 686 |
{
|
669 | 687 |
FT_Stream stream = FT_FACE_STREAM( face );
|
670 | 688 |
FT_Memory memory = stream->memory;
|
671 | 689 |
|
672 |
- FT_Error error;
|
|
690 |
+ FT_Error error;
|
|
673 | 691 |
|
674 |
- FT_UShort format;
|
|
675 |
- FT_UInt entrySize;
|
|
676 |
- FT_UInt innerBitCount;
|
|
677 |
- FT_UInt innerIndexMask;
|
|
678 |
- FT_UInt i, j;
|
|
692 |
+ FT_Byte format;
|
|
693 |
+ FT_Byte entryFormat;
|
|
694 |
+ FT_UInt entrySize;
|
|
695 |
+ FT_UInt innerBitCount;
|
|
696 |
+ FT_UInt innerIndexMask;
|
|
697 |
+ FT_ULong i;
|
|
698 |
+ FT_UInt j;
|
|
679 | 699 |
|
680 | 700 |
|
681 |
- if ( FT_STREAM_SEEK( offset ) ||
|
|
682 |
- FT_READ_USHORT( format ) ||
|
|
683 |
- FT_READ_USHORT( map->mapCount ) )
|
|
701 |
+ if ( FT_STREAM_SEEK( offset ) ||
|
|
702 |
+ FT_READ_BYTE( format ) ||
|
|
703 |
+ FT_READ_BYTE( entryFormat ) )
|
|
684 | 704 |
goto Exit;
|
685 | 705 |
|
686 |
- if ( format & 0xFFC0 )
|
|
706 |
+ if ( format == 0 )
|
|
707 |
+ {
|
|
708 |
+ if ( FT_READ_USHORT( map->mapCount ) )
|
|
709 |
+ goto Exit;
|
|
710 |
+ }
|
|
711 |
+ else if ( format == 1 ) /* new in OpenType 1.9 */
|
|
712 |
+ {
|
|
713 |
+ if ( FT_READ_ULONG( map->mapCount ) )
|
|
714 |
+ goto Exit;
|
|
715 |
+ }
|
|
716 |
+ else
|
|
687 | 717 |
{
|
688 | 718 |
FT_TRACE2(( "bad map format %d\n", format ));
|
689 | 719 |
error = FT_THROW( Invalid_Table );
|
690 | 720 |
goto Exit;
|
691 | 721 |
}
|
692 | 722 |
|
723 |
+ if ( entryFormat & 0xC0 )
|
|
724 |
+ {
|
|
725 |
+ FT_TRACE2(( "bad entry format %d\n", format ));
|
|
726 |
+ error = FT_THROW( Invalid_Table );
|
|
727 |
+ goto Exit;
|
|
728 |
+ }
|
|
729 |
+ |
|
693 | 730 |
/* bytes per entry: 1, 2, 3, or 4 */
|
694 |
- entrySize = ( ( format & 0x0030 ) >> 4 ) + 1;
|
|
695 |
- innerBitCount = ( format & 0x000F ) + 1;
|
|
731 |
+ entrySize = ( ( entryFormat & 0x30 ) >> 4 ) + 1;
|
|
732 |
+ innerBitCount = ( entryFormat & 0x0F ) + 1;
|
|
696 | 733 |
innerIndexMask = ( 1 << innerBitCount ) - 1;
|
697 | 734 |
|
735 |
+ /* rough sanity check */
|
|
736 |
+ if ( map->mapCount * entrySize > table_len )
|
|
737 |
+ {
|
|
738 |
+ FT_TRACE1(( "ft_var_load_delta_set_index_mapping:"
|
|
739 |
+ " invalid number of delta-set index mappings\n" ));
|
|
740 |
+ error = FT_THROW( Invalid_Table );
|
|
741 |
+ goto Exit;
|
|
742 |
+ }
|
|
743 |
+ |
|
698 | 744 |
if ( FT_NEW_ARRAY( map->innerIndex, map->mapCount ) )
|
699 | 745 |
goto Exit;
|
700 | 746 |
|
... | ... | @@ -723,7 +769,7 @@ |
723 | 769 |
|
724 | 770 |
if ( outerIndex >= itemStore->dataCount )
|
725 | 771 |
{
|
726 |
- FT_TRACE2(( "outerIndex[%d] == %d out of range\n",
|
|
772 |
+ FT_TRACE2(( "outerIndex[%ld] == %d out of range\n",
|
|
727 | 773 |
i,
|
728 | 774 |
outerIndex ));
|
729 | 775 |
error = FT_THROW( Invalid_Table );
|
... | ... | @@ -736,7 +782,7 @@ |
736 | 782 |
|
737 | 783 |
if ( innerIndex >= itemStore->varData[outerIndex].itemCount )
|
738 | 784 |
{
|
739 |
- FT_TRACE2(( "innerIndex[%d] == %d out of range\n",
|
|
785 |
+ FT_TRACE2(( "innerIndex[%ld] == %d out of range\n",
|
|
740 | 786 |
i,
|
741 | 787 |
innerIndex ));
|
742 | 788 |
error = FT_THROW( Invalid_Table );
|
... | ... | @@ -861,7 +907,8 @@ |
861 | 907 |
face,
|
862 | 908 |
table_offset + widthMap_offset,
|
863 | 909 |
&table->widthMap,
|
864 |
- &table->itemStore );
|
|
910 |
+ &table->itemStore,
|
|
911 |
+ table_len );
|
|
865 | 912 |
if ( error )
|
866 | 913 |
goto Exit;
|
867 | 914 |
}
|
... | ... | @@ -106,9 +106,9 @@ FT_BEGIN_HEADER |
106 | 106 |
|
107 | 107 |
typedef struct GX_DeltaSetIdxMapRec_
|
108 | 108 |
{
|
109 |
- FT_UInt mapCount;
|
|
110 |
- FT_UInt* outerIndex; /* indices to item var data */
|
|
111 |
- FT_UInt* innerIndex; /* indices to delta set */
|
|
109 |
+ FT_ULong mapCount;
|
|
110 |
+ FT_UInt* outerIndex; /* indices to item var data */
|
|
111 |
+ FT_UInt* innerIndex; /* indices to delta set */
|
|
112 | 112 |
|
113 | 113 |
} GX_DeltaSetIdxMapRec, *GX_DeltaSetIdxMap;
|
114 | 114 |
|
... | ... | @@ -79,7 +79,7 @@ |
79 | 79 |
/* For ordinary fonts get the character data stored in the face record. */
|
80 | 80 |
{
|
81 | 81 |
char_string->pointer = type1->charstrings[glyph_index];
|
82 |
- char_string->length = (FT_Int)type1->charstrings_len[glyph_index];
|
|
82 |
+ char_string->length = type1->charstrings_len[glyph_index];
|
|
83 | 83 |
}
|
84 | 84 |
|
85 | 85 |
if ( !error )
|
... | ... | @@ -1346,7 +1346,7 @@ |
1346 | 1346 |
|
1347 | 1347 |
static int
|
1348 | 1348 |
read_binary_data( T1_Parser parser,
|
1349 |
- FT_Long* size,
|
|
1349 |
+ FT_ULong* size,
|
|
1350 | 1350 |
FT_Byte** base,
|
1351 | 1351 |
FT_Bool incremental )
|
1352 | 1352 |
{
|
... | ... | @@ -1378,7 +1378,7 @@ |
1378 | 1378 |
if ( s >= 0 && s < limit - *base )
|
1379 | 1379 |
{
|
1380 | 1380 |
parser->root.cursor += s + 1;
|
1381 |
- *size = s;
|
|
1381 |
+ *size = (FT_ULong)s;
|
|
1382 | 1382 |
return !parser->root.error;
|
1383 | 1383 |
}
|
1384 | 1384 |
}
|
... | ... | @@ -1803,7 +1803,7 @@ |
1803 | 1803 |
for ( count = 0; ; count++ )
|
1804 | 1804 |
{
|
1805 | 1805 |
FT_Long idx;
|
1806 |
- FT_Long size;
|
|
1806 |
+ FT_ULong size;
|
|
1807 | 1807 |
FT_Byte* base;
|
1808 | 1808 |
|
1809 | 1809 |
|
... | ... | @@ -1861,7 +1861,7 @@ |
1861 | 1861 |
/* some fonts define empty subr records -- this is not totally */
|
1862 | 1862 |
/* compliant to the specification (which says they should at */
|
1863 | 1863 |
/* least contain a `return'), but we support them anyway */
|
1864 |
- if ( size < face->type1.private_dict.lenIV )
|
|
1864 |
+ if ( size < (FT_ULong)face->type1.private_dict.lenIV )
|
|
1865 | 1865 |
{
|
1866 | 1866 |
error = FT_THROW( Invalid_File_Format );
|
1867 | 1867 |
goto Fail;
|
... | ... | @@ -1872,7 +1872,7 @@ |
1872 | 1872 |
goto Fail;
|
1873 | 1873 |
FT_MEM_COPY( temp, base, size );
|
1874 | 1874 |
psaux->t1_decrypt( temp, size, 4330 );
|
1875 |
- size -= face->type1.private_dict.lenIV;
|
|
1875 |
+ size -= (FT_ULong)face->type1.private_dict.lenIV;
|
|
1876 | 1876 |
error = T1_Add_Table( table, (FT_Int)idx,
|
1877 | 1877 |
temp + face->type1.private_dict.lenIV, size );
|
1878 | 1878 |
FT_FREE( temp );
|
... | ... | @@ -1977,7 +1977,7 @@ |
1977 | 1977 |
|
1978 | 1978 |
for (;;)
|
1979 | 1979 |
{
|
1980 |
- FT_Long size;
|
|
1980 |
+ FT_ULong size;
|
|
1981 | 1981 |
FT_Byte* base;
|
1982 | 1982 |
|
1983 | 1983 |
|
... | ... | @@ -2071,7 +2071,7 @@ |
2071 | 2071 |
FT_Byte* temp = NULL;
|
2072 | 2072 |
|
2073 | 2073 |
|
2074 |
- if ( size <= face->type1.private_dict.lenIV )
|
|
2074 |
+ if ( size <= (FT_ULong)face->type1.private_dict.lenIV )
|
|
2075 | 2075 |
{
|
2076 | 2076 |
error = FT_THROW( Invalid_File_Format );
|
2077 | 2077 |
goto Fail;
|
... | ... | @@ -2082,7 +2082,7 @@ |
2082 | 2082 |
goto Fail;
|
2083 | 2083 |
FT_MEM_COPY( temp, base, size );
|
2084 | 2084 |
psaux->t1_decrypt( temp, size, 4330 );
|
2085 |
- size -= face->type1.private_dict.lenIV;
|
|
2085 |
+ size -= (FT_ULong)face->type1.private_dict.lenIV;
|
|
2086 | 2086 |
error = T1_Add_Table( code_table, n,
|
2087 | 2087 |
temp + face->type1.private_dict.lenIV, size );
|
2088 | 2088 |
FT_FREE( temp );
|
... | ... | @@ -2334,7 +2334,7 @@ |
2334 | 2334 |
else if ( *cur == 'R' && cur + 6 < limit && *(cur + 1) == 'D' &&
|
2335 | 2335 |
have_integer )
|
2336 | 2336 |
{
|
2337 |
- FT_Long s;
|
|
2337 |
+ FT_ULong s;
|
|
2338 | 2338 |
FT_Byte* b;
|
2339 | 2339 |
|
2340 | 2340 |
|
... | ... | @@ -2347,7 +2347,7 @@ |
2347 | 2347 |
else if ( *cur == '-' && cur + 6 < limit && *(cur + 1) == '|' &&
|
2348 | 2348 |
have_integer )
|
2349 | 2349 |
{
|
2350 |
- FT_Long s;
|
|
2350 |
+ FT_ULong s;
|
|
2351 | 2351 |
FT_Byte* b;
|
2352 | 2352 |
|
2353 | 2353 |
|