Index: Source/platform/fonts/FontPlatformData.cpp |
diff --git a/Source/platform/fonts/FontPlatformData.cpp b/Source/platform/fonts/FontPlatformData.cpp |
index 33f234c0b2958212562ab40afa13389c640efdb7..b75b6754877aa717ee33e69b3e1d80fb2620cec5 100644 |
--- a/Source/platform/fonts/FontPlatformData.cpp |
+++ b/Source/platform/fonts/FontPlatformData.cpp |
@@ -46,11 +46,7 @@ FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType) |
, m_syntheticBold(false) |
, m_syntheticItalic(false) |
, m_orientation(Horizontal) |
-#if OS(MACOSX) |
- , m_isColorBitmapFont(false) |
- , m_isCompositeFontReference(false) |
- , m_font(nullptr) |
-#else |
+#if !OS(MACOSX) |
, m_style(FontRenderStyle()) |
#endif |
, m_isHashTableDeletedValue(true) |
@@ -72,11 +68,7 @@ FontPlatformData::FontPlatformData() |
, m_syntheticBold(false) |
, m_syntheticItalic(false) |
, m_orientation(Horizontal) |
-#if OS(MACOSX) |
- , m_isColorBitmapFont(false) |
- , m_isCompositeFontReference(false) |
- , m_font(nullptr) |
-#else |
+#if !OS(MACOSX) |
, m_style(FontRenderStyle()) |
#endif |
, m_isHashTableDeletedValue(false) |
@@ -98,11 +90,7 @@ FontPlatformData::FontPlatformData(float size, bool syntheticBold, bool syntheti |
, m_syntheticBold(syntheticBold) |
, m_syntheticItalic(syntheticItalic) |
, m_orientation(orientation) |
-#if OS(MACOSX) |
- , m_isColorBitmapFont(false) |
- , m_isCompositeFontReference(false) |
- , m_font(nullptr) |
-#else |
+#if !OS(MACOSX) |
, m_style(FontRenderStyle()) |
#endif |
, m_isHashTableDeletedValue(false) |
@@ -124,10 +112,6 @@ FontPlatformData::FontPlatformData(const FontPlatformData& source) |
, m_syntheticBold(source.m_syntheticBold) |
, m_syntheticItalic(source.m_syntheticItalic) |
, m_orientation(source.m_orientation) |
-#if OS(MACOSX) |
- , m_isColorBitmapFont(source.m_isColorBitmapFont) |
- , m_isCompositeFontReference(source.m_isCompositeFontReference) |
-#endif |
#if !OS(MACOSX) |
, m_style(source.m_style) |
#endif |
@@ -140,9 +124,6 @@ FontPlatformData::FontPlatformData(const FontPlatformData& source) |
, m_minSizeForSubpixel(source.m_minSizeForSubpixel) |
#endif |
{ |
-#if OS(MACOSX) |
- platformDataInit(source); |
-#endif |
} |
FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize) |
@@ -154,10 +135,6 @@ FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize) |
, m_syntheticBold(src.m_syntheticBold) |
, m_syntheticItalic(src.m_syntheticItalic) |
, m_orientation(src.m_orientation) |
-#if OS(MACOSX) |
- , m_isColorBitmapFont(src.m_isColorBitmapFont) |
- , m_isCompositeFontReference(src.m_isCompositeFontReference) |
-#endif |
#if !OS(MACOSX) |
, m_style(src.m_style) |
#endif |
@@ -170,31 +147,11 @@ FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize) |
, m_minSizeForSubpixel(src.m_minSizeForSubpixel) |
#endif |
{ |
-#if OS(MACOSX) |
- platformDataInit(src); |
-#else |
+#if !OS(MACOSX) |
querySystemForRenderStyle(FontDescription::subpixelPositioning()); |
#endif |
} |
-#if OS(MACOSX) |
-FontPlatformData::FontPlatformData(CGFontRef cgFont, PassRefPtr<SkTypeface> tf, float size, bool syntheticBold, bool syntheticItalic, FontOrientation orientation) |
- : m_typeface(tf) |
- , m_family(CString()) |
- , m_textSize(size) |
- , m_syntheticBold(syntheticBold) |
- , m_syntheticItalic(syntheticItalic) |
- , m_orientation(orientation) |
- , m_isColorBitmapFont(false) |
- , m_isCompositeFontReference(false) |
- , m_font(nullptr) |
- , m_cgFont(cgFont) |
- , m_isHashTableDeletedValue(false) |
-{ |
-} |
- |
-#else |
- |
FontPlatformData::FontPlatformData(PassRefPtr<SkTypeface> tf, const char* family, float textSize, bool syntheticBold, bool syntheticItalic, FontOrientation orientation, bool subpixelTextPosition) |
: m_typeface(tf) |
#if !OS(WIN) |
@@ -212,17 +169,23 @@ FontPlatformData::FontPlatformData(PassRefPtr<SkTypeface> tf, const char* family |
, m_minSizeForSubpixel(0) |
#endif |
{ |
+#if !OS(MACOSX) |
querySystemForRenderStyle(subpixelTextPosition); |
-} |
- |
#endif |
+} |
FontPlatformData::~FontPlatformData() |
{ |
-#if OS(MACOSX) |
- if (m_font) |
- CFRelease(m_font); |
-#endif |
+} |
+ |
+CTFontRef FontPlatformData::ctFont() const |
+{ |
+ return SkTypeface_GetCTFontRef(m_typeface.get()); |
+}; |
+ |
+CGFontRef FontPlatformData::cgFont() const |
+{ |
+ return CTFontCopyGraphicsFont(ctFont(), 0); |
} |
const FontPlatformData& FontPlatformData::operator=(const FontPlatformData& other) |
@@ -240,10 +203,7 @@ const FontPlatformData& FontPlatformData::operator=(const FontPlatformData& othe |
m_syntheticItalic = other.m_syntheticItalic; |
m_harfBuzzFace = nullptr; |
m_orientation = other.m_orientation; |
-#if OS(MACOSX) |
- m_isColorBitmapFont = other.m_isColorBitmapFont; |
- m_isCompositeFontReference = other.m_isCompositeFontReference; |
-#else |
+#if !OS(MACOSX) |
m_style = other.m_style; |
#endif |
@@ -254,11 +214,7 @@ const FontPlatformData& FontPlatformData::operator=(const FontPlatformData& othe |
m_useSubpixelPositioning = other.m_useSubpixelPositioning; |
#endif |
-#if OS(MACOSX) |
- return platformDataAssign(other); |
-#else |
return *this; |
-#endif |
} |
bool FontPlatformData::operator==(const FontPlatformData& a) const |
@@ -276,13 +232,10 @@ bool FontPlatformData::operator==(const FontPlatformData& a) const |
&& m_isHashTableDeletedValue == a.m_isHashTableDeletedValue |
&& m_syntheticBold == a.m_syntheticBold |
&& m_syntheticItalic == a.m_syntheticItalic |
- && m_orientation == a.m_orientation |
#if !OS(MACOSX) |
- && m_style == a.m_style; |
-#else |
- && m_isColorBitmapFont == a.m_isColorBitmapFont |
- && m_isCompositeFontReference == a.m_isCompositeFontReference; |
+ && m_style == a.m_style |
#endif |
+ && m_orientation == a.m_orientation; |
} |
SkFontID FontPlatformData::uniqueID() const |
@@ -308,11 +261,10 @@ bool FontPlatformData::isFixedPitch() const |
SkTypeface* FontPlatformData::typeface() const |
{ |
#if OS(MACOSX) |
- // ctFont() will always generate a typeface, even for uninitialized font members. |
- // We only want to generate a Skia typeface if we have a valid font to start from, |
- // to keep hashing and comparisons to the empty object consistent. |
- if (!m_typeface && (m_font || m_cgFont || m_CTFont || m_inMemoryFont)) |
- m_typeface = adoptRef(SkCreateTypefaceFromCTFont(ctFont())); |
+ // TODO(dro): Ensure that we won't get here to retrieve a default font, |
+ // and remove this code. |
+ if (!m_typeface) |
+ m_typeface = adoptRef(SkTypeface::CreateFromName(0, SkTypeface::kNormal)); |
#endif |
return m_typeface.get(); |
} |