diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2021-12-03 04:03:12 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2021-12-03 04:03:12 +0000 |
commit | 4ee9d04bd5d518e5f1f86875f4f8184fc0552f44 (patch) | |
tree | 4f27c2cc7196ba469bf631ffe0460cb3d6bcbc9d /Build/source/libs/freetype2/freetype-src/src/sfnt | |
parent | 39bd39ea6f91fb51d118264f372905de9accc347 (diff) |
freetype 2.11.1
git-svn-id: svn://tug.org/texlive/trunk@61211 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/freetype2/freetype-src/src/sfnt')
11 files changed, 313 insertions, 99 deletions
diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfdriver.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfdriver.c index 824e709fab6..d1d01c99e52 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfdriver.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfdriver.c @@ -1292,13 +1292,15 @@ /* TT_Get_Colr_Layer_Func get_colr_layer */ PUT_COLOR_LAYERS_V1( tt_face_get_colr_glyph_paint ), - /* TT_Get_Colr_Glyph_Paint_Func get_colr_glyph_paint */ + /* TT_Get_Color_Glyph_Paint_Func get_colr_glyph_paint */ + PUT_COLOR_LAYERS_V1( tt_face_get_color_glyph_clipbox ), + /* TT_Get_Color_Glyph_ClipBox_Func get_clipbox */ PUT_COLOR_LAYERS_V1( tt_face_get_paint_layers ), - /* TT_Get_Paint_Layers_Func get_paint_layers */ + /* TT_Get_Paint_Layers_Func get_paint_layers */ PUT_COLOR_LAYERS_V1( tt_face_get_colorline_stops ), - /* TT_Get_Paint get_paint */ + /* TT_Get_Paint get_paint */ PUT_COLOR_LAYERS_V1( tt_face_get_paint ), - /* TT_Get_Colorline_Stops_Func get_colorline_stops */ + /* TT_Get_Colorline_Stops_Func get_colorline_stops */ PUT_COLOR_LAYERS( tt_face_colr_blend_layer ), /* TT_Blend_Colr_Func colr_blend */ 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 cf730717eb0..78910247900 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.c @@ -360,17 +360,27 @@ FT_FRAME_END }; +#ifndef FT_CONFIG_OPTION_USE_BROTLI + FT_UNUSED( face_instance_index ); + FT_UNUSED( woff2_num_faces ); +#endif + face->ttc_header.tag = 0; face->ttc_header.version = 0; face->ttc_header.count = 0; +#if defined( FT_CONFIG_OPTION_USE_ZLIB ) || \ + defined( FT_CONFIG_OPTION_USE_BROTLI ) retry: +#endif + offset = FT_STREAM_POS(); if ( FT_READ_ULONG( tag ) ) return error; +#ifdef FT_CONFIG_OPTION_USE_ZLIB if ( tag == TTAG_wOFF ) { FT_TRACE2(( "sfnt_open_font: file is a WOFF; synthesizing SFNT\n" )); @@ -386,7 +396,9 @@ stream = face->root.stream; goto retry; } +#endif +#ifdef FT_CONFIG_OPTION_USE_BROTLI if ( tag == TTAG_wOF2 ) { FT_TRACE2(( "sfnt_open_font: file is a WOFF2; synthesizing SFNT\n" )); @@ -405,6 +417,7 @@ stream = face->root.stream; goto retry; } +#endif if ( tag != 0x00010000UL && tag != TTAG_ttcf && @@ -1209,7 +1222,7 @@ /* of `FT_Face', we map `available_sizes' indices to strike */ /* indices */ if ( FT_NEW_ARRAY( root->available_sizes, count ) || - FT_NEW_ARRAY( sbit_strike_map, count ) ) + FT_QNEW_ARRAY( sbit_strike_map, count ) ) goto Exit; bsize_idx = 0; @@ -1238,7 +1251,7 @@ } /* reduce array size to the actually used elements */ - (void)FT_QRENEW_ARRAY( sbit_strike_map, count, bsize_idx ); + FT_MEM_QRENEW_ARRAY( sbit_strike_map, count, bsize_idx ); /* from now on, all strike indices are mapped */ /* using `sbit_strike_map' */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff.c index 44c926ed413..422c816a215 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff.c @@ -23,6 +23,9 @@ #include <freetype/ftgzip.h> +#ifdef FT_CONFIG_OPTION_USE_ZLIB + + /************************************************************************** * * The macro FT_COMPONENT is used in trace mode. It is an implicit @@ -109,7 +112,7 @@ FT_ULong sfnt_offset; FT_Int nn; - FT_ULong old_tag = 0; + FT_Tag old_tag = 0; static const FT_Frame_Field woff_header_fields[] = { @@ -360,8 +363,6 @@ } else { -#ifdef FT_CONFIG_OPTION_USE_ZLIB - /* Uncompress with zlib. */ FT_ULong output_len = table->OrigLength; @@ -377,13 +378,6 @@ error = FT_THROW( Invalid_Table ); goto Exit1; } - -#else /* !FT_CONFIG_OPTION_USE_ZLIB */ - - error = FT_THROW( Unimplemented_Feature ); - goto Exit1; - -#endif /* !FT_CONFIG_OPTION_USE_ZLIB */ } FT_FRAME_EXIT(); @@ -433,5 +427,12 @@ #undef WRITE_USHORT #undef WRITE_ULONG +#else /* !FT_CONFIG_OPTION_USE_ZLIB */ + + /* ANSI C doesn't like empty source files */ + typedef int _sfwoff_dummy; + +#endif /* !FT_CONFIG_OPTION_USE_ZLIB */ + /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff.h b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff.h index e2f22731e20..3fbdac0fde7 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff.h +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff.h @@ -26,12 +26,15 @@ FT_BEGIN_HEADER +#ifdef FT_CONFIG_OPTION_USE_ZLIB FT_LOCAL( FT_Error ) woff_open_font( FT_Stream stream, TT_Face face ); +#endif + FT_END_HEADER #endif /* SFWOFF_H_ */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff2.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff2.c index df04072382e..5ee8dea28a7 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff2.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff2.c @@ -26,8 +26,6 @@ #include <brotli/decode.h> -#endif - /************************************************************************** * @@ -108,8 +106,8 @@ WOFF2_Table table1 = *(WOFF2_Table*)a; WOFF2_Table table2 = *(WOFF2_Table*)b; - FT_ULong tag1 = table1->Tag; - FT_ULong tag2 = table2->Tag; + FT_Tag tag1 = table1->Tag; + FT_Tag tag2 = table2->Tag; if ( tag1 > tag2 ) @@ -316,8 +314,6 @@ const FT_Byte* src, FT_ULong src_size ) { -#ifdef FT_CONFIG_OPTION_USE_BROTLI - /* this cast is only of importance on 32bit systems; */ /* we don't validate it */ FT_Offset uncompressed_size = (FT_Offset)dst_size; @@ -338,25 +334,13 @@ FT_TRACE2(( "woff2_decompress: Brotli stream decompressed.\n" )); return FT_Err_Ok; - -#else /* !FT_CONFIG_OPTION_USE_BROTLI */ - - FT_UNUSED( dst ); - FT_UNUSED( dst_size ); - FT_UNUSED( src ); - FT_UNUSED( src_size ); - - FT_ERROR(( "woff2_decompress: Brotli support not available.\n" )); - return FT_THROW( Unimplemented_Feature ); - -#endif /* !FT_CONFIG_OPTION_USE_BROTLI */ } static WOFF2_Table find_table( WOFF2_Table* tables, FT_UShort num_tables, - FT_ULong tag ) + FT_Tag tag ) { FT_Int i; @@ -2216,7 +2200,7 @@ /* reject fonts that have multiple tables with the same tag */ for ( nn = 1; nn < woff2.num_tables; nn++ ) { - FT_ULong tag = indices[nn]->Tag; + FT_Tag tag = indices[nn]->Tag; if ( tag == indices[nn - 1]->Tag ) @@ -2356,5 +2340,12 @@ #undef BBOX_STREAM #undef INSTRUCTION_STREAM +#else /* !FT_CONFIG_OPTION_USE_BROTLI */ + + /* ANSI C doesn't like empty source files */ + typedef int _sfwoff2_dummy; + +#endif /* !FT_CONFIG_OPTION_USE_BROTLI */ + /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff2.h b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff2.h index 27f3da7b1d3..fa78b024297 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff2.h +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff2.h @@ -26,6 +26,7 @@ FT_BEGIN_HEADER +#ifdef FT_CONFIG_OPTION_USE_BROTLI /* Leave the first byte open to store `flag_byte'. */ #define WOFF2_FLAGS_TRANSFORM 1 << 8 @@ -66,6 +67,7 @@ FT_BEGIN_HEADER FT_Int* face_index, FT_Long* num_faces ); +#endif /* FT_CONFIG_OPTION_USE_BROTLI */ FT_END_HEADER diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcolr.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcolr.c index bd478ab9b5b..8f5cc8bcd1f 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcolr.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcolr.c @@ -27,6 +27,7 @@ */ +#include <freetype/internal/ftcalc.h> #include <freetype/internal/ftdebug.h> #include <freetype/internal/ftstream.h> #include <freetype/tttags.h> @@ -94,6 +95,8 @@ FT_ULong num_layers_v1; FT_Byte* layers_v1; + FT_Byte* clip_list; + /* * Paint tables start at the minimum of the end of the LayerList and the * end of the BaseGlyphList. Record this location in a field here for @@ -134,7 +137,7 @@ FT_ULong base_glyph_offset, layer_offset; FT_ULong base_glyphs_offset_v1, num_base_glyphs_v1; - FT_ULong layer_offset_v1, num_layers_v1; + FT_ULong layer_offset_v1, num_layers_v1, clip_list_offset; FT_ULong table_size; @@ -226,6 +229,16 @@ colr->base_glyphs_v1 + colr->num_base_glyphs_v1 * BASE_GLYPH_PAINT_RECORD_SIZE; } + + clip_list_offset = FT_NEXT_ULONG( p ); + + if ( clip_list_offset >= table_size ) + goto InvalidTable; + + if ( clip_list_offset ) + colr->clip_list = (FT_Byte*)( table + clip_list_offset ); + else + colr->clip_list = 0; } colr->base_glyphs = (FT_Byte*)( table + base_glyph_offset ); @@ -493,12 +506,16 @@ &apaint->u.linear_gradient.colorline ) ) return 0; - apaint->u.linear_gradient.p0.x = FT_NEXT_SHORT( p ); - apaint->u.linear_gradient.p0.y = FT_NEXT_SHORT( p ); - apaint->u.linear_gradient.p1.x = FT_NEXT_SHORT( p ); - apaint->u.linear_gradient.p1.y = FT_NEXT_SHORT( p ); - apaint->u.linear_gradient.p2.x = FT_NEXT_SHORT( p ); - apaint->u.linear_gradient.p2.y = FT_NEXT_SHORT( p ); + /* + * In order to support variations expose these as FT_Fixed 16.16 values so + * that we can support fractional values after interpolation. + */ + apaint->u.linear_gradient.p0.x = INT_TO_FIXED( FT_NEXT_SHORT( p ) ); + apaint->u.linear_gradient.p0.y = INT_TO_FIXED( FT_NEXT_SHORT( p ) ); + apaint->u.linear_gradient.p1.x = INT_TO_FIXED( FT_NEXT_SHORT( p ) ); + apaint->u.linear_gradient.p1.y = INT_TO_FIXED( FT_NEXT_SHORT( p ) ); + apaint->u.linear_gradient.p2.x = INT_TO_FIXED( FT_NEXT_SHORT( p ) ); + apaint->u.linear_gradient.p2.y = INT_TO_FIXED( FT_NEXT_SHORT( p ) ); return 1; } @@ -509,15 +526,15 @@ &apaint->u.radial_gradient.colorline ) ) return 0; - apaint->u.radial_gradient.c0.x = FT_NEXT_SHORT( p ); - apaint->u.radial_gradient.c0.y = FT_NEXT_SHORT( p ); + apaint->u.radial_gradient.c0.x = INT_TO_FIXED( FT_NEXT_SHORT( p ) ); + apaint->u.radial_gradient.c0.y = INT_TO_FIXED( FT_NEXT_SHORT( p ) ); - apaint->u.radial_gradient.r0 = FT_NEXT_USHORT( p ); + apaint->u.radial_gradient.r0 = FT_NEXT_USHORT( p ) << 16; - apaint->u.radial_gradient.c1.x = FT_NEXT_SHORT( p ); - apaint->u.radial_gradient.c1.y = FT_NEXT_SHORT( p ); + apaint->u.radial_gradient.c1.x = INT_TO_FIXED( FT_NEXT_SHORT( p ) ); + apaint->u.radial_gradient.c1.y = INT_TO_FIXED( FT_NEXT_SHORT( p ) ); - apaint->u.radial_gradient.r1 = FT_NEXT_USHORT( p ); + apaint->u.radial_gradient.r1 = FT_NEXT_USHORT( p ) << 16; return 1; } @@ -528,11 +545,15 @@ &apaint->u.sweep_gradient.colorline ) ) return 0; - apaint->u.sweep_gradient.center.x = FT_NEXT_SHORT( p ); - apaint->u.sweep_gradient.center.y = FT_NEXT_SHORT( p ); + apaint->u.sweep_gradient.center.x = + INT_TO_FIXED( FT_NEXT_SHORT( p ) ); + apaint->u.sweep_gradient.center.y = + INT_TO_FIXED( FT_NEXT_SHORT( p ) ); - apaint->u.sweep_gradient.start_angle = FT_NEXT_LONG( p ); - apaint->u.sweep_gradient.end_angle = FT_NEXT_LONG( p ); + apaint->u.sweep_gradient.start_angle = + F2DOT14_TO_FIXED( FT_NEXT_SHORT( p ) ); + apaint->u.sweep_gradient.end_angle = + F2DOT14_TO_FIXED( FT_NEXT_SHORT( p ) ); return 1; } @@ -551,6 +572,15 @@ apaint->u.transform.paint.p = child_table_p; apaint->u.transform.paint.insert_root_transform = 0; + if ( !get_child_table_pointer( colr, paint_base, &p, &child_table_p ) ) + return 0; + + p = child_table_p; + + /* + * The following matrix coefficients are encoded as + * OpenType 16.16 fixed-point values. + */ apaint->u.transform.affine.xx = FT_NEXT_LONG( p ); apaint->u.transform.affine.yx = FT_NEXT_LONG( p ); apaint->u.transform.affine.xy = FT_NEXT_LONG( p ); @@ -566,8 +596,8 @@ apaint->u.translate.paint.p = child_table_p; apaint->u.translate.paint.insert_root_transform = 0; - apaint->u.translate.dx = FT_NEXT_LONG( p ); - apaint->u.translate.dy = FT_NEXT_LONG( p ); + apaint->u.translate.dx = INT_TO_FIXED( FT_NEXT_SHORT( p ) ); + apaint->u.translate.dy = INT_TO_FIXED( FT_NEXT_SHORT( p ) ); return 1; } @@ -585,14 +615,14 @@ apaint->u.scale.paint.insert_root_transform = 0; /* All scale paints get at least one scale value. */ - apaint->u.scale.scale_x = FT_NEXT_LONG( p ); + apaint->u.scale.scale_x = F2DOT14_TO_FIXED( FT_NEXT_SHORT( p ) ); /* Non-uniform ones read an extra y value. */ if ( apaint->format == FT_COLR_PAINTFORMAT_SCALE || (FT_PaintFormat_Internal)apaint->format == FT_COLR_PAINTFORMAT_INTERNAL_SCALE_CENTER ) - apaint->u.scale.scale_y = FT_NEXT_LONG( p ); + apaint->u.scale.scale_y = F2DOT14_TO_FIXED( FT_NEXT_SHORT( p ) ); else apaint->u.scale.scale_y = apaint->u.scale.scale_x; @@ -603,8 +633,8 @@ (FT_PaintFormat_Internal)apaint->format == FT_COLR_PAINTFORMAT_INTERNAL_SCALE_UNIFORM_CENTER ) { - apaint->u.scale.center_x = FT_NEXT_LONG ( p ); - apaint->u.scale.center_y = FT_NEXT_LONG ( p ); + apaint->u.scale.center_x = INT_TO_FIXED( FT_NEXT_SHORT ( p ) ); + apaint->u.scale.center_y = INT_TO_FIXED( FT_NEXT_SHORT ( p ) ); } else { @@ -619,29 +649,55 @@ return 1; } - else if ( apaint->format == FT_COLR_PAINTFORMAT_ROTATE ) + else if ( apaint->format == FT_COLR_PAINTFORMAT_ROTATE || + (FT_PaintFormat_Internal)apaint->format == + FT_COLR_PAINTFORMAT_INTERNAL_ROTATE_CENTER ) { apaint->u.rotate.paint.p = child_table_p; apaint->u.rotate.paint.insert_root_transform = 0; - apaint->u.rotate.angle = FT_NEXT_LONG( p ); + apaint->u.rotate.angle = F2DOT14_TO_FIXED( FT_NEXT_SHORT( p ) ); + + if ( (FT_PaintFormat_Internal)apaint->format == + FT_COLR_PAINTFORMAT_INTERNAL_ROTATE_CENTER ) + { + apaint->u.rotate.center_x = INT_TO_FIXED( FT_NEXT_SHORT( p ) ); + apaint->u.rotate.center_y = INT_TO_FIXED( FT_NEXT_SHORT( p ) ); + } + else + { + apaint->u.rotate.center_x = 0; + apaint->u.rotate.center_y = 0; + } - apaint->u.rotate.center_x = FT_NEXT_LONG( p ); - apaint->u.rotate.center_y = FT_NEXT_LONG( p ); + apaint->format = FT_COLR_PAINTFORMAT_ROTATE; return 1; } - else if ( apaint->format == FT_COLR_PAINTFORMAT_SKEW ) + else if ( apaint->format == FT_COLR_PAINTFORMAT_SKEW || + (FT_PaintFormat_Internal)apaint->format == + FT_COLR_PAINTFORMAT_INTERNAL_SKEW_CENTER ) { apaint->u.skew.paint.p = child_table_p; apaint->u.skew.paint.insert_root_transform = 0; - apaint->u.skew.x_skew_angle = FT_NEXT_LONG( p ); - apaint->u.skew.y_skew_angle = FT_NEXT_LONG( p ); + apaint->u.skew.x_skew_angle = F2DOT14_TO_FIXED( FT_NEXT_SHORT( p ) ); + apaint->u.skew.y_skew_angle = F2DOT14_TO_FIXED( FT_NEXT_SHORT( p ) ); + + if ( (FT_PaintFormat_Internal)apaint->format == + FT_COLR_PAINTFORMAT_INTERNAL_SKEW_CENTER ) + { + apaint->u.skew.center_x = INT_TO_FIXED( FT_NEXT_SHORT( p ) ); + apaint->u.skew.center_y = INT_TO_FIXED( FT_NEXT_SHORT( p ) ); + } + else + { + apaint->u.skew.center_x = 0; + apaint->u.skew.center_y = 0; + } - apaint->u.skew.center_x = FT_NEXT_LONG( p ); - apaint->u.skew.center_y = FT_NEXT_LONG( p ); + apaint->format = FT_COLR_PAINTFORMAT_SKEW; return 1; } @@ -762,6 +818,117 @@ FT_LOCAL_DEF( FT_Bool ) + tt_face_get_color_glyph_clipbox( TT_Face face, + FT_UInt base_glyph, + FT_ClipBox* clip_box ) + { + Colr* colr; + + FT_Byte *p, *p1, *clip_base; + + FT_Byte clip_list_format; + FT_ULong num_clip_boxes, i; + FT_UShort gid_start, gid_end; + FT_UInt32 clip_box_offset; + FT_Byte format; + + const FT_Byte num_corners = 4; + FT_Vector corners[4]; + FT_Byte j; + FT_BBox font_clip_box; + + + colr = (Colr*)face->colr; + if ( !colr ) + return 0; + + if ( !colr->clip_list ) + return 0; + + p = colr->clip_list; + + clip_base = p; + clip_list_format = FT_NEXT_BYTE ( p ); + + /* Format byte used here to be able to upgrade ClipList for >16bit */ + /* glyph ids; for now we can expect it to be 0. */ + if ( !( clip_list_format == 1 ) ) + return 0; + + num_clip_boxes = FT_NEXT_ULONG( p ); + + for ( i = 0; i < num_clip_boxes; ++i ) + { + gid_start = FT_NEXT_USHORT( p ); + gid_end = FT_NEXT_USHORT( p ); + clip_box_offset = FT_NEXT_UOFF3( p ); + + if ( base_glyph >= gid_start && base_glyph <= gid_end ) + { + p1 = (FT_Byte*)( clip_base + clip_box_offset ); + + if ( p1 >= ( (FT_Byte*)colr->table + colr->table_size ) ) + return 0; + + format = FT_NEXT_BYTE( p1 ); + + if ( format > 1 ) + return 0; + + /* `face->root.size->metrics.x_scale` and `y_scale` are factors */ + /* that scale a font unit value in integers to a 26.6 fixed value */ + /* according to the requested size, see for example */ + /* `ft_recompute_scaled_metrics`. */ + font_clip_box.xMin = FT_MulFix( FT_NEXT_SHORT( p1 ), + face->root.size->metrics.x_scale ); + font_clip_box.yMin = FT_MulFix( FT_NEXT_SHORT( p1 ), + face->root.size->metrics.x_scale ); + font_clip_box.xMax = FT_MulFix( FT_NEXT_SHORT( p1 ), + face->root.size->metrics.x_scale ); + font_clip_box.yMax = FT_MulFix( FT_NEXT_SHORT( p1 ), + face->root.size->metrics.x_scale ); + + /* Make 4 corner points (xMin, yMin), (xMax, yMax) and transform */ + /* them. If we we would only transform two corner points and */ + /* span a rectangle based on those, the rectangle may become too */ + /* small to cover the glyph. */ + corners[0].x = font_clip_box.xMin; + corners[1].x = font_clip_box.xMin; + corners[2].x = font_clip_box.xMax; + corners[3].x = font_clip_box.xMax; + + corners[0].y = font_clip_box.yMin; + corners[1].y = font_clip_box.yMax; + corners[2].y = font_clip_box.yMax; + corners[3].y = font_clip_box.yMin; + + for ( j = 0; j < num_corners; ++j ) + { + if ( face->root.internal->transform_flags & 1 ) + FT_Vector_Transform( &corners[j], + &face->root.internal->transform_matrix ); + + if ( face->root.internal->transform_flags & 2 ) + { + corners[j].x += face->root.internal->transform_delta.x; + corners[j].y += face->root.internal->transform_delta.y; + } + } + + clip_box->bottom_left = corners[0]; + clip_box->top_left = corners[1]; + clip_box->top_right = corners[2]; + clip_box->bottom_right = corners[3]; + + return 1; + } + } + + return 0; + } + + + FT_LOCAL_DEF( FT_Bool ) tt_face_get_paint_layers( TT_Face face, FT_LayerIterator* iterator, FT_OpaquePaint* opaque_paint ) @@ -928,9 +1095,9 @@ if ( face->root.internal->transform_flags & 2 ) { paint->u.transform.affine.dx = - face->root.internal->transform_delta.x << 10; + face->root.internal->transform_delta.x * ( 1 << 10 ); paint->u.transform.affine.dy = - face->root.internal->transform_delta.y << 10; + face->root.internal->transform_delta.y * ( 1 << 10 ); } else { diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcolr.h b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcolr.h index c91d2b1723e..b81e4cb958c 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcolr.h +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcolr.h @@ -49,6 +49,11 @@ FT_BEGIN_HEADER FT_OpaquePaint* paint ); FT_LOCAL( FT_Bool ) + tt_face_get_color_glyph_clipbox( TT_Face face, + FT_UInt base_glyph, + FT_ClipBox* clip_box ); + + FT_LOCAL( FT_Bool ) tt_face_get_paint_layers( TT_Face face, FT_LayerIterator* iterator, FT_OpaquePaint* paint ); diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttload.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttload.c index d8ea9ea01cd..51416d80b4a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttload.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttload.c @@ -837,6 +837,8 @@ FT_ULong table_pos, table_len; FT_ULong storage_start, storage_limit; TT_NameTable table; + TT_Name names = NULL; + TT_LangTag langTags = NULL; static const FT_Frame_Field name_table_fields[] = { @@ -917,13 +919,13 @@ storage_start += 2 + 4 * table->numLangTagRecords; /* allocate language tag records array */ - if ( FT_QNEW_ARRAY( table->langTags, table->numLangTagRecords ) || - FT_FRAME_ENTER( table->numLangTagRecords * 4 ) ) + if ( FT_QNEW_ARRAY( langTags, table->numLangTagRecords ) || + FT_FRAME_ENTER( table->numLangTagRecords * 4 ) ) goto Exit; /* load language tags */ { - TT_LangTag entry = table->langTags; + TT_LangTag entry = langTags; TT_LangTag limit = FT_OFFSET( entry, table->numLangTagRecords ); @@ -939,7 +941,13 @@ /* invalid entry; ignore it */ entry->stringLength = 0; } + + /* mark the string as not yet loaded */ + entry->string = NULL; } + + table->langTags = langTags; + langTags = NULL; } FT_FRAME_EXIT(); @@ -948,14 +956,15 @@ } /* allocate name records array */ - if ( FT_QNEW_ARRAY( table->names, table->numNameRecords ) || - FT_FRAME_ENTER( table->numNameRecords * 12 ) ) + if ( FT_QNEW_ARRAY( names, table->numNameRecords ) || + FT_FRAME_ENTER( table->numNameRecords * 12 ) ) goto Exit; /* load name records */ { - TT_Name entry = table->names; + TT_Name entry = names; FT_UInt count = table->numNameRecords; + FT_UInt valid = 0; for ( ; count > 0; count-- ) @@ -988,15 +997,20 @@ } } + /* mark the string as not yet converted */ + entry->string = NULL; + + valid++; entry++; } /* reduce array size to the actually used elements */ - count = (FT_UInt)( entry - table->names ); - (void)FT_QRENEW_ARRAY( table->names, - table->numNameRecords, - count ); - table->numNameRecords = count; + FT_MEM_QRENEW_ARRAY( names, + table->numNameRecords, + valid ); + table->names = names; + names = NULL; + table->numNameRecords = valid; } FT_FRAME_EXIT(); @@ -1005,6 +1019,8 @@ face->num_names = (FT_UShort)table->numNameRecords; Exit: + FT_FREE( names ); + FT_FREE( langTags ); return error; } @@ -1417,8 +1433,8 @@ FT_Error error; FT_Memory memory = stream->memory; - FT_UInt j,num_ranges; - TT_GaspRange gaspranges = NULL; + FT_UShort j, num_ranges; + TT_GaspRange gasp_ranges = NULL; /* the gasp table is optional */ @@ -1429,8 +1445,8 @@ if ( FT_FRAME_ENTER( 4L ) ) goto Exit; - face->gasp.version = FT_GET_USHORT(); - face->gasp.numRanges = FT_GET_USHORT(); + face->gasp.version = FT_GET_USHORT(); + num_ranges = FT_GET_USHORT(); FT_FRAME_EXIT(); @@ -1442,29 +1458,31 @@ goto Exit; } - num_ranges = face->gasp.numRanges; - FT_TRACE3(( "numRanges: %u\n", num_ranges )); + FT_TRACE3(( "numRanges: %hu\n", num_ranges )); - if ( FT_QNEW_ARRAY( face->gasp.gaspRanges, num_ranges ) || - FT_FRAME_ENTER( num_ranges * 4L ) ) + if ( FT_QNEW_ARRAY( gasp_ranges, num_ranges ) || + FT_FRAME_ENTER( num_ranges * 4L ) ) goto Exit; - gaspranges = face->gasp.gaspRanges; - for ( j = 0; j < num_ranges; j++ ) { - gaspranges[j].maxPPEM = FT_GET_USHORT(); - gaspranges[j].gaspFlag = FT_GET_USHORT(); + gasp_ranges[j].maxPPEM = FT_GET_USHORT(); + gasp_ranges[j].gaspFlag = FT_GET_USHORT(); FT_TRACE3(( "gaspRange %d: rangeMaxPPEM %5d, rangeGaspBehavior 0x%x\n", j, - gaspranges[j].maxPPEM, - gaspranges[j].gaspFlag )); + gasp_ranges[j].maxPPEM, + gasp_ranges[j].gaspFlag )); } + face->gasp.gaspRanges = gasp_ranges; + gasp_ranges = NULL; + face->gasp.numRanges = num_ranges; + FT_FRAME_EXIT(); Exit: + FT_FREE( gasp_ranges ); return error; } diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/woff2tags.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/woff2tags.c index 84748268c1a..fe8f5cf76f6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/woff2tags.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/woff2tags.c @@ -17,6 +17,9 @@ #include <freetype/tttags.h> + +#ifdef FT_CONFIG_OPTION_USE_BROTLI + #include "woff2tags.h" /* @@ -28,10 +31,10 @@ * * for details. */ - FT_LOCAL_DEF( FT_ULong ) + FT_LOCAL_DEF( FT_Tag ) woff2_known_tags( FT_Byte index ) { - const FT_ULong known_tags[63] = + static const FT_Tag known_tags[63] = { FT_MAKE_TAG('c', 'm', 'a', 'p'), /* 0 */ FT_MAKE_TAG('h', 'e', 'a', 'd'), /* 1 */ @@ -105,5 +108,12 @@ return known_tags[index]; } +#else /* !FT_CONFIG_OPTION_USE_BROTLI */ + + /* ANSI C doesn't like empty source files */ + typedef int _woff2tags_dummy; + +#endif /* !FT_CONFIG_OPTION_USE_BROTLI */ + /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/woff2tags.h b/Build/source/libs/freetype2/freetype-src/src/sfnt/woff2tags.h index 543daf89111..4ef0a651c3e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/woff2tags.h +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/woff2tags.h @@ -2,7 +2,7 @@ * * woff2tags.h * - * WOFFF2 Font table tags (specification). + * WOFF2 Font table tags (specification). * * Copyright (C) 2019-2021 by * Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg. @@ -26,10 +26,12 @@ FT_BEGIN_HEADER +#ifdef FT_CONFIG_OPTION_USE_BROTLI - FT_LOCAL( FT_ULong ) + FT_LOCAL( FT_Tag ) woff2_known_tags( FT_Byte index ); +#endif FT_END_HEADER |