diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkAdvancedTypefaceMetrics.cpp | 16 | ||||
-rw-r--r-- | src/ports/SkFontHost_FreeType.cpp | 7 | ||||
-rw-r--r-- | src/ports/SkFontMgr_custom.cpp | 20 | ||||
-rw-r--r-- | src/ports/SkFontMgr_custom_empty_factory.cpp | 13 |
4 files changed, 44 insertions, 12 deletions
diff --git a/src/core/SkAdvancedTypefaceMetrics.cpp b/src/core/SkAdvancedTypefaceMetrics.cpp index 28079f98e9..48b2cd73f7 100644 --- a/src/core/SkAdvancedTypefaceMetrics.cpp +++ b/src/core/SkAdvancedTypefaceMetrics.cpp @@ -14,11 +14,9 @@ #include <dwrite.h> #endif -#if defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID) // forward declare structs needed for getAdvanceData() template for freetype struct FT_FaceRec_; typedef struct FT_FaceRec_* FT_Face; -#endif #ifdef SK_BUILD_FOR_MAC #import <ApplicationServices/ApplicationServices.h> @@ -255,6 +253,13 @@ SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* getAdvanceData( // Make AdvanceMetric template functions available for linking with typename // WidthRange and VerticalAdvanceRange. +template SkAdvancedTypefaceMetrics::WidthRange* getAdvanceData( + FT_Face face, + int num_glyphs, + const uint32_t* subsetGlyphIDs, + uint32_t subsetGlyphIDsLength, + bool (*getAdvance)(FT_Face face, int gId, int16_t* data)); + #if defined(SK_BUILD_FOR_WIN) template SkAdvancedTypefaceMetrics::WidthRange* getAdvanceData( HDC hdc, @@ -268,13 +273,6 @@ template SkAdvancedTypefaceMetrics::WidthRange* getAdvanceData( const uint32_t* subsetGlyphIDs, uint32_t subsetGlyphIDsLength, bool (*getAdvance)(IDWriteFontFace* fontFace, int gId, int16_t* data)); -#elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID) -template SkAdvancedTypefaceMetrics::WidthRange* getAdvanceData( - FT_Face face, - int num_glyphs, - const uint32_t* subsetGlyphIDs, - uint32_t subsetGlyphIDsLength, - bool (*getAdvance)(FT_Face face, int gId, int16_t* data)); #elif defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) template SkAdvancedTypefaceMetrics::WidthRange* getAdvanceData( CTFontRef ctFont, diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index f01c7d7cc5..e7cb6d2963 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -361,7 +361,8 @@ static FT_Face ref_ft_face(const SkTypeface* typeface) { } // Caller must lock gFTMutex before calling this function. -static void unref_ft_face(FT_Face face) { +extern void unref_ft_face(FT_Face face); +void unref_ft_face(FT_Face face) { gFTMutex.assertHeld(); SkFaceRec* rec = gFaceRecHead; @@ -1284,7 +1285,6 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* metrics SkAutoMutexAcquire ac(gFTMutex); if (this->setupSize()) { - ERROR: sk_bzero(metrics, sizeof(*metrics)); return; } @@ -1376,7 +1376,8 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* metrics metrics->fFlags &= ~SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag; metrics->fFlags &= ~SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag; } else { - goto ERROR; + sk_bzero(metrics, sizeof(*metrics)); + return; } // synthesize elements that were not provided by the os/2 table or format-specific metrics diff --git a/src/ports/SkFontMgr_custom.cpp b/src/ports/SkFontMgr_custom.cpp index 158ba006d4..c77fe394b1 100644 --- a/src/ports/SkFontMgr_custom.cpp +++ b/src/ports/SkFontMgr_custom.cpp @@ -506,3 +506,23 @@ private: SkFontMgr* SkFontMgr_New_Custom_Embedded(const SkEmbeddedResourceHeader* header) { return new SkFontMgr_Custom(EmbeddedSystemFontLoader(header)); } + +/////////////////////////////////////////////////////////////////////////////// + +class EmptyFontLoader : public SkFontMgr_Custom::SystemFontLoader { +public: + EmptyFontLoader() { } + + void loadSystemFonts(const SkTypeface_FreeType::Scanner& scanner, + SkFontMgr_Custom::Families* families) const override + { + SkFontStyleSet_Custom* family = new SkFontStyleSet_Custom(SkString()); + families->push_back().reset(family); + family->appendTypeface(new SkTypeface_Empty); + } + +}; + +SK_API SkFontMgr* SkFontMgr_New_Custom_Empty() { + return new SkFontMgr_Custom(EmptyFontLoader()); +} diff --git a/src/ports/SkFontMgr_custom_empty_factory.cpp b/src/ports/SkFontMgr_custom_empty_factory.cpp new file mode 100644 index 0000000000..c9487cdcc7 --- /dev/null +++ b/src/ports/SkFontMgr_custom_empty_factory.cpp @@ -0,0 +1,13 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkFontMgr.h" +#include "SkFontMgr_custom.h" + +SkFontMgr* SkFontMgr::Factory() { + return SkFontMgr_New_Custom_Empty(); +} |