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

Unified Diff: src/ports/SkFontMgr_android.cpp

Issue 1590223003: Expose API for gx font variation axes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix FontConfig and Android. Created 4 years, 11 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 | « src/ports/SkFontHost_mac.cpp ('k') | src/ports/SkFontMgr_fontconfig.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontMgr_android.cpp
diff --git a/src/ports/SkFontMgr_android.cpp b/src/ports/SkFontMgr_android.cpp
index 11244c55ee94f3eecf7003c3a1866fb916c85b69..afa78734544f685bfba82be17062e89f6b2f543b 100644
--- a/src/ports/SkFontMgr_android.cpp
+++ b/src/ports/SkFontMgr_android.cpp
@@ -6,7 +6,6 @@
*/
#include "SkTypes.h"
-#if defined(SK_BUILD_FOR_ANDROID)
#include "SkFixed.h"
#include "SkFontDescriptor.h"
@@ -208,26 +207,27 @@ public:
}
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;
- }
+ // 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));
- }
- })
+ }
+ 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));
+ }
+ }
+ )
- fStyles.push_back().reset(new SkTypeface_AndroidSystem(
- pathName, ttcIndex, axisValues.get(), axisDefinitions.count(), style,
- isFixedWidth, familyName, lang, variant));
+ fStyles.push_back().reset(new SkTypeface_AndroidSystem(
+ pathName, ttcIndex, axisValues.get(), axisDefinitions.count(), style,
+ isFixedWidth, familyName, lang, variant));
}
}
@@ -476,6 +476,29 @@ protected:
return new SkTypeface_AndroidStream(data, style, isFixedPitch, name);
}
+ SkTypeface* onCreateFromStream(SkStreamAsset* s, const FontParameters& params) const override {
+ using Scanner = SkTypeface_FreeType::Scanner;
+ SkAutoTDelete<SkStreamAsset> stream(s);
+ bool isFixedPitch;
+ SkFontStyle style;
+ SkString name;
+ Scanner::AxisDefinitions axisDefinitions;
+ if (!fScanner.scanFont(stream, params.getCollectionIndex(), &name, &style, &isFixedPitch,
+ &axisDefinitions))
+ {
+ return nullptr;
+ }
+
+ int paramAxisCount;
+ const FontParameters::Axis* paramAxes = params.getAxes(&paramAxisCount);
+ SkAutoSTMalloc<4, SkFixed> axisValues(axisDefinitions.count());
+ Scanner::computeAxisValues(axisDefinitions, paramAxes, paramAxisCount, axisValues, name);
+
+ SkFontData* data(new SkFontData(stream.detach(), params.getCollectionIndex(),
+ axisValues.get(), axisDefinitions.count()));
+ return new SkTypeface_AndroidStream(data, style, isFixedPitch, name);
+ }
+
SkTypeface* onCreateFromFontData(SkFontData* data) const override {
SkStreamAsset* stream(data->getStream());
bool isFixedPitch;
@@ -589,5 +612,3 @@ SkFontMgr* SkFontMgr_New_Android(const SkFontMgr_Android_CustomFonts* custom) {
return new SkFontMgr_Android(custom);
}
-
-#endif//defined(SK_BUILD_FOR_ANDROID)
« no previous file with comments | « src/ports/SkFontHost_mac.cpp ('k') | src/ports/SkFontMgr_fontconfig.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698