Skip to content

Commit

Permalink
Support font palette overrides through SkFontArguments
Browse files Browse the repository at this point in the history
Co-authored with Ben Wagner, [email protected].

Similar to how we allow configuration of variable font configurations,
provide additional SkFontArguments to select a base palette and a set
of potentially sparse color overrides.

This is required for implementing CSS font-palette.

Modify the more_samples-glyf_colr_1.ttf to have two additional palettes,
and two additional test glyphs, one that draws with COLRv0 logic, one
that draws with COLRv1 logic and has a foreground palette index dot
in the middle. See [1] & [2] for the additions to the test font.

Add a GM which tests this on the SkFontMgr_custom using makeClone() and
makeFromStreamArgs(). The test displays the two glyphs in default
palette on the left, then with palette overrides (as in the title of the
test) on the right. The first row uses a typeface created with
makeFromStreamArgs(), the second uses one created with makeClone().

[1] googlefonts/color-fonts#91
[2] googlefonts/color-fonts#92

Reviewed-on: https://skia-review.googlesource.com/c/skia/+/479616
  • Loading branch information
drott authored and dahlstrom-g committed Mar 6, 2024
1 parent dad8fa5 commit 331acc2
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ std::unique_ptr<SkFontData> SkTypeface_Cobalt::onMakeFontData() const {
if (!stream) {
return nullptr;
}
return std::make_unique<SkFontData>(std::move(stream), index,
computed_variation_position_.data(),
computed_variation_position_.count());
return std::make_unique<SkFontData>(
std::move(stream), index, 0, computed_variation_position_.data(),
computed_variation_position_.count(), nullptr, 0);
}

SkTypeface_CobaltStream::SkTypeface_CobaltStream(
Expand Down

0 comments on commit 331acc2

Please sign in to comment.