summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell Brenner <russellbrenner@google.com>2011-11-03 16:22:00 -0700
committerRussell Brenner <russellbrenner@google.com>2011-11-08 10:52:11 -0800
commit2018cbdd9add7cc6b5201f2bc8cba86e62bafc5c (patch)
treee359e4f0eeb3fe7021394c5132099b654dc10c56
parent54464c408c893079c1486aec03329f1de8ec6a29 (diff)
downloadexternal_webkit-2018cbdd9add7cc6b5201f2bc8cba86e62bafc5c.zip
external_webkit-2018cbdd9add7cc6b5201f2bc8cba86e62bafc5c.tar.gz
external_webkit-2018cbdd9add7cc6b5201f2bc8cba86e62bafc5c.tar.bz2
Fix font size handling for harfbuzz hack
Complex languages (Arabic, Thai, etc.) currently need to override the base font (e.g. Roboto) with an explicitly loaded copy of the right fallback font (e.g. DroidNaskh). To keep from running out of file descriptors, a caching mechanism was put in place, but the cached data contained the font size, so the first size seen on the page was applied to all subsequent renderings of that font, regardless of the size requested. Size is now also considered in the cache. Bug: 5509443 Change-Id: I616954980122e89da14ce86efe99d5e4343a40c2
-rw-r--r--Source/WebCore/platform/graphics/android/FontAndroid.cpp25
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 3528d47..1e64873 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);
@@ -454,7 +457,6 @@ private:
};
static const char* paths[NUM_SCRIPTS];
- static const FontPlatformData* s_fallbackPlatformData[NUM_SCRIPTS];
void setupFontForScriptRun();
const FontPlatformData* setupComplexFont(CustomScript script,
@@ -509,9 +511,6 @@ const char* TextRunWalker::paths[] = {
"/system/fonts/DroidSansHebrew-Bold.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)
@@ -668,17 +667,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()