summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Röttsches <drott@chromium.org>2022-07-05 14:43:10 +0300
committerWerner Lemberg <wl@gnu.org>2022-07-09 05:41:27 +0200
commit9c4ad2a901bebd79ecaea42584193fb04c3619fa (patch)
treea597da6f6fca59e4aa3db7e512bc648b0ac04f23
parent3414fef74f9dd1858aca521f93ebadca9ab36f96 (diff)
downloadfreetype2-9c4ad2a901bebd79ecaea42584193fb04c3619fa.tar.gz
[sfnt] Deltas for 'COLR' v1 gradient coordinates.
* src/sfnt/ttcolr.c (read_paint) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Read and apply deltas to radial, linear, and sweep gradient coordinates such as 'p0', 'p1', 'p2', 'center', 'radii', and 'angles'.
-rw-r--r--src/sfnt/ttcolr.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/sfnt/ttcolr.c b/src/sfnt/ttcolr.c
index e8a3d65ac..a380719f8 100644
--- a/src/sfnt/ttcolr.c
+++ b/src/sfnt/ttcolr.c
@@ -718,6 +718,24 @@
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 ) );
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+ if ( do_read_var && VARIABLE_COLRV1_ENABLED )
+ {
+ var_index_base = FT_NEXT_ULONG ( p );
+
+ if ( !get_deltas_for_var_index_base( face, colr, var_index_base, 6,
+ item_deltas ) )
+ return 0;
+
+ apaint->u.linear_gradient.p0.x += INT_TO_FIXED( item_deltas[0] );
+ apaint->u.linear_gradient.p0.y += INT_TO_FIXED( item_deltas[1] );
+ apaint->u.linear_gradient.p1.x += INT_TO_FIXED( item_deltas[2] );
+ apaint->u.linear_gradient.p1.y += INT_TO_FIXED( item_deltas[3] );
+ apaint->u.linear_gradient.p2.x += INT_TO_FIXED( item_deltas[4] );
+ apaint->u.linear_gradient.p2.y += INT_TO_FIXED( item_deltas[5] );
+ }
+#endif
+
apaint->format = FT_COLR_PAINTFORMAT_LINEAR_GRADIENT;
return 1;
@@ -753,6 +771,28 @@
tmp = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
apaint->u.radial_gradient.r1 = tmp < 0 ? FT_INT_MAX : tmp;
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+ if ( do_read_var && VARIABLE_COLRV1_ENABLED )
+ {
+ var_index_base = FT_NEXT_ULONG ( p );
+
+ if ( !get_deltas_for_var_index_base( face, colr, var_index_base, 6,
+ item_deltas ) )
+ return 0;
+
+ apaint->u.radial_gradient.c0.x += INT_TO_FIXED( item_deltas[0] );
+ apaint->u.radial_gradient.c0.y += INT_TO_FIXED( item_deltas[1] );
+
+ // TODO: Anything to be done about UFWORD deltas here?
+ apaint->u.radial_gradient.r0 += INT_TO_FIXED( item_deltas[2] );
+
+ apaint->u.radial_gradient.c1.x += INT_TO_FIXED( item_deltas[3] );
+ apaint->u.radial_gradient.c1.y += INT_TO_FIXED( item_deltas[4] );
+
+ apaint->u.radial_gradient.r1 += INT_TO_FIXED( item_deltas[5] );
+ }
+#endif
+
apaint->format = FT_COLR_PAINTFORMAT_RADIAL_GRADIENT;
return 1;
@@ -778,6 +818,25 @@
apaint->u.sweep_gradient.end_angle =
F2DOT14_TO_FIXED( FT_NEXT_SHORT( p ) );
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+ if ( do_read_var && VARIABLE_COLRV1_ENABLED )
+ {
+ var_index_base = FT_NEXT_ULONG ( p );
+
+ if ( !get_deltas_for_var_index_base( face, colr, var_index_base, 4,
+ item_deltas ) )
+ return 0;
+
+ // TODO: Handle overflow?
+ apaint->u.sweep_gradient.center.x += INT_TO_FIXED( item_deltas[0] );
+ apaint->u.sweep_gradient.center.y += INT_TO_FIXED( item_deltas[1] );
+
+ apaint->u.sweep_gradient.start_angle +=
+ F2DOT14_TO_FIXED( item_deltas[2] );
+ apaint->u.sweep_gradient.end_angle +=
+ F2DOT14_TO_FIXED( item_deltas[3] );
+ }
+#endif
apaint->format = FT_COLR_PAINTFORMAT_SWEEP_GRADIENT;
return 1;