aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2015-05-13 10:57:09 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-13 10:57:10 -0700
commit05773ed30920c0214d1433c07cf6360a05476c97 (patch)
tree5da7ade81a22ca07b2018f42b111bc861bf1edcd /include
parentc5f1c5414fc8f73cbefadcc1b24ec794056fa203 (diff)
Font variations.
Multiple Master and TrueType fonts support variation axes. This implements back-end support for axes on platforms which support it. Review URL: https://codereview.chromium.org/1027373002
Diffstat (limited to 'include')
-rw-r--r--include/core/SkTypeface.h16
-rw-r--r--include/ports/SkFontMgr.h11
2 files changed, 27 insertions, 0 deletions
diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h
index 7d8b892f2c..f0059deb25 100644
--- a/include/core/SkTypeface.h
+++ b/include/core/SkTypeface.h
@@ -17,6 +17,7 @@
#include "SkWeakRefCnt.h"
class SkDescriptor;
+class SkFontData;
class SkFontDescriptor;
class SkScalerContext;
struct SkScalerContextRec;
@@ -134,6 +135,12 @@ public:
*/
static SkTypeface* CreateFromStream(SkStreamAsset* stream, int index = 0);
+ /** Return a new typeface given font data and configuration. If the data
+ is not valid font data, returns null. Ownership of the font data is
+ transferred, so the caller must not reference it again.
+ */
+ static SkTypeface* CreateFromFontData(SkFontData*);
+
/** Write a unique signature to a stream, sufficient to reconstruct a
typeface referencing the same font when Deserialize is called.
*/
@@ -284,6 +291,12 @@ public:
SkStreamAsset* openStream(int* ttcIndex) const;
/**
+ * Return the font data, or NULL on failure.
+ * The caller is responsible for deleting the font data.
+ */
+ SkFontData* createFontData() const;
+
+ /**
* Return a scalercontext for the given descriptor. If this fails, then
* if allowFailure is true, this returns NULL, else it returns a
* dummy scalercontext that will not crash, but will draw nothing.
@@ -337,6 +350,9 @@ protected:
uint32_t glyphIDsCount) const = 0;
virtual SkStreamAsset* onOpenStream(int* ttcIndex) const = 0;
+ // TODO: make pure virtual.
+ virtual SkFontData* onCreateFontData() const;
+
virtual void onGetFontDescriptor(SkFontDescriptor*, bool* isLocal) const = 0;
virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[],
diff --git a/include/ports/SkFontMgr.h b/include/ports/SkFontMgr.h
index 4dde920085..48a0494a7a 100644
--- a/include/ports/SkFontMgr.h
+++ b/include/ports/SkFontMgr.h
@@ -12,6 +12,7 @@
#include "SkFontStyle.h"
class SkData;
+class SkFontData;
class SkStreamAsset;
class SkString;
class SkTypeface;
@@ -95,6 +96,14 @@ public:
SkTypeface* createFromStream(SkStreamAsset*, int ttcIndex = 0) const;
/**
+ * Create a typeface from the specified font data.
+ * Takes ownership of the font data, so the caller should not reference it again.
+ * Will return NULL if the typeface could not be created.
+ * The caller must call unref() on the returned object if it is not null.
+ */
+ SkTypeface* createFromFontData(SkFontData*) const;
+
+ /**
* Create a typeface for the specified fileName and TTC index
* (pass 0 for none) or NULL if the file is not found, or its contents are
* not recognized. The caller must call unref() on the returned object
@@ -129,6 +138,8 @@ protected:
virtual SkTypeface* onCreateFromData(SkData*, int ttcIndex) const = 0;
virtual SkTypeface* onCreateFromStream(SkStreamAsset*, int ttcIndex) const = 0;
+ // TODO: make pure virtual.
+ virtual SkTypeface* onCreateFromFontData(SkFontData*) const;
virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const = 0;
virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],