COLRv1 GM test for foreground color

Updated COLRv1 samples font file from
https://github.com/googlefonts/color-fonts/pull/80

Bug: skia:12576
Cq-Include-Trybots: luci.skia.skia.primary:Test-Android-Clang-GalaxyS20-GPU-MaliG77-arm64-Release-All-Android_NativeFonts,Test-Debian10-Clang-GCE-CPU-AVX2-x86_64-Debug-All-NativeFonts
Change-Id: I18164fda87ffc3a2a05749f55ca61813cac14b41
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/468236
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Auto-Submit: Dominik Röttsches <drott@chromium.org>
This commit is contained in:
Dominik Röttsches 2021-11-09 16:13:19 +02:00 committed by SkCQ
parent add2c39dce
commit 612c73329b
2 changed files with 13 additions and 1 deletions

View File

@ -37,7 +37,8 @@ public:
kColorFontsRepoSkew,
kColorFontsRepoTransform,
kColorFontsRepoClipBox,
kColorFontsRepoComposite
kColorFontsRepoComposite,
kColorFontsRepoForeground
};
ColrV1GM(ColrV1TestType testType, SkScalar skewX, SkScalar rotateDeg)
@ -64,6 +65,8 @@ protected:
return SkString("clipbox");
case kColorFontsRepoComposite:
return SkString("composite");
case kColorFontsRepoForeground:
return SkString("foreground");
}
SkASSERT(false); /* not reached */
return SkString();
@ -112,6 +115,9 @@ protected:
case kColorFontsRepoComposite:
fEmojiFont.fGlyphs = {40, 41, 42, 43, 44, 45, 46};
break;
case kColorFontsRepoForeground:
fEmojiFont.fGlyphs = {47, 48, 49, 50, 51, 52, 53, 54};
break;
}
}
@ -148,15 +154,20 @@ protected:
SkFontMetrics metrics;
SkScalar y = 0;
std::vector<SkColor> paint_colors = {
SK_ColorBLACK, SK_ColorGREEN, SK_ColorRED, SK_ColorBLUE};
auto paint_color_iterator = paint_colors.begin();
for (SkScalar textSize : { 12, 18, 30, 120 }) {
font.setSize(textSize);
font.getMetrics(&metrics);
y += -metrics.fAscent;
paint.setColor(*paint_color_iterator);
canvas->drawSimpleText(fEmojiFont.fGlyphs.data(),
fEmojiFont.bytesize(),
SkTextEncoding::kGlyphID,
10, y, font, paint);
y += metrics.fDescent + metrics.fLeading;
paint_color_iterator++;
}
return DrawResult::kOk;
}
@ -181,5 +192,6 @@ DEF_GM(return new ColrV1GM(ColrV1GM::kColorFontsRepoTransform, 0.f, 0.f);)
DEF_GM(return new ColrV1GM(ColrV1GM::kColorFontsRepoClipBox, 0.f, 0.f);)
DEF_GM(return new ColrV1GM(ColrV1GM::kColorFontsRepoClipBox, -0.5f, 20.f);)
DEF_GM(return new ColrV1GM(ColrV1GM::kColorFontsRepoComposite, 0.f, 0.f);)
DEF_GM(return new ColrV1GM(ColrV1GM::kColorFontsRepoForeground, 0.f, 0.f);)
} // namespace skiagm