summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/android
diff options
context:
space:
mode:
authorVictoria Lease <violets@google.com>2012-05-30 15:55:30 -0700
committerVictoria Lease <violets@google.com>2012-05-31 09:58:11 -0700
commit2622fb80bac785bc80c698cc7397e160b95db1e7 (patch)
tree34533c98483631511db67deb413f444c9e9b1d58 /Source/WebCore/platform/graphics/android
parent6f60c96bbd87b5c54d89aeb23ace06ae3647e2f3 (diff)
downloadexternal_webkit-2622fb80bac785bc80c698cc7397e160b95db1e7.zip
external_webkit-2622fb80bac785bc80c698cc7397e160b95db1e7.tar.gz
external_webkit-2622fb80bac785bc80c698cc7397e160b95db1e7.tar.bz2
Fix fake bold for fallback fonts.
With no knowledge of the actual SkTypeface used to render text before render-time, the best we can do is turn fake bold on for all text and simply ignore it at render-time if the SkTypeface's style is bold. Also the complex FontPlatformData hashing mechanism needed to account for fake styles, as the versions of FontPlatformData with fake styles enabled are otherwise indistinguishable from the normal style version Bug: 6522642 Change-Id: Ic0e9f1bbd8cae9fdd3a6d1d015bb9224c8be545c
Diffstat (limited to 'Source/WebCore/platform/graphics/android')
-rw-r--r--Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp13
-rw-r--r--Source/WebCore/platform/graphics/android/fonts/FontCacheAndroid.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/fonts/FontPlatformData.h3
3 files changed, 16 insertions, 2 deletions
diff --git a/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp b/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp
index e26fa9e..7bed5bb 100644
--- a/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp
@@ -63,6 +63,7 @@ using namespace android;
namespace WebCore {
typedef std::pair<int, float> FallbackFontKey;
+
typedef HashMap<FallbackFontKey, FontPlatformData*> FallbackHash;
static void updateForFont(SkPaint* paint, const SimpleFontData* font) {
@@ -696,7 +697,17 @@ const FontPlatformData* TextRunWalker::setupComplexFont(
{
static FallbackHash fallbackPlatformData;
- FallbackFontKey key(script, platformData.size());
+ // generate scriptStyleIndex - we need unique hash IDs for each style
+ // of each script - normal, bold, italic, bolditalic. the first set of
+ // NUM_SCRIPTS are the normal style version, followed by bold, then
+ // italic, then bold italic. additional fake style bits can be added.
+ int scriptStyleIndex = script;
+ if (platformData.isFakeBold())
+ scriptStyleIndex += NUM_SCRIPTS;
+ if (platformData.isFakeItalic())
+ scriptStyleIndex += NUM_SCRIPTS << 1;
+
+ FallbackFontKey key(scriptStyleIndex, platformData.size());
FontPlatformData* newPlatformData = 0;
if (!fallbackPlatformData.contains(key)) {
diff --git a/Source/WebCore/platform/graphics/android/fonts/FontCacheAndroid.cpp b/Source/WebCore/platform/graphics/android/fonts/FontCacheAndroid.cpp
index 5696a46..4bb388c 100644
--- a/Source/WebCore/platform/graphics/android/fonts/FontCacheAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/fonts/FontCacheAndroid.cpp
@@ -175,7 +175,7 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
}
result = new FontPlatformData(tf, fontDescription.computedSize(),
- (style & SkTypeface::kBold) && !tf->isBold(),
+ (style & SkTypeface::kBold),
(style & SkTypeface::kItalic) && !tf->isItalic(),
fontDescription.orientation(),
fontDescription.textOrientation());
diff --git a/Source/WebCore/platform/graphics/android/fonts/FontPlatformData.h b/Source/WebCore/platform/graphics/android/fonts/FontPlatformData.h
index 1e46971..02a0cea 100644
--- a/Source/WebCore/platform/graphics/android/fonts/FontPlatformData.h
+++ b/Source/WebCore/platform/graphics/android/fonts/FontPlatformData.h
@@ -92,6 +92,9 @@ public:
HB_FaceRec_* harfbuzzFace() const;
SkTypeface* typeface() const { return mTypeface; }
+ bool isFakeBold() const { return mFakeBold; }
+ bool isFakeItalic() const { return mFakeItalic; }
+
private:
class RefCountedHarfbuzzFace : public RefCounted<RefCountedHarfbuzzFace> {
public: