aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2017-03-29 13:38:53 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-30 15:23:53 +0000
commit9aec8945f0e0cc88c33c2440f2163d36c7198bf6 (patch)
tree7a5060b1966784a92d148c806e54b5eb9fe4bbc3 /src/ports
parenta811b1200cc0b5e3819c89f62def23ec203d4b5a (diff)
Use last value for axis for variation position.
SkFontArguments::VariationPosition may be over specified. If there are multiple values for a given axis, ensure the last value specified is used, since that's what css-fonts-4 requires. BUG=chromium:674878 Change-Id: I6704c15c520c89efb9ee84659a3e16e0d07691c9 Reviewed-on: https://skia-review.googlesource.com/10513 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/ports')
-rw-r--r--src/ports/SkFontHost_FreeType.cpp4
-rw-r--r--src/ports/SkFontHost_mac.cpp4
2 files changed, 6 insertions, 2 deletions
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index 240f75c2e2..91801cdbd0 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -1855,7 +1855,9 @@ bool SkTypeface_FreeType::Scanner::scanFont(
const SkScalar axisMin = SkFixedToScalar(axisDefinition.fMinimum);
const SkScalar axisMax = SkFixedToScalar(axisDefinition.fMaximum);
axisValues[i] = axisDefinition.fDefault;
- for (int j = 0; j < position.coordinateCount; ++j) {
+ // The position may be over specified. If there are multiple values for a given axis,
+ // use the last one since that's what css-fonts-4 requires.
+ for (int j = position.coordinateCount; j --> 0;) {
const auto& coordinate = position.coordinates[j];
if (axisDefinition.fTag == coordinate.axis) {
const SkScalar axisValue = SkTPin(coordinate.value, axisMin, axisMax);
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index 176a20cd65..d13be5a03b 100644
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -2488,7 +2488,9 @@ protected:
}
double value = defDouble;
- for (int j = 0; j < position.coordinateCount; ++j) {
+ // The position may be over specified. If there are multiple values for a given axis,
+ // use the last one since that's what css-fonts-4 requires.
+ for (int j = position.coordinateCount; j --> 0;) {
if (position.coordinates[j].axis == tagLong) {
value = SkTPin(SkScalarToDouble(position.coordinates[j].value),
minDouble, maxDouble);