26#if defined(SK_TYPEFACE_FACTORY_FONTATIONS)
31#include <initializer_list>
36const SkScalar kTextSizes[] = {12, 18, 30, 120};
37const char kTestFontName[] =
"fonts/test_glyphs-glyf_colr_1.ttf";
38const char kTestFontNameVariable[] =
"fonts/test_glyphs-glyf_colr_1_variable.ttf";
49 std::initializer_list<SkFontArguments::VariationPosition::Coordinate>
51 : fTestName(
testName), fCodepoints(codepoints), fSkewX(skewX), fRotateDeg(rotateDeg) {
53 fCoordinates = std::make_unique<SkFontArguments::VariationPosition::Coordinate[]>(
54 specifiedVariations.size());
55 for (
size_t i = 0;
i < specifiedVariations.size(); ++
i) {
56 fCoordinates[
i] =
std::data(specifiedVariations)[
i];
59 fVariationPosition.
coordinates = fCoordinates.get();
104 if (fTestName.
equals(
"sweep_varsweep")) {
117 static_cast<int>(coords.
size())};
119 args.setVariationDesignPosition(varPos);
130 *errorMsg =
"Did not recognize COLR v1 font format.";
134 canvas->
rotate(fRotateDeg);
135 canvas->
skew(fSkewX, 0);
141 std::vector<SkColor> paint_colors = {
143 auto paint_color_iterator = paint_colors.begin();
144 for (
SkScalar textSize : kTextSizes) {
145 font.setSize(textSize);
146 font.getMetrics(&metrics);
150 paint.setColor(*paint_color_iterator);
153 for (
size_t i = 0;
i < fCodepoints.
size(); ++
i) {
167 x += glyphAdvance + glyphAdvance * 0.05f;
169 paint_color_iterator++;
175 using INHERITED =
GM;
182 std::unique_ptr<SkFontArguments::VariationPosition::Coordinate[]> fCoordinates;
191namespace ColrV1TestDefinitions {
194 0xf0200, 0xf0201, 0xf0202, 0xf0203, 0xf0204, 0xf0205, 0xf0206, 0xf0207, 0xf0208,
195 0xf0209, 0xf020a, 0xf020b, 0xf020c, 0xf020d, 0xf020e, 0xf020f, 0xf0210, 0xf0211,
196 0xf0212, 0xf0213, 0xf0214, 0xf0215, 0xf0216, 0xf0217, 0xf0218, 0xf0219, 0xf021a,
197 0xf021b, 0xf021c, 0xf021d, 0xf021e, 0xf021f, 0xf0220, 0xf0221, 0xf0222, 0xf0223,
198 0xf0224, 0xf0225, 0xf0226, 0xf0227, 0xf0228, 0xf0229, 0xf022a, 0xf022b, 0xf022c,
199 0xf022d, 0xf022e, 0xf022f, 0xf0230, 0xf0231, 0xf0232, 0xf0233, 0xf0234, 0xf0235,
200 0xf0236, 0xf0237, 0xf0238, 0xf0239, 0xf023a, 0xf023b, 0xf023c, 0xf023d, 0xf023e,
201 0xf023f, 0xf0240, 0xf0241, 0xf0242, 0xf0243, 0xf0244, 0xf0245, 0xf0246, 0xf0247};
202const uint32_t
paint_scale[] = {0xf0300, 0xf0301, 0xf0302, 0xf0303, 0xf0304, 0xf0305};
204 0xf0500, 0xf0501, 0xf0502, 0xf0503, 0xf0504, 0xf0505, 0xf0506, 0xf0507, 0xf0508};
206const uint32_t
paint_skew[] = {0xf0700, 0xf0701, 0xf0702, 0xf0703, 0xf0704, 0xf0705};
208const uint32_t
paint_translate[] = {0xf0900, 0xf0901, 0xf0902, 0xf0903, 0xf0904, 0xf0905, 0xf0906};
209const uint32_t
composite_mode[] = {0xf0a00, 0xf0a01, 0xf0a02, 0xf0a03, 0xf0a04, 0xf0a05, 0xf0a06,
210 0xf0a07, 0xf0a08, 0xf0a09, 0xf0a0a, 0xf0a0b, 0xf0a0c, 0xf0a0d,
211 0xf0a0e, 0xf0a0f, 0xf0a10, 0xf0a11, 0xf0a12, 0xf0a13, 0xf0a14,
212 0xf0a15, 0xf0a16, 0xf0a17, 0xf0a18, 0xf0a19, 0xf0a1a, 0xf0a1b};
214 0xf0b00, 0xf0b01, 0xf0b02, 0xf0b03, 0xf0b04, 0xf0b05, 0xf0b06, 0xf0b07};
215const uint32_t
clipbox[] = {0xf0c00, 0xf0c01, 0xf0c02, 0xf0c03, 0xf0c04};
220 0xf1306, 0xf1307, 0xf1308, 0xf1309, 0xf130a, 0xf130b,
221 0xf130c, 0xf130d, 0xf130e, 0xf130f, 0xf1310, 0xf1311,
222 0xf1312, 0xf1313, 0xf1314, 0xf1315, 0xf1316, 0xf1317};
224 0xf1404, 0xf1405, 0xf1406, 0xf1407,
225 0xf1408, 0xf1409, 0xf140a, 0xf140b,
226 0xf140c, 0xf140d, 0xf140e, 0xf140f };
232std::unique_ptr<ColrV1GM>
F(
237 std::initializer_list<SkFontArguments::VariationPosition::Coordinate> variations) {
238 return std::make_unique<ColrV1GM>(
name, codepoints, skewX, rotateDeg, variations);
248#define C(TEST_CATEGORY) #TEST_CATEGORY, ColrV1TestDefinitions::TEST_CATEGORY
265DEF_GM(return
F(
C(
extend_mode), 0.0
f, 0.0
f, {{
"GRX0"_t, -1000.f}, {
"GRX1"_t, -1000.f}, {
"GRR0"_t, -1000.f}, {
"GRR1"_t, -900.f}}))
267DEF_GM(return
F(
C(
extend_mode), 0.0
f, 0.0
f, {{
"GRX0"_t, 1000.f}, {
"GRX1"_t, -1000.f}, {
"GRR0"_t, -1000.f}, {
"GRR1"_t, 200.f}}))
269DEF_GM(return
F(
C(
extend_mode), 0.0
f, 0.0
f, {{
"GRR0"_t, -50.f}, {
"COL3"_t, -2.f}, {
"COL2"_t, -2.f}, {
"COL1"_t, -0.9f}}))
271DEF_GM(return
F(
C(
extend_mode), 0.0
f, 0.0
f, {{
"GRR0"_t, -50.f}, {
"COL3"_t, -2.f}, {
"COL2"_t, -2.f}, {
"COL1"_t, -1.1f}}))
313 {
"SWC2"_t, 0.083333333f},
314 {
"SWC3"_t, 0.083333333f},
315 {
"SWC4"_t, +0.25f}}))
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorGREEN
constexpr SkColor SK_ColorWHITE
@ kNone
glyph outlines unchanged
@ kUTF32
uses four byte words to represent all of Unicode
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
static constexpr SkFourByteTag SkSetFourByteTag(char a, char b, char c, char d)
void drawSimpleText(const void *text, size_t byteLength, SkTextEncoding encoding, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
void rotate(SkScalar degrees)
void skew(SkScalar sx, SkScalar sy)
constexpr T * data() const
constexpr size_t size() const
bool equals(const SkString &) const
void append(const char text[])
const char * c_str() const
sk_sp< SkTypeface > makeClone(const SkFontArguments &) const
void onSetControls(const SkMetaData &controls) override
bool onGetControls(SkMetaData *controls) override
ColrV1GM(const char *testName, SkSpan< const uint32_t > codepoints, SkScalar skewX, SkScalar rotateDeg, std::initializer_list< SkFontArguments::VariationPosition::Coordinate > specifiedVariations)
sk_sp< SkTypeface > makeVariedTypeface()
void onOnceBeforeDraw() override
DrawResult onDraw(SkCanvas *canvas, SkString *errorMsg) override
SkISize getISize() override
SkString getName() const override
GM(SkColor backgroundColor=SK_ColorWHITE)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
DEF_SWITCHES_START aot vmservice shared library name
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
font
Font Metadata and Metrics.
const uint32_t paint_transform[]
const uint32_t paintcolrglyph_cycle[]
const uint32_t paint_glyph_nested[]
const uint32_t gradient_stops_repeat[]
const uint32_t composite_mode[]
const uint32_t paint_translate[]
const uint32_t paint_skew[]
const uint32_t sweep_coincident[]
const uint32_t sweep_varsweep[]
const uint32_t paint_scale[]
const uint32_t variable_alpha[]
const uint32_t extend_mode[]
const uint32_t foreground_color[]
const uint32_t gradient_p2_skewed[]
const uint32_t paint_rotate[]
DEF_GM(return F(C(clipbox), 0.0f, 0.0f, {})) DEF_GM(return F(C(clipbox)
const Coordinate * coordinates
SkScalar fLeading
distance to add between lines, typically positive or zero
SkScalar fAscent
distance to reserve above baseline, typically negative
SkScalar fDescent
distance to reserve below baseline, typically positive
static constexpr SkISize Make(int32_t w, int32_t h)
constexpr int32_t width() const
std::shared_ptr< const fml::Mapping > data