diff options
author | Feng Qian <fqian@google.com> | 2009-06-17 12:12:20 -0700 |
---|---|---|
committer | Feng Qian <fqian@google.com> | 2009-06-17 12:12:20 -0700 |
commit | 5f1ab04193ad0130ca8204aadaceae083aca9881 (patch) | |
tree | 5a92cd389e2cfe7fb67197ce14b38469462379f8 /WebCore/platform/graphics/chromium/FontCacheLinux.cpp | |
parent | 194315e5a908cc8ed67d597010544803eef1ac59 (diff) | |
download | external_webkit-5f1ab04193ad0130ca8204aadaceae083aca9881.zip external_webkit-5f1ab04193ad0130ca8204aadaceae083aca9881.tar.gz external_webkit-5f1ab04193ad0130ca8204aadaceae083aca9881.tar.bz2 |
Get WebKit r44544.
Diffstat (limited to 'WebCore/platform/graphics/chromium/FontCacheLinux.cpp')
-rw-r--r-- | WebCore/platform/graphics/chromium/FontCacheLinux.cpp | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/WebCore/platform/graphics/chromium/FontCacheLinux.cpp b/WebCore/platform/graphics/chromium/FontCacheLinux.cpp index 89433e1..797825e 100644 --- a/WebCore/platform/graphics/chromium/FontCacheLinux.cpp +++ b/WebCore/platform/graphics/chromium/FontCacheLinux.cpp @@ -46,6 +46,8 @@ #include "SkTypeface.h" #include "SkUtils.h" +#include <wtf/Assertions.h> + namespace WebCore { void FontCache::platformInit() @@ -79,9 +81,8 @@ const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, if (match) { FcChar8* family; if (FcPatternGetString(match, FC_FAMILY, 0, &family) == FcResultMatch) { - FontPlatformData* fpd = - createFontPlatformData(font.fontDescription(), AtomicString((char*) family)); - ret = new SimpleFontData(*fpd); + AtomicString fontFamily(reinterpret_cast<char*>(family)); + ret = getCachedFontData(getCachedFontPlatformData(font.fontDescription(), fontFamily, false)); } FcPatternDestroy(match); } @@ -98,8 +99,26 @@ FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font) FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& description) { - static AtomicString arialStr("Arial"); - return getCachedFontPlatformData(description, arialStr); + static const AtomicString sansStr("Sans"); + static const AtomicString serifStr("Serif"); + static const AtomicString monospaceStr("Monospace"); + + FontPlatformData* fontPlatformData = 0; + switch (description.genericFamily()) { + case FontDescription::SerifFamily: + fontPlatformData = getCachedFontPlatformData(description, serifStr); + break; + case FontDescription::MonospaceFamily: + fontPlatformData = getCachedFontPlatformData(description, monospaceStr); + break; + case FontDescription::SansSerifFamily: + default: + fontPlatformData = getCachedFontPlatformData(description, sansStr); + break; + } + + ASSERT(fontPlatformData); + return fontPlatformData; } void FontCache::getTraitsInFamily(const AtomicString& familyName, @@ -146,7 +165,13 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD if (fontDescription.italic()) style |= SkTypeface::kItalic; + // FIXME: This #ifdef can go away once we're firmly using the new Skia. + // During the transition, this makes the code compatible with both versions. +#ifdef SK_USE_OLD_255_TO_256 + SkTypeface* tf = SkTypeface::CreateFromName(name, static_cast<SkTypeface::Style>(style)); +#else SkTypeface* tf = SkTypeface::Create(name, static_cast<SkTypeface::Style>(style)); +#endif if (!tf) return 0; @@ -159,11 +184,4 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD return result; } -AtomicString FontCache::getGenericFontForScript(UScriptCode script, - const FontDescription& descript) -{ - notImplemented(); - return AtomicString(); -} - } // namespace WebCore |