diff options
author | Russell Brenner <russellbrenner@google.com> | 2011-11-09 15:23:16 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-11-09 15:23:16 -0800 |
commit | 5d8f08b924be7ee27891cda15c51ed2b5e20753c (patch) | |
tree | a02d57d9276973b68c5a78f2d5b33e6a2ea561a4 /Source/WebCore | |
parent | 7c7fadaed03fc262d86394fc08ae3948ebc904e1 (diff) | |
parent | 2018cbdd9add7cc6b5201f2bc8cba86e62bafc5c (diff) | |
download | external_webkit-5d8f08b924be7ee27891cda15c51ed2b5e20753c.zip external_webkit-5d8f08b924be7ee27891cda15c51ed2b5e20753c.tar.gz external_webkit-5d8f08b924be7ee27891cda15c51ed2b5e20753c.tar.bz2 |
Merge "Fix font size handling for harfbuzz hack" into ics-mr1
Diffstat (limited to 'Source/WebCore')
-rw-r--r-- | Source/WebCore/platform/graphics/android/FontAndroid.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/Source/WebCore/platform/graphics/android/FontAndroid.cpp b/Source/WebCore/platform/graphics/android/FontAndroid.cpp index 795111d..81dbdae 100644 --- a/Source/WebCore/platform/graphics/android/FontAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/FontAndroid.cpp @@ -59,6 +59,9 @@ using namespace android; namespace WebCore { +typedef std::pair<int, float> FallbackFontKey; +typedef HashMap<FallbackFontKey, FontPlatformData*> FallbackHash; + static void updateForFont(SkPaint* paint, const SimpleFontData* font) { font->platformData().setupPaint(paint); paint->setTextEncoding(SkPaint::kGlyphID_TextEncoding); @@ -456,7 +459,6 @@ private: }; static const char* paths[NUM_SCRIPTS]; - static const FontPlatformData* s_fallbackPlatformData[NUM_SCRIPTS]; void setupFontForScriptRun(); const FontPlatformData* setupComplexFont(CustomScript script, @@ -513,9 +515,6 @@ const char* TextRunWalker::paths[] = { "/system/fonts/DroidSansThai.ttf" }; -// Indexed using enum CustomScript -const FontPlatformData* TextRunWalker::s_fallbackPlatformData[] = {}; - TextRunWalker::TextRunWalker(const TextRun& run, unsigned startingX, const Font* font) : m_font(font) , m_startingX(startingX) @@ -672,17 +671,23 @@ const FontPlatformData* TextRunWalker::setupComplexFont( CustomScript script, const FontPlatformData& platformData) { - if (!s_fallbackPlatformData[script]) { + static FallbackHash fallbackPlatformData; + + FallbackFontKey key(script, platformData.size()); + FontPlatformData* newPlatformData = 0; + + if (!fallbackPlatformData.contains(key)) { SkTypeface* typeface = SkTypeface::CreateFromFile(paths[script]); - s_fallbackPlatformData[script] = new FontPlatformData(platformData, typeface); + newPlatformData = new FontPlatformData(platformData, typeface); SkSafeUnref(typeface); + fallbackPlatformData.set(key, newPlatformData); } - // If we couldn't allocate a new FontPlatformData, revert to the one passed - if (!s_fallbackPlatformData[script]) - return &platformData; + if (!newPlatformData) + newPlatformData = fallbackPlatformData.get(key); - return s_fallbackPlatformData[script]; + // If we couldn't allocate a new FontPlatformData, revert to the one passed + return newPlatformData ? newPlatformData : &platformData; } void TextRunWalker::setupFontForScriptRun() |