2009-06-25 Adam Langley <agl@google.com>
authoragl@chromium.org <agl@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Jun 2009 21:15:23 +0000 (21:15 +0000)
committeragl@chromium.org <agl@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Jun 2009 21:15:23 +0000 (21:15 +0000)
        Reviewed by Darin Fisher.

        https://bugs.webkit.org/show_bug.cgi?id=26529

        This is hopefully the last step before our renderers can run
        cleanly in a chroot.

        WebKit needs to be able to ask for the correct font to use in
        the case that the current font doesn't include glyphs for
        certain code points. Currently we make a fontconfig call in our
        WebKit port to handle this.

        This patch changes this so that the call is sent our via
        ChromiumBridge.

        http://codereview.chromium.org/132007

        This should not affect any layout tests.

        * platform/chromium/ChromiumBridge.h:
        * platform/graphics/chromium/FontCacheLinux.cpp:
        (WebCore::FontCache::getFontDataForCharacters):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@45191 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/chromium/ChromiumBridge.h
WebCore/platform/graphics/chromium/FontCacheLinux.cpp

index 23316571dce348dcb11885fecd8b8c6a060ad9f6..d99fecf1d5b80c86f829d07e56fe4da4636be6e1 100644 (file)
@@ -1,3 +1,28 @@
+2009-06-25  Adam Langley  <agl@google.com>
+
+        Reviewed by Darin Fisher.
+
+        https://bugs.webkit.org/show_bug.cgi?id=26529
+
+        This is hopefully the last step before our renderers can run
+        cleanly in a chroot.
+
+        WebKit needs to be able to ask for the correct font to use in
+        the case that the current font doesn't include glyphs for
+        certain code points. Currently we make a fontconfig call in our
+        WebKit port to handle this.
+
+        This patch changes this so that the call is sent our via
+        ChromiumBridge.
+
+        http://codereview.chromium.org/132007
+
+        This should not affect any layout tests.
+
+        * platform/chromium/ChromiumBridge.h:
+        * platform/graphics/chromium/FontCacheLinux.cpp:
+        (WebCore::FontCache::getFontDataForCharacters):
+
 2009-06-25  Albert J. Wong  <ajwong@chromium.org>
 
         Reviewed by David Levin.
index 75e9103978bb5d9976c48a3907564aeb2ec53ba6..ac036868c8d619bbba3e1b33d90b3f28be4d4d50 100644 (file)
@@ -86,6 +86,9 @@ namespace WebCore {
 #if PLATFORM(WIN_OS)
         static bool ensureFontLoaded(HFONT font);
 #endif
+#if PLATFORM(LINUX)
+        static String getFontFamilyForCharacters(const UChar*, size_t numCharacters);
+#endif
 
         // Forms --------------------------------------------------------------
         static void notifyFormStateChanged(const Document*);
index 36d4a1c97d89be3093b6b14ef60c12cd432ac6c3..3fe1561a66b1de213736b6a7a603ccff6848f4c5 100644 (file)
@@ -31,9 +31,8 @@
 #include "config.h"
 #include "FontCache.h"
 
-#include <fontconfig/fontconfig.h>
-
 #include "AtomicString.h"
+#include "ChromiumBridge.h"
 #include "CString.h"
 #include "Font.h"
 #include "FontDescription.h"
@@ -59,41 +58,12 @@ const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font,
                                                           const UChar* characters,
                                                           int length)
 {
-    FcCharSet* cset = FcCharSetCreate();
-    for (int i = 0; i < length; ) {
-        UChar32 ucs4 = 0;
-        U16_NEXT(characters, i, length, ucs4);
-        FcCharSetAddChar(cset, ucs4);
-    }
-
-    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 = 0;
-
-    if (match) {
-        FcChar8* family;
-        if (FcPatternGetString(match, FC_FAMILY, 0, &family) == FcResultMatch) {
-            AtomicString fontFamily(reinterpret_cast<char*>(family));
-            ret = getCachedFontData(getCachedFontPlatformData(font.fontDescription(), fontFamily, false));
-        }
-        FcPatternDestroy(match);
-    }
-
-    FcCharSetDestroy(cset);
+    String family = ChromiumBridge::getFontFamilyForCharacters(characters, length);
+    if (family.isEmpty())
+        return 0;
 
-    return ret;
+    AtomicString atomicFamily(family);
+    return getCachedFontData(getCachedFontPlatformData(font.fontDescription(), atomicFamily, false));
 }
 
 FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)