OLD | NEW |
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 FcValue fcvalue; | 55 FcValue fcvalue; |
56 fcvalue.type = FcTypeCharSet; | 56 fcvalue.type = FcTypeCharSet; |
57 fcvalue.u.c = cset; | 57 fcvalue.u.c = cset; |
58 FcPatternAdd(pattern, FC_CHARSET, fcvalue, FcFalse); | 58 FcPatternAdd(pattern, FC_CHARSET, fcvalue, FcFalse); |
59 | 59 |
60 fcvalue.type = FcTypeBool; | 60 fcvalue.type = FcTypeBool; |
61 fcvalue.u.b = FcTrue; | 61 fcvalue.u.b = FcTrue; |
62 FcPatternAdd(pattern, FC_SCALABLE, fcvalue, FcFalse); | 62 FcPatternAdd(pattern, FC_SCALABLE, fcvalue, FcFalse); |
63 | 63 |
64 if (preferredLocale) { | 64 if (preferredLocale && strlen(preferredLocale)) { |
65 FcLangSet* langset = FcLangSetCreate(); | 65 FcLangSet* langset = FcLangSetCreate(); |
66 FcLangSetAdd(langset, reinterpret_cast<const FcChar8 *>(preferredLocale)
); | 66 FcLangSetAdd(langset, reinterpret_cast<const FcChar8 *>(preferredLocale)
); |
67 FcPatternAddLangSet(pattern, FC_LANG, langset); | 67 FcPatternAddLangSet(pattern, FC_LANG, langset); |
68 FcLangSetDestroy(langset); | 68 FcLangSetDestroy(langset); |
69 } | 69 } |
70 | 70 |
71 FcConfigSubstitute(0, pattern, FcMatchPattern); | 71 FcConfigSubstitute(0, pattern, FcMatchPattern); |
72 FcDefaultSubstitute(pattern); | 72 FcDefaultSubstitute(pattern); |
73 | 73 |
| 74 // Default substitution reintroduces an FC_LANG entry, |
| 75 // which causes sorting order to change. |
| 76 if (!preferredLocale || !strlen(preferredLocale)) |
| 77 FcPatternDel(pattern, FC_LANG); |
| 78 |
74 FcResult result; | 79 FcResult result; |
75 FcFontSet* fontSet = FcFontSort(0, pattern, 0, 0, &result); | 80 FcFontSet* fontSet = FcFontSort(0, pattern, 0, 0, &result); |
76 FcPatternDestroy(pattern); | 81 FcPatternDestroy(pattern); |
77 FcCharSetDestroy(cset); | 82 FcCharSetDestroy(cset); |
78 | 83 |
79 if (!fontSet) { | 84 if (!fontSet) { |
80 fallbackFont->name = WebCString(); | 85 fallbackFont->name = WebCString(); |
81 fallbackFont->isBold = false; | 86 fallbackFont->isBold = false; |
82 fallbackFont->isItalic = false; | 87 fallbackFont->isItalic = false; |
83 return; | 88 return; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 213 } |
209 | 214 |
210 // FontConfig doesn't provide parameters to configure whether subpixel | 215 // FontConfig doesn't provide parameters to configure whether subpixel |
211 // positioning should be used or not, so we just use a global setting. | 216 // positioning should be used or not, so we just use a global setting. |
212 out->useSubpixelPositioning = useSubpixelPositioning; | 217 out->useSubpixelPositioning = useSubpixelPositioning; |
213 | 218 |
214 FcPatternDestroy(match); | 219 FcPatternDestroy(match); |
215 } | 220 } |
216 | 221 |
217 } // namespace blink | 222 } // namespace blink |
OLD | NEW |