Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(986)

Unified Diff: src/ports/SkFontHost_FreeType.cpp

Issue 1709403003: Check scalar to fixed conversions with axes. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_FreeType.cpp
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index d61a94323aaf84e2d4b4e47fee56efd2daa658ee..181116a15e09d4b1853a17abeb0da73a261e6d16 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -1750,13 +1750,14 @@ bool SkTypeface_FreeType::Scanner::scanFont(
{
for (int i = 0; i < axisDefinitions.count(); ++i) {
const Scanner::AxisDefinition& axisDefinition = axisDefinitions[i];
+ const SkScalar axisMin = SkFixedToScalar(axisDefinition.fMinimum);
+ const SkScalar axisMax = SkFixedToScalar(axisDefinition.fMaximum);
axisValues[i] = axisDefinition.fDefault;
for (int j = 0; j < requestedAxisCount; ++j) {
const SkFontMgr::FontParameters::Axis& axisSpecified = requestedAxes[j];
if (axisDefinition.fTag == axisSpecified.fTag) {
- SkFixed axisValue = SkScalarToFixed(axisSpecified.fStyleValue);
- axisValues[i] = SkTPin(axisValue, axisDefinition.fMinimum, axisDefinition.fMaximum);
- if (axisValues[i] != axisValue) {
+ const SkScalar axisValue = SkTPin(axisSpecified.fStyleValue, axisMin, axisMax);
+ if (axisSpecified.fStyleValue != axisValue) {
SkDEBUGF(("Requested font axis value out of range: "
"%s '%c%c%c%c' %f; pinned to %f.\n",
name.c_str(),
@@ -1765,8 +1766,9 @@ bool SkTypeface_FreeType::Scanner::scanFont(
(axisDefinition.fTag >> 8) & 0xFF,
(axisDefinition.fTag ) & 0xFF,
SkScalarToDouble(axisSpecified.fStyleValue),
- SkFixedToDouble(axisValues[i])));
+ SkScalarToDouble(axisValue)));
}
+ axisValues[i] = SkScalarToFixed(axisValue);
break;
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698