diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-03 23:19:26 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-03 23:19:26 +0000 |
commit | 44a97a6e13baecedccbcd87b1b32562a783c4cbc (patch) | |
tree | 885b9240f576c5258805ccbc43f73d0736c48723 /webkit/port | |
parent | f2e9cf6ede882970018fb7381e92cb201946c29d (diff) | |
download | chromium_src-44a97a6e13baecedccbcd87b1b32562a783c4cbc.zip chromium_src-44a97a6e13baecedccbcd87b1b32562a783c4cbc.tar.gz chromium_src-44a97a6e13baecedccbcd87b1b32562a783c4cbc.tar.bz2 |
Linux: use other fonts when the primary is missing glyphs
We had a bug where we weren't setting the fontdata for missing glyphs to
NULL. This caused WebKit not to try to load other fonts when glyphs
were missing.
With that fixed, we can implement the code to find a font for a given
set of code points. This uses fontconfig as it has this information
already indexed.
This fixes css2.1/t0805-c5519-brdr-r-00-a.html
Review URL: http://codereview.chromium.org/13108
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6328 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port')
-rw-r--r-- | webkit/port/platform/graphics/chromium/FontCacheLinux.cpp | 48 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/GlyphPageTreeNodeLinux.cpp | 2 |
2 files changed, 43 insertions, 7 deletions
diff --git a/webkit/port/platform/graphics/chromium/FontCacheLinux.cpp b/webkit/port/platform/graphics/chromium/FontCacheLinux.cpp index 31b4207..c8fb0f1 100644 --- a/webkit/port/platform/graphics/chromium/FontCacheLinux.cpp +++ b/webkit/port/platform/graphics/chromium/FontCacheLinux.cpp @@ -5,12 +5,16 @@ #include "config.h" #include "FontCache.h" +#include <fontconfig/fontconfig.h> + #include "AtomicString.h" #include "CString.h" +#include "Font.h" #include "FontDescription.h" #include "FontPlatformData.h" #include "Logging.h" #include "NotImplemented.h" +#include "SimpleFontData.h" #include "SkPaint.h" #include "SkTypeface.h" @@ -23,11 +27,43 @@ void FontCache::platformInit() } const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, - const UChar* characters, + const UChar* characters, int length) { - notImplemented(); - return NULL; + FcCharSet* cset = FcCharSetCreate(); + for (int i = 0; i < length; ++i) + FcCharSetAddChar(cset, characters[i]); + + FcPattern* pattern = FcPatternCreate(); + + FcValue fcvalue; + fcvalue.type = FcTypeCharSet; + fcvalue.u.c = cset; + FcPatternAdd(pattern, FC_CHARSET, fcvalue, 0); + + FcConfigSubstitute(0, pattern, FcMatchPattern); + FcDefaultSubstitute(pattern); + + FcResult result; + FcPattern* match = FcFontMatch(0, pattern, &result); + FcPatternDestroy(pattern); + + SimpleFontData* ret = NULL; + + if (match) { + FcChar8* family; + if (FcPatternGetString(match, FC_FAMILY, 0, &family) == FcResultMatch) { + FontPlatformData* fpd = + createFontPlatformData(font.fontDescription(), + AtomicString((char *) family)); + ret = new SimpleFontData(*fpd); + } + FcPatternDestroy(match); + } + + FcCharSetDestroy(cset); + + return ret; } const AtomicString& FontCache::alternateFamilyName(const AtomicString& familyName) @@ -62,7 +98,7 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD { const char* name = 0; CString s; - + if (family.length() == 0) { static const struct { FontDescription::GenericFamilyType mType; @@ -88,7 +124,7 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD s = family.string().utf8(); name = s.data(); } - + int style = SkTypeface::kNormal; if (fontDescription.weight() >= FontWeightBold) style |= SkTypeface::kBold; @@ -109,7 +145,7 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD } AtomicString FontCache::getGenericFontForScript(UScriptCode script, - const FontDescription&) + const FontDescription& descript) { notImplemented(); return AtomicString(); diff --git a/webkit/port/platform/graphics/chromium/GlyphPageTreeNodeLinux.cpp b/webkit/port/platform/graphics/chromium/GlyphPageTreeNodeLinux.cpp index fd5aa4e..65b02c7 100644 --- a/webkit/port/platform/graphics/chromium/GlyphPageTreeNodeLinux.cpp +++ b/webkit/port/platform/graphics/chromium/GlyphPageTreeNodeLinux.cpp @@ -63,7 +63,7 @@ bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned b unsigned allGlyphs = 0; // track if any of the glyphIDs are non-zero for (unsigned i = 0; i < length; i++) { - setGlyphDataForIndex(offset + i, glyphs[i], fontData); + setGlyphDataForIndex(offset + i, glyphs[i], glyphs[i] ? fontData : NULL); allGlyphs |= glyphs[i]; } return allGlyphs != 0; |