Chromium Code Reviews| Index: skia/ext/SkFontHost_fontconfig_direct.cpp |
| =================================================================== |
| --- skia/ext/SkFontHost_fontconfig_direct.cpp (revision 68262) |
| +++ skia/ext/SkFontHost_fontconfig_direct.cpp (working copy) |
| @@ -26,7 +26,7 @@ |
| namespace { |
| -// Equivalence classes, used to match the Liberation and Ascender fonts |
| +// Equivalence classes, used to match the Liberation and other fonts |
| // with their metric-compatible replacements. See the discussion in |
| // GetFontEquivClass(). |
| enum FontEquivClass |
| @@ -34,7 +34,13 @@ |
| OTHER, |
| SANS, |
| SERIF, |
| - MONO |
| + MONO, |
| + PMINCHO, |
| + MINCHO, |
| + PGOTHIC, |
| + GOTHIC, |
| + SIMSUN, |
| + NSIMSUN, |
| }; |
| // Match the font name against a whilelist of fonts, returning the equivalence |
| @@ -51,28 +57,62 @@ |
| // /etc/fonts/conf.d/30-metric-aliases.conf |
| // from my Ubuntu system, but we're better off being very conservative. |
| - // "Ascender Sans", "Ascender Serif" and "Ascender Sans Mono" are the |
| - // tentative names of another set of fonts metric-compatible with |
| + // Arimo, Tinos and Cousine are a set of fonts metric-compatible with |
| // Arial, Times New Roman and Courier New with a character repertoire |
| - // much larger than Liberation. Note that Ascender Sans Mono |
| - // is metrically compatible with Courier New, but the former |
| - // is sans-serif while ther latter is serif. |
| - // Arimo, Tinos and Cousine are the names of new fonts derived from and |
| - // expanded upon Ascender Sans, Ascender Serif and Ascender Sans Mono. |
| - if (strcasecmp(fontname, "Arial") == 0 || |
| - strcasecmp(fontname, "Liberation Sans") == 0 || |
| - strcasecmp(fontname, "Arimo") == 0 || |
| - strcasecmp(fontname, "Ascender Sans") == 0) { |
| - return SANS; |
| - } else if (strcasecmp(fontname, "Times New Roman") == 0 || |
| - strcasecmp(fontname, "Liberation Serif") == 0 || |
| - strcasecmp(fontname, "Tinos") == 0 || |
| - strcasecmp(fontname, "Ascender Serif") == 0) { |
| - return SERIF; |
| - } else if (strcasecmp(fontname, "Courier New") == 0 || |
| - strcasecmp(fontname, "Cousine") == 0 || |
| - strcasecmp(fontname, "Ascender Sans Mono") == 0) { |
| - return MONO; |
| + // much larger than Liberation. Note that Cousine is metrically |
| + // compatible with Courier New, but the former is sans-serif while |
| + // the latter is serif. |
| + |
| + |
| + struct FontEquivMap { |
| + FontEquivClass clazz; |
| + const char name[40]; |
| + }; |
| + |
| + static const FontEquivMap kFontEquivMap[] = { |
| + { SANS, "Arial" }, |
| + { SANS, "Arimo" }, |
| + { SANS, "Liberation Sans" }, |
| + |
| + { SERIF, "Times New Roman" }, |
| + { SERIF, "Tinos" }, |
| + { SERIF, "Liberation Serif" }, |
| + |
| + { MONO, "Courier New" }, |
| + { MONO, "Cousine" }, |
| + { MONO, "Liberation Mono" }, |
| + |
| + { PMINCHO, "MS PMincho" }, |
| + { PMINCHO, "MS P明朝" }, |
|
Evan Martin
2010/12/14 18:04:21
I worry that people's editors will eat these UTF-8
|
| + { PMINCHO, "IPAPMincho" }, |
| + |
| + { MINCHO, "MS Mincho" }, |
| + { MINCHO, "MS 明朝" }, |
| + { MINCHO, "IPAMincho" }, |
| + |
| + { PGOTHIC, "MS PGothic" }, |
| + { PGOTHIC, "MS Pゴシック" }, |
| + { PGOTHIC, "IPAPGothic" }, |
| + |
| + { GOTHIC, "MS Gothic" }, |
| + { GOTHIC, "MS ゴシック" }, |
| + { GOTHIC, "IPAGothic" }, |
| + |
| + { SIMSUN, "Simsun" }, |
| + { SIMSUN, "宋体" }, |
| + { SIMSUN, "Song ASC" }, |
| + |
| + { NSIMSUN, "NSimsun" }, |
| + { NSIMSUN, "新宋体" }, |
| + { NSIMSUN, "N Song ASC" }, |
| + }; |
| + |
| + static const size_t kFontCount = |
| + sizeof(kFontEquivMap)/sizeof(kFontEquivMap[0]); |
| + |
| + for (size_t i = 0; i < kFontCount; ++i) { |
|
jungshik at Google
2010/12/11 01:10:50
Evan, do you think I'd better make a (hash)map onc
Evan Martin
2010/12/14 18:04:21
I think whichever implementation is simpler would
|
| + if (strcasecmp(kFontEquivMap[i].name, fontname) == 0) |
| + return kFontEquivMap[i].clazz; |
| } |
| return OTHER; |
| } |