diff --git a/third_party/freetype/BUILD.gn b/third_party/freetype/BUILD.gn index 92d43c6e742f..95e4c8a90a3c 100644 --- a/third_party/freetype/BUILD.gn +++ b/third_party/freetype/BUILD.gn @@ -140,6 +140,12 @@ source_set("freetype_source") { defines += [ "FT2_BUILD_LIBRARY" ] + if (use_system_harfbuzz) { + configs += [ "//third_party/harfbuzz-ng:harfbuzz_from_pkgconfig" ] + } else { + configs += [ "//third_party/harfbuzz-ng:harfbuzz_config" ] + } + configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] configs += [ "//build/config/sanitizers:cfi_icall_generalize_pointers" ] configs += [ ":freetype-warnings" ] diff --git a/third_party/freetype/METADATA b/third_party/freetype/METADATA index 66f02f02b837..1eeff65303ba 100644 --- a/third_party/freetype/METADATA +++ b/third_party/freetype/METADATA @@ -1,12 +1,12 @@ third_party { identifier { type: "ChromiumVersion" - value: "112.0.5615.134" # from https://chromereleases.googleblog.com/2023/04/stable-channel-update-for-chromeos_19.html + value: "114.0.5735.358" # from https://chromereleases.googleblog.com/2024/03/long-term-support-channel-update-for_26.html } identifier { type: "Git" value: "https://chromium.googlesource.com/chromium/src.git" - version: "53b87ba394bbdcf2f9d63e985ca5385a5b420ca9" + version: "1759c6ae9316996b9f150c0ce9d0ca78a3d15c02" } identifier { type: "UpstreamSubdir" diff --git a/third_party/freetype/README.chromium b/third_party/freetype/README.chromium index 58630e40d5ab..703c7d3fecf1 100644 --- a/third_party/freetype/README.chromium +++ b/third_party/freetype/README.chromium @@ -1,8 +1,8 @@ Name: FreeType URL: http://www.freetype.org/ -Version: VER-2-13-0-69 -Revision: e78e2d29a95baf6053e30cc9422aa20319259803 -CPEPrefix: cpe:/a:freetype:freetype:2.13.0 +Version: VER-2-13-0-76-g0a3836c97 +Revision: 0a3836c97d5e84d6721ac0fd2839e8ae1b7be8d9 +CPEPrefix: cpe:/a:freetype:freetype:2.12.1 License: Custom license "inspired by the BSD, Artistic, and IJG (Independent JPEG Group) licenses" License File: src/docs/FTL.TXT diff --git a/third_party/freetype/src/METADATA b/third_party/freetype/src/METADATA index 585ae0c96a91..0ad64e096aac 100644 --- a/third_party/freetype/src/METADATA +++ b/third_party/freetype/src/METADATA @@ -5,13 +5,13 @@ description: third_party { identifier { type: "ChromiumVersion" - value: "112.0.5615.134" # from https://chromereleases.googleblog.com/2023/04/stable-channel-update-for-chromeos_19.html + value: "114.0.5735.358" # from https://chromereleases.googleblog.com/2024/03/long-term-support-channel-update-for_26.html } identifier { type: "Git" value: "https://chromium.googlesource.com/chromium/src/third_party/freetype2.git" - version: "e78e2d29a95baf6053e30cc9422aa20319259803" - # from https://chromium.googlesource.com/chromium/src/+/112.0.5615.134/DEPS#353 + version: "0a3836c97d5e84d6721ac0fd2839e8ae1b7be8d9" + # from https://chromium.googlesource.com/chromium/src/+/114.0.5735.358/DEPS#347 } last_upgrade_date { year: 2023 diff --git a/third_party/freetype/src/include/freetype/freetype.h b/third_party/freetype/src/include/freetype/freetype.h index efff74fe399e..e855e6cb64f8 100644 --- a/third_party/freetype/src/include/freetype/freetype.h +++ b/third_party/freetype/src/include/freetype/freetype.h @@ -1002,7 +1002,7 @@ FT_BEGIN_HEADER * Note that the bounding box might be off by (at least) one pixel for * hinted fonts. See @FT_Size_Metrics for further discussion. * - * Note that the bounding box does not vary in OpenType variable fonts + * Note that the bounding box does not vary in OpenType variation fonts * and should only be used in relation to the default instance. * * units_per_EM :: @@ -1090,9 +1090,9 @@ FT_BEGIN_HEADER FT_Generic generic; - /*# The following member variables (down to `underline_thickness`) */ - /*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size */ - /*# for bitmap fonts. */ + /* The following member variables (down to `underline_thickness`) */ + /* are only relevant to scalable outlines; cf. @FT_Bitmap_Size */ + /* for bitmap fonts. */ FT_BBox bbox; FT_UShort units_per_EM; @@ -1110,7 +1110,7 @@ FT_BEGIN_HEADER FT_Size size; FT_CharMap charmap; - /*@private begin */ + /* private fields, internal to FreeType */ FT_Driver driver; FT_Memory memory; @@ -1123,8 +1123,6 @@ FT_BEGIN_HEADER FT_Face_Internal internal; - /*@private end */ - } FT_FaceRec; diff --git a/third_party/freetype/src/include/freetype/internal/services/svmetric.h b/third_party/freetype/src/include/freetype/internal/services/svmetric.h index d067dc977cc9..167617ebb3d0 100644 --- a/third_party/freetype/src/include/freetype/internal/services/svmetric.h +++ b/third_party/freetype/src/include/freetype/internal/services/svmetric.h @@ -77,7 +77,7 @@ FT_BEGIN_HEADER typedef void (*FT_Metrics_Adjust_Func)( FT_Face face ); - typedef void + typedef FT_Error (*FT_Size_Reset_Func)( FT_Size size ); diff --git a/third_party/freetype/src/src/cid/cidgload.c b/third_party/freetype/src/src/cid/cidgload.c index ba4b7565d547..66e298331609 100644 --- a/third_party/freetype/src/src/cid/cidgload.c +++ b/third_party/freetype/src/src/cid/cidgload.c @@ -117,11 +117,44 @@ off2 = cid_get_offset( &p, cid->gd_bytes ); FT_FRAME_EXIT(); - if ( fd_select >= cid->num_dicts || - off2 > stream->size || - off1 > off2 ) + + if ( fd_select >= cid->num_dicts ) { - FT_TRACE0(( "cid_load_glyph: invalid glyph stream offsets\n" )); + /* + * fd_select == 0xFF is often used to indicate that the CID + * has no charstring to be rendered, similar to GID = 0xFFFF + * in TrueType fonts. + */ + if ( (cid->fd_bytes == 1 && fd_select == 0xFFU ) || + (cid->fd_bytes == 2 && fd_select == 0xFFFFU ) ) + { + FT_TRACE1(( "cid_load_glyph: fail for glyph_index=%d, " + "FD number %d is the max integer fitting into %d byte%s\n", + glyph_index, fd_select, cid->fd_bytes, + cid->fd_bytes == 1 ? "" : "s" )); + } + else + { + FT_TRACE0(( "cid_load_glyph: fail for glyph_index=%d, " + "FD number %d > number of dicts %d\n", + glyph_index, fd_select, cid->num_dicts )); + } + error = FT_THROW( Invalid_Offset ); + goto Exit; + } + else if ( off2 > stream->size ) + { + FT_TRACE0(( "cid_load_glyph: fail for glyph_index=%d, " + "end of the glyph data is beyond the data stream\n", + glyph_index )); + error = FT_THROW( Invalid_Offset ); + goto Exit; + } + else if ( off1 > off2 ) + { + FT_TRACE0(( "cid_load_glyph: fail for glyph_index=%d, " + "the end position of glyph data is set before the start position\n", + glyph_index )); error = FT_THROW( Invalid_Offset ); goto Exit; } @@ -161,7 +194,9 @@ cs_offset = decoder->lenIV >= 0 ? (FT_UInt)decoder->lenIV : 0; if ( cs_offset > glyph_length ) { - FT_TRACE0(( "cid_load_glyph: invalid glyph stream offsets\n" )); + FT_TRACE0(( "cid_load_glyph: fail for glyph_index=%d, " + "offset to the charstring is beyond glyph length\n", + glyph_index )); error = FT_THROW( Invalid_Offset ); goto Exit; } diff --git a/third_party/freetype/src/src/sfnt/sfdriver.c b/third_party/freetype/src/src/sfnt/sfdriver.c index 762883db5420..70c63417b3ef 100644 --- a/third_party/freetype/src/src/sfnt/sfdriver.c +++ b/third_party/freetype/src/src/sfnt/sfdriver.c @@ -523,15 +523,14 @@ FT_TRACE0(( "get_win_string:" " Character 0x%X invalid in PS name string\n", ((unsigned)p[0])*256 + (unsigned)p[1] )); - break; + continue; } } - if ( !len ) - *r = '\0'; + *r = '\0'; FT_FRAME_EXIT(); - if ( !len ) + if ( r != result ) return result; get_win_string_error: @@ -580,15 +579,14 @@ FT_TRACE0(( "get_apple_string:" " Character `%c' (0x%X) invalid in PS name string\n", *p, *p )); - break; + continue; } } - if ( !len ) - *r = '\0'; + *r = '\0'; FT_FRAME_EXIT(); - if ( !len ) + if ( r != result ) return result; get_apple_string_error: @@ -819,9 +817,9 @@ if ( !found ) { - /* as a last resort we try the family name; note that this is */ - /* not in the Adobe TechNote, but GX fonts (which predate the */ - /* TechNote) benefit from this behaviour */ + /* according to the 'name' documentation in the OpenType */ + /* specification the font family name is to be used if the */ + /* typographic family name is missing, so let's do that */ found = sfnt_get_name_id( face, TT_NAME_ID_FONT_FAMILY, &win, @@ -853,6 +851,10 @@ { FT_TRACE0(( "sfnt_get_var_ps_name:" " No valid PS name prefix for font instances found\n" )); + /* XXX It probably makes sense to never let this fail */ + /* since an arbitrary prefix should work, too. */ + /* On the other hand, it is very unlikely that */ + /* we ever reach this code at all. */ return NULL; } diff --git a/third_party/freetype/src/src/truetype/ttgxvar.c b/third_party/freetype/src/src/truetype/ttgxvar.c index 3af028aac9d7..80553c93aebd 100644 --- a/third_party/freetype/src/src/truetype/ttgxvar.c +++ b/third_party/freetype/src/src/truetype/ttgxvar.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include diff --git a/third_party/freetype/src/src/truetype/ttinterp.c b/third_party/freetype/src/src/truetype/ttinterp.c index 8cf66ebaecc7..c6a6cde6b51c 100644 --- a/third_party/freetype/src/src/truetype/ttinterp.c +++ b/third_party/freetype/src/src/truetype/ttinterp.c @@ -7321,14 +7321,6 @@ * GETINFO[]: GET INFOrmation * Opcode range: 0x88 * Stack: uint32 --> uint32 - * - * XXX: UNDOCUMENTED: Selector bits higher than 9 are currently (May - * 2015) not documented in the OpenType specification. - * - * Selector bit 11 is incorrectly described as bit 8, while the - * real meaning of bit 8 (vertical LCD subpixels) stays - * undocumented. The same mistake can be found in Greg Hitchcock's - * whitepaper. */ static void Ins_GETINFO( TT_ExecContext exc, @@ -7387,8 +7379,6 @@ * VARIATION GLYPH * Selector Bit: 3 * Return Bit(s): 10 - * - * XXX: UNDOCUMENTED! */ if ( (args[0] & 8 ) != 0 && exc->face->blend ) K |= 1 << 10; diff --git a/third_party/freetype/src/src/truetype/ttobjs.c b/third_party/freetype/src/src/truetype/ttobjs.c index ee4f3de1bba9..c351e082b606 100644 --- a/third_party/freetype/src/src/truetype/ttobjs.c +++ b/third_party/freetype/src/src/truetype/ttobjs.c @@ -1346,12 +1346,16 @@ * Used for variation fonts as an iterator function. * * @Input: - * size :: - * A handle to the target size object. + * ft_size :: + * A handle to the target TT_Size object. This function will be called + * through a `FT_Size_Reset_Func` pointer which takes `FT_Size`. This + * function must take `FT_Size` as a result. The passed `FT_Size` is + * expected to point to a `TT_Size`. */ FT_LOCAL_DEF( FT_Error ) - tt_size_reset_height( TT_Size size ) + tt_size_reset_height( FT_Size ft_size ) { + TT_Size size = (TT_Size)ft_size; TT_Face face = (TT_Face)size->root.face; FT_Size_Metrics* size_metrics = &size->hinted_metrics; @@ -1408,7 +1412,7 @@ FT_Size_Metrics* size_metrics = &size->hinted_metrics; - error = tt_size_reset_height( size ); + error = tt_size_reset_height( (FT_Size)size ); if ( error ) return error; diff --git a/third_party/freetype/src/src/truetype/ttobjs.h b/third_party/freetype/src/src/truetype/ttobjs.h index d74264e57930..d1834c046f31 100644 --- a/third_party/freetype/src/src/truetype/ttobjs.h +++ b/third_party/freetype/src/src/truetype/ttobjs.h @@ -391,7 +391,7 @@ FT_BEGIN_HEADER #endif /* TT_USE_BYTECODE_INTERPRETER */ FT_LOCAL( FT_Error ) - tt_size_reset_height( TT_Size size ); + tt_size_reset_height( FT_Size size ); FT_LOCAL( FT_Error ) tt_size_reset( TT_Size size );