aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkTypeface.h6
-rw-r--r--src/ports/SkFontHost_mac.cpp16
2 files changed, 14 insertions, 8 deletions
diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h
index 10cf96142b..3e7f447f9f 100644
--- a/include/core/SkTypeface.h
+++ b/include/core/SkTypeface.h
@@ -321,6 +321,10 @@ public:
void getFontDescriptor(SkFontDescriptor* desc, bool* isLocal) const {
this->onGetFontDescriptor(desc, isLocal);
}
+ // PRIVATE / EXPERIMENTAL -- do not call
+ void* internal_private_getCTFontRef() const {
+ return this->onGetCTFontRef();
+ }
protected:
// The type of advance data wanted.
@@ -384,6 +388,8 @@ protected:
virtual bool onComputeBounds(SkRect*) const;
+ virtual void* onGetCTFontRef() const { return nullptr; }
+
private:
friend class SkRandomTypeface;
friend class SkPDFFont;
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index 4774eab87f..a43cf22c98 100644
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -62,6 +62,10 @@
// Set to make glyph bounding boxes visible.
#define SK_SHOW_TEXT_BLIT_COVERAGE 0
+CTFontRef SkTypeface_GetCTFontRef(const SkTypeface* face) {
+ return face ? (CTFontRef)face->internal_private_getCTFontRef() : nullptr;
+}
+
class SkScalerContext_Mac;
struct CFSafeRelease {
@@ -528,6 +532,8 @@ protected:
uint16_t glyphs[], int glyphCount) const override;
int onCountGlyphs() const override;
+ void* onGetCTFontRef() const override { return (void*)fFontRef.get(); }
+
private:
bool fIsLocalStream;
@@ -536,7 +542,7 @@ private:
static bool find_by_CTFontRef(SkTypeface* cached, void* context) {
CTFontRef self = (CTFontRef)context;
- CTFontRef other = ((SkTypeface_Mac*)cached)->fFontRef.get();
+ CTFontRef other = (CTFontRef)cached->internal_private_getCTFontRef();
return CFEqual(self, other);
}
@@ -653,12 +659,6 @@ static SkTypeface* create_from_name(const char familyName[], const SkFontStyle&
///////////////////////////////////////////////////////////////////////////////
-extern CTFontRef SkTypeface_GetCTFontRef(const SkTypeface* face);
-CTFontRef SkTypeface_GetCTFontRef(const SkTypeface* face) {
- const SkTypeface_Mac* macface = (const SkTypeface_Mac*)face;
- return macface ? macface->fFontRef.get() : nullptr;
-}
-
/* This function is visible on the outside. It first searches the cache, and if
* not found, returns a new entry (after adding it to the cache).
*/
@@ -779,7 +779,7 @@ SkScalerContext_Mac::SkScalerContext_Mac(sk_sp<SkTypeface_Mac> typeface,
{
AUTO_CG_LOCK();
- CTFontRef ctFont = static_cast<SkTypeface_Mac*>(this->getTypeface())->fFontRef.get();
+ CTFontRef ctFont = (CTFontRef)this->getTypeface()->internal_private_getCTFontRef();
CFIndex numGlyphs = CTFontGetGlyphCount(ctFont);
SkASSERT(numGlyphs >= 1 && numGlyphs <= 0xFFFF);
fGlyphCount = SkToU16(numGlyphs);