Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / platform / fonts / win / FontPlatformDataWin.cpp
index cd85a12..ebccad5 100644 (file)
@@ -115,14 +115,14 @@ static bool isWebFont(const String& familyName)
         && '=' == familyName[22] && '=' == familyName[23];
 }
 
-int FontPlatformData::paintTextFlags() const
+static int computePaintTextFlags(String fontFamilyName)
 {
     int textFlags = getSystemTextFlags();
 
     // Many web-fonts are so poorly hinted that they are terrible to read when drawn in BW.
     // In these cases, we have decided to FORCE these fonts to be drawn with at least grayscale AA,
     // even when the System (getSystemTextFlags) tells us to draw only in BW.
-    if (isWebFont(fontFamilyName()) && !isRunningLayoutTest())
+    if (isWebFont(fontFamilyName) && !isRunningLayoutTest())
         textFlags |= SkPaint::kAntiAlias_Flag;
     return textFlags;
 }
@@ -148,6 +148,7 @@ FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType)
     , m_syntheticItalic(false)
     , m_orientation(Horizontal)
     , m_typeface(adoptRef(SkTypeface::RefDefault()))
+    , m_paintTextFlags(0)
     , m_isHashTableDeletedValue(true)
     , m_useSubpixelPositioning(false)
 {
@@ -163,6 +164,7 @@ FontPlatformData::FontPlatformData()
     , m_syntheticItalic(false)
     , m_orientation(Horizontal)
     , m_typeface(adoptRef(SkTypeface::RefDefault()))
+    , m_paintTextFlags(0)
     , m_isHashTableDeletedValue(false)
     , m_useSubpixelPositioning(false)
 {
@@ -184,6 +186,7 @@ FontPlatformData::FontPlatformData(HFONT font, float size, FontOrientation orien
     , m_isHashTableDeletedValue(false)
     , m_useSubpixelPositioning(false)
 {
+    m_paintTextFlags = computePaintTextFlags(fontFamilyName());
 }
 #endif
 
@@ -194,6 +197,7 @@ FontPlatformData::FontPlatformData(float size, bool bold, bool oblique)
     , m_syntheticItalic(false)
     , m_orientation(Horizontal)
     , m_typeface(adoptRef(SkTypeface::RefDefault()))
+    , m_paintTextFlags(0)
     , m_isHashTableDeletedValue(false)
     , m_useSubpixelPositioning(false)
 {
@@ -209,6 +213,7 @@ FontPlatformData::FontPlatformData(const FontPlatformData& data)
     , m_syntheticItalic(data.m_syntheticItalic)
     , m_orientation(data.m_orientation)
     , m_typeface(data.m_typeface)
+    , m_paintTextFlags(data.m_paintTextFlags)
     , m_isHashTableDeletedValue(false)
     , m_useSubpixelPositioning(data.m_useSubpixelPositioning)
 {
@@ -224,6 +229,7 @@ FontPlatformData::FontPlatformData(const FontPlatformData& data, float textSize)
     , m_syntheticItalic(data.m_syntheticItalic)
     , m_orientation(data.m_orientation)
     , m_typeface(data.m_typeface)
+    , m_paintTextFlags(data.m_paintTextFlags)
     , m_isHashTableDeletedValue(false)
     , m_useSubpixelPositioning(data.m_useSubpixelPositioning)
 {
@@ -244,13 +250,13 @@ FontPlatformData::FontPlatformData(PassRefPtr<SkTypeface> tf, const char* family
     , m_isHashTableDeletedValue(false)
     , m_useSubpixelPositioning(useSubpixelPositioning)
 {
+    m_paintTextFlags = computePaintTextFlags(fontFamilyName());
+#if !USE(HARFBUZZ)
     // FIXME: This can be removed together with m_font once the last few
     // uses of hfont() has been eliminated.
     LOGFONT logFont;
     SkLOGFONTFromTypeface(m_typeface.get(), &logFont);
     logFont.lfHeight = -textSize;
-
-#if !USE(HARFBUZZ)
     HFONT hFont = CreateFontIndirect(&logFont);
     m_font = hFont ? RefCountedHFONT::create(hFont) : 0;
     m_scriptCache = 0;
@@ -265,6 +271,7 @@ FontPlatformData& FontPlatformData::operator=(const FontPlatformData& data)
         m_syntheticItalic = data.m_syntheticItalic;
         m_orientation = data.m_orientation;
         m_typeface = data.m_typeface;
+        m_paintTextFlags = data.m_paintTextFlags;
 
 #if !USE(HARFBUZZ)
         m_font = data.m_font;