diff options
author | 2016-09-01 08:52:29 -0700 | |
---|---|---|
committer | 2016-09-01 08:52:29 -0700 | |
commit | 4bb029cd9f7c00ac146df1f4c66d1ac5c078b78b (patch) | |
tree | 4b14f1bd664ca9adafca2d09a3b7fd5f3cbb0c20 /src/ports/SkFontConfigTypeface.h | |
parent | d0cd2ecf31bb49988bc8a7ff74ee05161c9538de (diff) |
SkFontMgr_FontConfigInterface create typeface from FontParameters.
This implements
SkFontMgr_FontConfigInterface::onCreateFromStream(SkStreamAsset*, const FontParameters&)
and makes the changes needed to support it. This will allow Chromium to
create variation fonts from data.
BUG=skia:5697
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2296843002
Review-Url: https://codereview.chromium.org/2296843002
Diffstat (limited to 'src/ports/SkFontConfigTypeface.h')
-rw-r--r-- | src/ports/SkFontConfigTypeface.h | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/src/ports/SkFontConfigTypeface.h b/src/ports/SkFontConfigTypeface.h index 590c6fac89..b636052c47 100644 --- a/src/ports/SkFontConfigTypeface.h +++ b/src/ports/SkFontConfigTypeface.h @@ -6,17 +6,18 @@ */ #include "SkFontConfigInterface.h" +#include "SkFontDescriptor.h" #include "SkFontHost_FreeType_common.h" +#include "SkRefCnt.h" #include "SkStream.h" -#include "SkTypefaceCache.h" class SkFontDescriptor; class SkTypeface_FCI : public SkTypeface_FreeType { - SkAutoTUnref<SkFontConfigInterface> fFCI; + sk_sp<SkFontConfigInterface> fFCI; SkFontConfigInterface::FontIdentity fIdentity; SkString fFamilyName; - SkAutoTDelete<SkStreamAsset> fLocalStream; + std::unique_ptr<SkFontData> fFontData; public: static SkTypeface_FCI* Create(SkFontConfigInterface* fci, @@ -27,24 +28,16 @@ public: return new SkTypeface_FCI(fci, fi, familyName, style); } - static SkTypeface_FCI* Create(const SkFontStyle& style, bool fixedWidth, - SkStreamAsset* localStream, int index) + static SkTypeface_FCI* Create(std::unique_ptr<SkFontData> data, + SkFontStyle style, bool isFixedPitch) { - return new SkTypeface_FCI(style, fixedWidth, localStream, index); + return new SkTypeface_FCI(std::move(data), style, isFixedPitch); } const SkFontConfigInterface::FontIdentity& getIdentity() const { return fIdentity; } - SkStreamAsset* getLocalStream() const { - return fLocalStream.get(); - } - - bool isFamilyName(const char* name) const { - return fFamilyName.equals(name); - } - protected: SkTypeface_FCI(SkFontConfigInterface* fci, const SkFontConfigInterface::FontIdentity& fi, @@ -54,18 +47,20 @@ protected: , fFCI(SkRef(fci)) , fIdentity(fi) , fFamilyName(familyName) - , fLocalStream(nullptr) {} + , fFontData(nullptr) {} - SkTypeface_FCI(const SkFontStyle& style, bool fixedWidth, SkStreamAsset* localStream, int index) - : INHERITED(style, fixedWidth) - , fLocalStream(localStream) + SkTypeface_FCI(std::unique_ptr<SkFontData> data, SkFontStyle style, bool isFixedPitch) + : INHERITED(style, isFixedPitch) + , fFontData(std::move(data)) { - fIdentity.fTTCIndex = index; + SkASSERT(fFontData); + fIdentity.fTTCIndex = fFontData->getIndex(); } void onGetFamilyName(SkString* familyName) const override { *familyName = fFamilyName; } void onGetFontDescriptor(SkFontDescriptor*, bool*) const override; SkStreamAsset* onOpenStream(int* ttcIndex) const override; + SkFontData* onCreateFontData() const override; private: typedef SkTypeface_FreeType INHERITED; |