691a794bee
Implement support for COLRv1 color gradient vector forms. COLR v1 is an extension to the OpenType COLR tables that introduces support for gradients, transforms and compositing. [1] COLRv1 fonts contain an OpenType COLR table with format v1. In a COLR v1 table, glyphs are defined by a directed, acyclic graph of Paint operations. The task for the Skia implementation is to extract the COLR v1 information from the font using FreeType's COLRv1 API, then traverse the glyph graph and translate information from the font into Skia operations on SkCanvas. Care needs to be taken for transformations to work correctly. FreeType sends a top level transform that includes the scaling from font units to actual glyph size, as well as optional transforms configured on FreeType using FT_Set_Transform. This is set up as the starting transform at the beginning of drawing a COLRv1 glyph. At the stage of setting a clip for a PaintGlyph operation, the glyph outline is retrieved from FreeType unscaled and untransformed. Since the starting transformation is applied to the SkCanvas, the unscaled glyph is properly scaled and positioned. Similarly, computing the initial bounding box for the COLRv1 glyph needs to consider transformations. COLRv1 glyphs have a base glyph entry in the glyf table which can use a minimum of two points for defining a bounding box. This bounding box is an imaged rectangle enclosing those two points at the identity transform. We need to compute the bounding box scaled, but at identity transform, then make a rectangle from it, that we then transform so that we get a large enough area to paint in. If those two points from the glyf table would be transformed first, then we would compute the bounding box, the resulting bounding box ends up too small. As a test font, add a version of the samples-glyf_colr_1.ttf from [2] with one glyph added for testing PaintColrGlyph functionality and compositions. Add a basic GM test that produces color glyphs untransformed, with skew and with rotation and combinations of those. [1] https://github.com/googlefonts/colr-gradients-spec/ [2] https://github.com/googlefonts/color-fonts Bug: skia:11264 Change-Id: I8357cd0c7ac0039bb2eac18f21fa343bf61871eb Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300558 Commit-Queue: Dominik Röttsches <drott@chromium.org> Commit-Queue: Ben Wagner <bungeman@google.com> Auto-Submit: Dominik Röttsches <drott@chromium.org> Reviewed-by: Ben Wagner <bungeman@google.com> |
||
---|---|---|
.. | ||
abc | ||
svg | ||
7630.otf | ||
ahem.ttf | ||
cbdt.ttf | ||
colr.ttf | ||
colrv1_samples.ttf | ||
Distortable.ttf | ||
Em.ttf | ||
fonts.xml | ||
Funkster.ttf | ||
HangingS.ttf | ||
hintgasp.ttf | ||
planetcbdt.ttf | ||
planetcolr.ttf | ||
planetsbix.ttf | ||
ReallyBigA.ttf | ||
Roboto2-Regular_NoEmbed.ttf | ||
Roboto2-Regular.pfa | ||
Roboto2-Regular.pfb | ||
Roboto-Regular.ttf | ||
sbix.ttf | ||
SpiderSymbol.ttf | ||
Stroking.otf | ||
Stroking.ttf | ||
test.ttc | ||
Variable.ttf | ||
VaryAlongQuads.ttf |