Commit 47964779 authored by Dominik Röttsches's avatar Dominik Röttsches Committed by Commit Bot

Switch application of variable axes to web fonts to Skia's makeClone

Analogously to the fix in [1], use Skia's makeClone method for applying
variable font axis parameters to a previously decoded and instantiated
(as SkTypeface) web font. This avoids the workaround of instantiating
the variable instance from a duplicated SkStreamAsset.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/1911758

Bug: 1034906
Change-Id: I80406cfd67c60251404bd80b2f99bc59b891dcd5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1970618
Commit-Queue: Dominik Röttsches <drott@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735788}
parent b7ca54ae
......@@ -45,16 +45,6 @@
namespace blink {
namespace {
sk_sp<SkFontMgr> FontManagerForSubType(
FontFormatCheck::VariableFontSubType font_sub_type) {
CHECK_NE(font_sub_type, FontFormatCheck::VariableFontSubType::kNotVariable);
if (font_sub_type == FontFormatCheck::VariableFontSubType::kVariableCFF2)
return WebFontTypefaceFactory::FreeTypeFontManager();
return WebFontTypefaceFactory::FontManagerForVariations();
}
} // namespace
FontCustomPlatformData::FontCustomPlatformData(sk_sp<SkTypeface> typeface,
size_t data_size)
: base_typeface_(std::move(typeface)), data_size_(data_size) {}
......@@ -124,12 +114,8 @@ FontPlatformData FontCustomPlatformData::GetFontPlatformData(
axes.push_back(opsz_axis);
}
int index;
std::unique_ptr<SkStreamAsset> stream(base_typeface_->openStream(&index));
sk_sp<SkTypeface> sk_variation_font(FontManagerForSubType(font_sub_type)
->makeFromStream(std::move(stream),
SkFontArguments().setCollectionIndex(index)
.setAxes(axes.data(), axes.size())));
sk_sp<SkTypeface> sk_variation_font(base_typeface_->makeClone(
SkFontArguments().setAxes(axes.data(), axes.size())));
if (sk_variation_font) {
return_typeface = sk_variation_font;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment