Werner Lemberg pushed to branch master at FreeType / FreeType
Commits:
-
54c5ad5c
by Dominik Röttsches at 2021-02-11T14:20:03+01:00
3 changed files:
Changes:
1 |
+2021-02-10 Dominik Röttsches <drott@chromium.org>
|
|
2 |
+ |
|
3 |
+ [sfnt] Implement 'COLR' v1 sweep gradients.
|
|
4 |
+ |
|
5 |
+ * freetype.h (FT_PaintSweepGradient): Add `FT_PaintSweepGradient` to
|
|
6 |
+ represent a 'COLR' v1 sweep gradient.
|
|
7 |
+ Update format.
|
|
8 |
+ (FT_PaintFormat): Update shifted paint formats.
|
|
9 |
+ Sync with spec.
|
|
10 |
+ * sfnt/ttcolr.c (read_paint): Logic to parse sweep gradients.
|
|
11 |
+ Fix struct access in radial gradient implementation.
|
|
12 |
+ |
|
1 | 13 |
2021-02-09 Dominik Röttsches <drott@chromium.org>
|
2 | 14 |
|
3 | 15 |
[sfnt] Provide optional root transform for 'COLR' v1 glyph graph.
|
... | ... | @@ -4235,14 +4235,15 @@ FT_BEGIN_HEADER |
4235 | 4235 |
FT_COLR_PAINTFORMAT_SOLID = 2,
|
4236 | 4236 |
FT_COLR_PAINTFORMAT_LINEAR_GRADIENT = 3,
|
4237 | 4237 |
FT_COLR_PAINTFORMAT_RADIAL_GRADIENT = 4,
|
4238 |
- FT_COLR_PAINTFORMAT_GLYPH = 5,
|
|
4239 |
- FT_COLR_PAINTFORMAT_COLR_GLYPH = 6,
|
|
4240 |
- FT_COLR_PAINTFORMAT_TRANSFORMED = 7,
|
|
4241 |
- FT_COLR_PAINTFORMAT_TRANSLATE = 8,
|
|
4242 |
- FT_COLR_PAINTFORMAT_ROTATE = 9,
|
|
4243 |
- FT_COLR_PAINTFORMAT_SKEW = 10,
|
|
4244 |
- FT_COLR_PAINTFORMAT_COMPOSITE = 11,
|
|
4245 |
- FT_COLR_PAINT_FORMAT_MAX = 12,
|
|
4238 |
+ FT_COLR_PAINTFORMAT_SWEEP_GRADIENT = 5,
|
|
4239 |
+ FT_COLR_PAINTFORMAT_GLYPH = 6,
|
|
4240 |
+ FT_COLR_PAINTFORMAT_COLR_GLYPH = 7,
|
|
4241 |
+ FT_COLR_PAINTFORMAT_TRANSFORMED = 8,
|
|
4242 |
+ FT_COLR_PAINTFORMAT_TRANSLATE = 9,
|
|
4243 |
+ FT_COLR_PAINTFORMAT_ROTATE = 10,
|
|
4244 |
+ FT_COLR_PAINTFORMAT_SKEW = 11,
|
|
4245 |
+ FT_COLR_PAINTFORMAT_COMPOSITE = 12,
|
|
4246 |
+ FT_COLR_PAINT_FORMAT_MAX = 13,
|
|
4246 | 4247 |
FT_COLR_PAINTFORMAT_UNSUPPORTED = 255
|
4247 | 4248 |
|
4248 | 4249 |
} FT_PaintFormat;
|
... | ... | @@ -4611,7 +4612,6 @@ FT_BEGIN_HEADER |
4611 | 4612 |
{
|
4612 | 4613 |
FT_ColorLine colorline;
|
4613 | 4614 |
|
4614 |
- /* TODO: Potentially expose those as x0, y0 etc. */
|
|
4615 | 4615 |
FT_Vector c0;
|
4616 | 4616 |
FT_UShort r0;
|
4617 | 4617 |
FT_Vector c1;
|
... | ... | @@ -4620,6 +4620,48 @@ FT_BEGIN_HEADER |
4620 | 4620 |
} FT_PaintRadialGradient;
|
4621 | 4621 |
|
4622 | 4622 |
|
4623 |
+ /**************************************************************************
|
|
4624 |
+ *
|
|
4625 |
+ * @struct:
|
|
4626 |
+ * FT_PaintSweepGradient
|
|
4627 |
+ *
|
|
4628 |
+ * @description:
|
|
4629 |
+ * A structure representing a `PaintSweepGradient` value of the 'COLR'
|
|
4630 |
+ * v1 extensions, see
|
|
4631 |
+ * 'https://github.com/googlefonts/colr-gradients-spec'. The glyph
|
|
4632 |
+ * layer filled with this paint is drawn filled with a sweep gradient
|
|
4633 |
+ * from `start_angle` to `end_angle`.
|
|
4634 |
+ *
|
|
4635 |
+ * @fields:
|
|
4636 |
+ * colorline ::
|
|
4637 |
+ * The @FT_ColorLine information for this paint, i.e., the list of
|
|
4638 |
+ * color stops along the gradient.
|
|
4639 |
+ *
|
|
4640 |
+ * center ::
|
|
4641 |
+ * The center of the sweep gradient (in font units).
|
|
4642 |
+ *
|
|
4643 |
+ * start_angle ::
|
|
4644 |
+ * The start angle of the sweep gradient, in 16.16 fixed point format
|
|
4645 |
+ * specifying degrees. Values are given counter-clockwise, starting
|
|
4646 |
+ * from the (positive) y~axis.
|
|
4647 |
+ *
|
|
4648 |
+ * end_angle ::
|
|
4649 |
+ * The end angle of the sweep gradient, in 16.16 fixed point format
|
|
4650 |
+ * specifying degrees. Values are given counter-clockwise, starting
|
|
4651 |
+ * from the (positive) y~axis.
|
|
4652 |
+ *
|
|
4653 |
+ */
|
|
4654 |
+ typedef struct FT_PaintSweepGradient_
|
|
4655 |
+ {
|
|
4656 |
+ FT_ColorLine colorline;
|
|
4657 |
+ |
|
4658 |
+ FT_Vector center;
|
|
4659 |
+ FT_Fixed start_angle;
|
|
4660 |
+ FT_Fixed end_angle;
|
|
4661 |
+ |
|
4662 |
+ } FT_PaintSweepGradient;
|
|
4663 |
+ |
|
4664 |
+ |
|
4623 | 4665 |
/**************************************************************************
|
4624 | 4666 |
*
|
4625 | 4667 |
* @struct:
|
... | ... | @@ -4853,6 +4895,7 @@ FT_BEGIN_HEADER |
4853 | 4895 |
* * @FT_PaintSolid
|
4854 | 4896 |
* * @FT_PaintLinearGradient
|
4855 | 4897 |
* * @FT_PaintRadialGradient
|
4898 |
+ * * @FT_PaintSweepGradient
|
|
4856 | 4899 |
* * @FT_PaintTransformed
|
4857 | 4900 |
* * @FT_PaintTranslate
|
4858 | 4901 |
* * @FT_PaintRotate
|
... | ... | @@ -4871,6 +4914,7 @@ FT_BEGIN_HEADER |
4871 | 4914 |
FT_PaintSolid solid;
|
4872 | 4915 |
FT_PaintLinearGradient linear_gradient;
|
4873 | 4916 |
FT_PaintRadialGradient radial_gradient;
|
4917 |
+ FT_PaintSweepGradient sweep_gradient;
|
|
4874 | 4918 |
FT_PaintTransformed transformed;
|
4875 | 4919 |
FT_PaintTranslate translate;
|
4876 | 4920 |
FT_PaintRotate rotate;
|
... | ... | @@ -441,7 +441,7 @@ |
441 | 441 |
|
442 | 442 |
if ( !read_color_line( paint_base,
|
443 | 443 |
color_line_offset,
|
444 |
- &apaint->u.linear_gradient.colorline ) )
|
|
444 |
+ &apaint->u.radial_gradient.colorline ) )
|
|
445 | 445 |
return 0;
|
446 | 446 |
|
447 | 447 |
/* skip VarIdx entries */
|
... | ... | @@ -462,6 +462,28 @@ |
462 | 462 |
FT_NEXT_ULONG ( p );
|
463 | 463 |
}
|
464 | 464 |
|
465 |
+ else if ( apaint->format == FT_COLR_PAINTFORMAT_SWEEP_GRADIENT )
|
|
466 |
+ {
|
|
467 |
+ FT_ULong color_line_offset = color_line_offset = FT_NEXT_OFF3( p );
|
|
468 |
+ |
|
469 |
+ |
|
470 |
+ if ( !read_color_line( paint_base,
|
|
471 |
+ color_line_offset,
|
|
472 |
+ &apaint->u.sweep_gradient.colorline ) )
|
|
473 |
+ return 0;
|
|
474 |
+ |
|
475 |
+ /* skip VarIdx entries */
|
|
476 |
+ apaint->u.sweep_gradient.center.x = FT_NEXT_SHORT ( p );
|
|
477 |
+ FT_NEXT_ULONG ( p );
|
|
478 |
+ apaint->u.sweep_gradient.center.y = FT_NEXT_SHORT ( p );
|
|
479 |
+ FT_NEXT_ULONG ( p );
|
|
480 |
+ |
|
481 |
+ apaint->u.sweep_gradient.start_angle = FT_NEXT_LONG( p );
|
|
482 |
+ FT_NEXT_ULONG ( p );
|
|
483 |
+ apaint->u.sweep_gradient.end_angle = FT_NEXT_LONG( p );
|
|
484 |
+ FT_NEXT_ULONG ( p );
|
|
485 |
+ }
|
|
486 |
+ |
|
465 | 487 |
else if ( apaint->format == FT_COLR_PAINTFORMAT_TRANSFORMED )
|
466 | 488 |
{
|
467 | 489 |
FT_UInt32 paint_offset;
|
... | ... | @@ -842,7 +864,7 @@ |
842 | 864 |
|
843 | 865 |
/* `x_scale` and `y_scale` are in 26.6 format, representing the scale
|
844 | 866 |
* factor to get from font units to requested size. However, expected
|
845 |
- * return values are in 16.16, so we shift accordingly with rounding.
|
|
867 |
+ * return values are in 16.16, so we shift accordingly with rounding.
|
|
846 | 868 |
*/
|
847 | 869 |
ft_root_scale.xx = ( face->root.size->metrics.x_scale + 32 ) >> 6;
|
848 | 870 |
ft_root_scale.xy = 0;
|