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

Unified Diff: include/ports/SkFontMgr.h

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 | « gm/fontscalerdistortable.cpp ('k') | src/core/SkFontMgr.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/ports/SkFontMgr.h
diff --git a/include/ports/SkFontMgr.h b/include/ports/SkFontMgr.h
index 96a8501c48561918c8c03213e3198fa78bc61233..3e6c785be9eb66943586b54f15767213d6ad5a52 100644
--- a/include/ports/SkFontMgr.h
+++ b/include/ports/SkFontMgr.h
@@ -8,8 +8,10 @@
#ifndef SkFontMgr_DEFINED
#define SkFontMgr_DEFINED
-#include "SkRefCnt.h"
#include "SkFontStyle.h"
+#include "SkRefCnt.h"
+#include "SkScalar.h"
+#include "SkTypes.h"
class SkData;
class SkFontData;
@@ -100,6 +102,52 @@ public:
*/
SkTypeface* createFromStream(SkStreamAsset*, int ttcIndex = 0) const;
+ struct FontParameters {
+ struct Axis {
+ SkFourByteTag fTag;
+ SkScalar fStyleValue;
+ };
+
+ FontParameters() : fCollectionIndex(0), fAxisCount(0), fAxes(nullptr) {}
+
+ /** Specify the index of the desired font.
+ *
+ * Font formats like ttc, dfont, cff, cid, pfr, t42, t1, and fon may actually be indexed
+ * collections of fonts.
+ */
+ FontParameters& setCollectionIndex(int collectionIndex) {
+ fCollectionIndex = collectionIndex;
+ return *this;
+ }
+
+ /** Specify the GX variation axis values.
+ *
+ * Any axes not specified will use the default value. Specified axes not present in the
+ * font will be ignored.
+ *
+ * @param axes not copied. This pointer must remain valid for life of FontParameters.
+ */
+ FontParameters& setAxes(const Axis* axes, int axisCount) {
+ fAxisCount = axisCount;
+ fAxes = axes;
+ return *this;
+ }
+
+ int getCollectionIndex() const {
+ return fCollectionIndex;
+ }
+ const Axis* getAxes(int* axisCount) const {
+ *axisCount = fAxisCount;
+ return fAxes;
+ }
+ private:
+ int fCollectionIndex;
+ int fAxisCount;
+ const Axis* fAxes;
+ };
+ /* Experimental, API subject to change. */
+ SkTypeface* createFromStream(SkStreamAsset*, const FontParameters&) const;
+
/**
* Create a typeface from the specified font data.
* Takes ownership of the font data, so the caller should not reference it again.
@@ -144,6 +192,7 @@ protected:
virtual SkTypeface* onCreateFromData(SkData*, int ttcIndex) const = 0;
virtual SkTypeface* onCreateFromStream(SkStreamAsset*, int ttcIndex) const = 0;
// TODO: make pure virtual.
+ virtual SkTypeface* onCreateFromStream(SkStreamAsset*, const FontParameters&) const;
virtual SkTypeface* onCreateFromFontData(SkFontData*) const;
virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const = 0;
« no previous file with comments | « gm/fontscalerdistortable.cpp ('k') | src/core/SkFontMgr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698