aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkFontMgr_android.cpp
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2016-02-25 11:20:01 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-25 11:20:01 -0800
commit47a1e96b957b50662274360f1a390d76ab3d02cc (patch)
tree9f0c168c3d7558b3e045b50acb24d56e64abb4d8 /src/ports/SkFontMgr_android.cpp
parent26cc3f5ad0aacf80bba162bab4b23a2901ffed17 (diff)
Deduplicate axis value resolving code.
The code was originally written for Android, but is now implemented more generally by the FreeType scanner to be shared between all FreeType backed typefaces. This removes the now duplicate code in the Android font manager and uses the shared code instead. GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1726213004 Review URL: https://codereview.chromium.org/1726213004
Diffstat (limited to 'src/ports/SkFontMgr_android.cpp')
-rw-r--r--src/ports/SkFontMgr_android.cpp46
1 files changed, 3 insertions, 43 deletions
diff --git a/src/ports/SkFontMgr_android.cpp b/src/ports/SkFontMgr_android.cpp
index a71e2c9276..93a7d8659f 100644
--- a/src/ports/SkFontMgr_android.cpp
+++ b/src/ports/SkFontMgr_android.cpp
@@ -198,49 +198,9 @@ public:
}
SkAutoSTMalloc<4, SkFixed> axisValues(axisDefinitions.count());
- for (int i = 0; i < axisDefinitions.count(); ++i) {
- const Scanner::AxisDefinition& axisDefinition = axisDefinitions[i];
- axisValues[i] = axisDefinition.fDefault;
- for (int j = 0; j < fontFile.fAxes.count(); ++j) {
- const FontFileInfo::Axis& axisSpecified = fontFile.fAxes[j];
- if (axisDefinition.fTag == axisSpecified.fTag) {
- axisValues[i] = SkTPin(axisSpecified.fValue, axisDefinition.fMinimum,
- axisDefinition.fMaximum);
- if (axisValues[i] != axisSpecified.fValue) {
- SkDEBUGF(("Requested font axis value out of range: "
- "%s '%c%c%c%c' %f; pinned to %f.\n",
- familyName.c_str(),
- (axisDefinition.fTag >> 24) & 0xFF,
- (axisDefinition.fTag >> 16) & 0xFF,
- (axisDefinition.fTag >> 8) & 0xFF,
- (axisDefinition.fTag ) & 0xFF,
- SkFixedToDouble(axisSpecified.fValue),
- SkFixedToDouble(axisValues[i])));
- }
- break;
- }
- }
- // TODO: warn on defaulted axis?
- }
-
- SkDEBUGCODE(
- // Check for axis specified, but not matched in font.
- for (int i = 0; i < fontFile.fAxes.count(); ++i) {
- SkFourByteTag skTag = fontFile.fAxes[i].fTag;
- bool found = false;
- for (int j = 0; j < axisDefinitions.count(); ++j) {
- if (skTag == axisDefinitions[j].fTag) {
- found = true;
- break;
- }
- }
- if (!found) {
- SkDEBUGF(("Requested font axis not found: %s '%c%c%c%c'\n",
- familyName.c_str(), (skTag >> 24) & 0xFF,
- (skTag >> 16) & 0xFF, (skTag >> 8) & 0xFF, (skTag)&0xFF));
- }
- }
- )
+ Scanner::computeAxisValues(axisDefinitions,
+ fontFile.fAxes.begin(), fontFile.fAxes.count(),
+ axisValues, familyName);
fStyles.push_back().reset(new SkTypeface_AndroidSystem(
pathName, cacheFontFiles, ttcIndex, axisValues.get(), axisDefinitions.count(),