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

Prepare for applying opsz also when font-variation-settings not present

Add null check for font-variation-settings, rephrase reconfigured and
found axes.

TEST: virtual/text-antialias/mac-system-ui-trak.html
Bug: 1005969
Change-Id: If235b4518c801fe46bd5a7deb64d102310bc50f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2022709
Commit-Queue: Dominik Röttsches <drott@chromium.org>
Commit-Queue: Ben Wagner <bungeman@chromium.org>
Reviewed-by: default avatarBen Wagner <bungeman@chromium.org>
Auto-Submit: Dominik Röttsches <drott@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735404}
parent 0eb51acb
...@@ -167,28 +167,28 @@ std::unique_ptr<FontPlatformData> FontPlatformDataFromNSFont( ...@@ -167,28 +167,28 @@ std::unique_ptr<FontPlatformData> FontPlatformDataFromNSFont(
// Iterate over the font's axes and find a missing tag from variation // Iterate over the font's axes and find a missing tag from variation
// settings, special case opsz, track the number of axes reconfigured. // settings, special case opsz, track the number of axes reconfigured.
size_t reconfigured_axes = 0; bool axes_reconfigured = false;
for (auto& coordinate : coordinates_to_set) { for (auto& coordinate : coordinates_to_set) {
FontVariationAxis current_axis(AtomicString(), 0);
// Set opsz to font size but allow having it overriden by // Set opsz to font size but allow having it overriden by
// font-variation-settings in case it has 'opsz'. // font-variation-settings in case it has 'opsz'.
if (coordinate.axis == kOpszTag) { if (coordinate.axis == kOpszTag) {
if (coordinate.value != SkFloatToScalar(size)) { if (coordinate.value != SkFloatToScalar(size)) {
coordinate.value = SkFloatToScalar(size); coordinate.value = SkFloatToScalar(size);
reconfigured_axes++; axes_reconfigured = true;
} }
} }
if (variation_settings->FindPair(FourByteTagToAtomicString(coordinate.axis), FontVariationAxis found_variation_setting(AtomicString(), 0);
&current_axis)) { if (variation_settings &&
if (coordinate.value != current_axis.Value() && variation_settings->FindPair(FourByteTagToAtomicString(coordinate.axis),
coordinate.axis != kOpszTag) { &found_variation_setting)) {
coordinate.value = current_axis.Value(); if (coordinate.value != found_variation_setting.Value()) {
reconfigured_axes++; coordinate.value = found_variation_setting.Value();
axes_reconfigured = true;
} }
} }
} }
if (!reconfigured_axes) { if (!axes_reconfigured) {
// No variable axes touched, return the previous typeface. // No variable axes touched, return the previous typeface.
return make_typeface_fontplatformdata(); return make_typeface_fontplatformdata();
} }
......
...@@ -80,4 +80,11 @@ TEST(FontSettingsTest, FindTest) { ...@@ -80,4 +80,11 @@ TEST(FontSettingsTest, FindTest) {
} }
} }
TEST(FontSettingsTest, FindTestEmpty) {
scoped_refptr<FontVariationSettings> settings =
MakeSettings<FontVariationSettings, FontVariationAxis>({});
FontVariationAxis found_axis(AtomicString(), 0);
ASSERT_FALSE(settings->FindPair("a", &found_axis));
}
} // namespace blink } // namespace blink
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