Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Unified Diff: webkit/api/src/gtk/WebFontInfo.cpp

Issue 149482: Linux: workaround a fontconfig bug. (Closed)
Patch Set: ... Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « skia/ext/SkFontHost_fontconfig_direct.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/api/src/gtk/WebFontInfo.cpp
diff --git a/webkit/api/src/gtk/WebFontInfo.cpp b/webkit/api/src/gtk/WebFontInfo.cpp
index 264efffd946b81b1f0e3707825710bc974652fa5..60fdde4ccc70c98b37abbce7d1d2c689f8688adb 100644
--- a/webkit/api/src/gtk/WebFontInfo.cpp
+++ b/webkit/api/src/gtk/WebFontInfo.cpp
@@ -66,21 +66,34 @@ WebString WebFontInfo::familyForChars(const WebUChar* characters, size_t numChar
FcDefaultSubstitute(pattern);
FcResult result;
- FcPattern* match = FcFontMatch(0, pattern, &result);
+ FcFontSet* fontSet = FcFontSort(0, pattern, 0, 0, &result);
FcPatternDestroy(pattern);
FcCharSetDestroy(cset);
- if (match) {
+ if (!fontSet)
+ return WebString();
+
+ // Older versions of fontconfig have a bug where they cannot select
+ // only scalable fonts so we have to manually filter the results.
+ for (int i = 0; i < fontSet->nfont; ++i) {
+ FcPattern* current = fontSet->fonts[i];
+ FcBool isScalable;
+
+ if (FcPatternGetBool(current, FC_SCALABLE, 0, &isScalable) != FcResultMatch
+ || !isScalable)
+ continue;
+
FcChar8* family;
WebString result;
- if (FcPatternGetString(match, FC_FAMILY, 0, &family) == FcResultMatch) {
+ if (FcPatternGetString(current, FC_FAMILY, 0, &family) == FcResultMatch) {
const char* charFamily = reinterpret_cast<char*>(family);
result = WebString::fromUTF8(charFamily, strlen(charFamily));
}
- FcPatternDestroy(match);
+ FcFontSetDestroy(fontSet);
return result;
}
+ FcFontSetDestroy(fontSet);
return WebString();
}
« no previous file with comments | « skia/ext/SkFontHost_fontconfig_direct.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698