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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « skia/ext/SkFontHost_fontconfig_direct.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 FcPatternAdd(pattern, FC_CHARSET, fcvalue, 0); 59 FcPatternAdd(pattern, FC_CHARSET, fcvalue, 0);
60 60
61 fcvalue.type = FcTypeBool; 61 fcvalue.type = FcTypeBool;
62 fcvalue.u.b = FcTrue; 62 fcvalue.u.b = FcTrue;
63 FcPatternAdd(pattern, FC_SCALABLE, fcvalue, 0); 63 FcPatternAdd(pattern, FC_SCALABLE, fcvalue, 0);
64 64
65 FcConfigSubstitute(0, pattern, FcMatchPattern); 65 FcConfigSubstitute(0, pattern, FcMatchPattern);
66 FcDefaultSubstitute(pattern); 66 FcDefaultSubstitute(pattern);
67 67
68 FcResult result; 68 FcResult result;
69 FcPattern* match = FcFontMatch(0, pattern, &result); 69 FcFontSet* fontSet = FcFontSort(0, pattern, 0, 0, &result);
70 FcPatternDestroy(pattern); 70 FcPatternDestroy(pattern);
71 FcCharSetDestroy(cset); 71 FcCharSetDestroy(cset);
72 72
73 if (match) { 73 if (!fontSet)
74 return WebString();
75
76 // Older versions of fontconfig have a bug where they cannot select
77 // only scalable fonts so we have to manually filter the results.
78 for (int i = 0; i < fontSet->nfont; ++i) {
79 FcPattern* current = fontSet->fonts[i];
80 FcBool isScalable;
81
82 if (FcPatternGetBool(current, FC_SCALABLE, 0, &isScalable) != FcResultMatch
83 || !isScalable)
84 continue;
85
74 FcChar8* family; 86 FcChar8* family;
75 WebString result; 87 WebString result;
76 if (FcPatternGetString(match, FC_FAMILY, 0, &family) == FcResultMatch) { 88 if (FcPatternGetString(current, FC_FAMILY, 0, &family) == FcResultMatch) {
77 const char* charFamily = reinterpret_cast<char*>(family); 89 const char* charFamily = reinterpret_cast<char*>(family);
78 result = WebString::fromUTF8(charFamily, strlen(charFamily)); 90 result = WebString::fromUTF8(charFamily, strlen(charFamily));
79 } 91 }
80 FcPatternDestroy(match); 92 FcFontSetDestroy(fontSet);
81 return result; 93 return result;
82 } 94 }
83 95
96 FcFontSetDestroy(fontSet);
84 return WebString(); 97 return WebString();
85 } 98 }
86 99
87 } // namespace WebKit 100 } // namespace WebKit
OLDNEW
« 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