Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1117)

Unified Diff: Source/core/platform/graphics/FontCache.cpp

Issue 23503080: Pass DOM locale to Skia in FontCache::getFontDataForCharacter (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@fontcleanup
Patch Set: Pure Android only Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/platform/graphics/FontCache.cpp
diff --git a/Source/core/platform/graphics/FontCache.cpp b/Source/core/platform/graphics/FontCache.cpp
index 2d7403c9c82e1b4d366b50fdb8fc640de8654177..ebb97981d061296192e32c119d4ffc6418d813df 100644
--- a/Source/core/platform/graphics/FontCache.cpp
+++ b/Source/core/platform/graphics/FontCache.cpp
@@ -65,7 +65,8 @@ struct FontPlatformDataCacheKey {
WTF_MAKE_FAST_ALLOCATED;
public:
FontPlatformDataCacheKey(const AtomicString& family = AtomicString(), float size = 0, unsigned weight = 0, bool italic = false,
- bool isPrinterFont = false, FontOrientation orientation = Horizontal, FontWidthVariant widthVariant = RegularWidth)
+ bool isPrinterFont = false, FontOrientation orientation = Horizontal, FontWidthVariant widthVariant = RegularWidth,
+ const AtomicString& locale = AtomicString())
: m_size(size * s_fontSizePrecisionMultiplier)
, m_weight(weight)
, m_family(family)
@@ -73,6 +74,7 @@ public:
, m_printerFont(isPrinterFont)
, m_orientation(orientation)
, m_widthVariant(widthVariant)
+ , m_locale(locale)
{
}
@@ -83,7 +85,8 @@ public:
{
return equalIgnoringCase(m_family, other.m_family) && m_size == other.m_size
&& m_weight == other.m_weight && m_italic == other.m_italic && m_printerFont == other.m_printerFont
- && m_orientation == other.m_orientation && m_widthVariant == other.m_widthVariant;
+ && m_orientation == other.m_orientation && m_widthVariant == other.m_widthVariant
+ && m_locale == other.m_locale;
}
unsigned m_size;
@@ -93,6 +96,9 @@ public:
bool m_printerFont;
FontOrientation m_orientation;
FontWidthVariant m_widthVariant;
+ // Only set for platforms (e.g. Android) that FontCache::getFontDataForCharacter() may return different FontData
+ // for different locales of FontDescriptions.
falken 2013/09/25 08:11:51 So eventually all platforms will want this? It see
+ AtomicString m_locale;
eseidel 2013/09/25 15:51:13 So WebKit doesn't seem to key based on locale. I'
private:
// Multiplying the floating point size by 100 gives two decimal
@@ -104,12 +110,13 @@ private:
inline unsigned computeHash(const FontPlatformDataCacheKey& fontKey)
eseidel 2013/09/25 15:49:52 This is webkit's impl: http://trac.webkit.org/brow
{
- unsigned hashCodes[5] = {
- CaseFoldingHash::hash(fontKey.m_family),
+ unsigned hashCodes[6] = {
+ fontKey.m_family.isNull() ? 0 : CaseFoldingHash::hash(fontKey.m_family),
fontKey.m_size,
fontKey.m_weight,
fontKey.m_widthVariant,
- static_cast<unsigned>(fontKey.m_orientation) << 2 | static_cast<unsigned>(fontKey.m_italic) << 1 | static_cast<unsigned>(fontKey.m_printerFont)
+ static_cast<unsigned>(fontKey.m_orientation) << 2 | static_cast<unsigned>(fontKey.m_italic) << 1 | static_cast<unsigned>(fontKey.m_printerFont),
+ fontKey.m_locale.isNull() ? 0 : CaseFoldingHash::hash(fontKey.m_locale)
};
return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
}
@@ -207,9 +214,16 @@ FontPlatformData* FontCache::getFontResourcePlatformData(const FontDescription&
fontSize = fontDescription.computedSize();
else
fontSize = fontDescription.computedPixelSize();
- FontPlatformDataCacheKey key(familyName, fontSize, fontDescription.weight(), fontDescription.italic(),
- fontDescription.usePrinterFont(), fontDescription.orientation(), fontDescription.widthVariant());
+ FontPlatformDataCacheKey key(familyName, fontSize, fontDescription.weight(), fontDescription.italic(),
+ fontDescription.usePrinterFont(), fontDescription.orientation(), fontDescription.widthVariant(),
+#if OS(ANDROID)
+ // On Android FontPlatformData from different locales need to be distinguished
+ // to avoid conflict of glyphs from different locale-perferred fallback fonts.
falken 2013/09/25 08:11:51 s/perferred/preferred I think comment can use ela
+ fontDescription.locale());
+#else
+ AtomicString());
+#endif
FontPlatformData* result = 0;
bool foundResult;
FontPlatformDataCache::iterator it = gFontPlatformDataCache->find(key);

Powered by Google App Engine
This is Rietveld 408576698