summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Röttsches <drott@chromium.org>2022-08-19 19:07:42 +0300
committerWerner Lemberg <wl@gnu.org>2022-09-05 10:36:22 +0200
commita1017e2655360923227f4e8a261497a93867a9a6 (patch)
treec495308bc69d966bff0f960b468ad9e549d0fdf6
parentdd91f6e7f5a051818070c49715125fb72074023e (diff)
downloadfreetype2-a1017e2655360923227f4e8a261497a93867a9a6.tar.gz
[sfnt] Don't require 'gvar' table to support variation fonts.
Fixes #1172. * src/sfnt/sfobjs.c (sfnt_load_face): Tag font as Multiple Masters font if `fvar` is present; do not require other tables to be present. * src/truetype/ttgxvar.c (tt_set_mm_blend): Allow for a missing 'gvar' table when setting variation coordinates. However, if a 'gvar' table is actually present, do perform a sanity check and fail on malformedness. (TT_Get_MM_Var): Don't assume 'fvar' needs 'gvar' or 'CFF2 tables in all cases, which is an overly tight check.
-rw-r--r--src/sfnt/sfobjs.c8
-rw-r--r--src/truetype/ttgxvar.c24
2 files changed, 10 insertions, 22 deletions
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index a0da984e7..2f87d2429 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -1107,13 +1107,7 @@
/* Don't bother to load the tables unless somebody asks for them. */
/* No need to do work which will (probably) not be used. */
if ( face->variation_support & TT_FACE_FLAG_VAR_FVAR )
- {
- if ( tt_face_lookup_table( face, TTAG_glyf ) != 0 &&
- tt_face_lookup_table( face, TTAG_gvar ) != 0 )
- flags |= FT_FACE_FLAG_MULTIPLE_MASTERS;
- if ( tt_face_lookup_table( face, TTAG_CFF2 ) != 0 )
- flags |= FT_FACE_FLAG_MULTIPLE_MASTERS;
- }
+ flags |= FT_FACE_FLAG_MULTIPLE_MASTERS;
#endif
root->face_flags = flags;
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 6cb2cc9f8..180f5fbe2 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -2217,20 +2217,6 @@
{
FT_TRACE2(( "FVAR " ));
- /* both `fvar' and `gvar' must be present */
- if ( FT_SET_ERROR( face->goto_table( face, TTAG_gvar,
- stream, &table_len ) ) )
- {
- /* CFF2 is an alternate to gvar here */
- if ( FT_SET_ERROR( face->goto_table( face, TTAG_CFF2,
- stream, &table_len ) ) )
- {
- FT_TRACE1(( "\n" ));
- FT_TRACE1(( "TT_Get_MM_Var: `gvar' or `CFF2' table is missing\n" ));
- goto Exit;
- }
- }
-
if ( FT_SET_ERROR( face->goto_table( face, TTAG_fvar,
stream, &table_len ) ) )
{
@@ -2673,8 +2659,16 @@
FT_TRACE5(( "\n" ));
if ( !face->is_cff2 && !blend->glyphoffsets )
- if ( FT_SET_ERROR( ft_var_load_gvar( face ) ) )
+ {
+ /* While a missing 'gvar' table is acceptable, for example for */
+ /* fonts that only vary metrics information or 'COLR' v1 */
+ /* `PaintVar*` tables, an incorrect SFNT table offset or size */
+ /* for 'gvar', or an inconsistent 'gvar' table is not. */
+ error = ft_var_load_gvar( face );
+ if ( error != FT_Err_Table_Missing && error != FT_Err_Ok )
goto Exit;
+ error = FT_Err_Ok;
+ }
if ( !blend->coords )
{