Commit a5c4592b authored by jshin@chromium.org's avatar jshin@chromium.org

Add font-equivalent mapping for a few Chinese/Japanese fonts for CrOS.

The following aliases are added to be recognized in addition to what we have.

The first four are applicable to Chrome on Linux and ChromeOS. The last 
two are for Chrome OS.

IPAPMincho -> MS P Mincho
IPAMincho -> MS Mincho
IPAPGothic -> MS P Gothic
IPAGothic -> MS Gothic

Song ASC -> Simsun
N Song ASC -> NSimsun

BUG=65382,chromium-os:10182,chromium-os:8757
TEST=Install IPA fonts on Linux and make sure that Windows Japanese fonts are not installed on your machine. Also, add what's added in http://codereview.chromium.org/5695005/ to your copy of /etc/fonts/local.conf. And, load cjfontalias.html attached to http://crosbug.com/10182 to make sure that all three columns look identical (each rows should be different). 

Review URL: http://codereview.chromium.org/5578008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71295 0039d316-1c4b-4281-b951-d872f2087c98
parent c2301a9c
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
namespace { 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 // with their metric-compatible replacements. See the discussion in
// GetFontEquivClass(). // GetFontEquivClass().
enum FontEquivClass enum FontEquivClass
...@@ -34,7 +34,13 @@ enum FontEquivClass ...@@ -34,7 +34,13 @@ enum FontEquivClass
OTHER, OTHER,
SANS, SANS,
SERIF, SERIF,
MONO MONO,
PMINCHO,
MINCHO,
PGOTHIC,
GOTHIC,
SIMSUN,
NSIMSUN,
}; };
// Match the font name against a whilelist of fonts, returning the equivalence // Match the font name against a whilelist of fonts, returning the equivalence
...@@ -51,28 +57,73 @@ FontEquivClass GetFontEquivClass(const char* fontname) ...@@ -51,28 +57,73 @@ FontEquivClass GetFontEquivClass(const char* fontname)
// /etc/fonts/conf.d/30-metric-aliases.conf // /etc/fonts/conf.d/30-metric-aliases.conf
// from my Ubuntu system, but we're better off being very conservative. // from my Ubuntu system, but we're better off being very conservative.
// "Ascender Sans", "Ascender Serif" and "Ascender Sans Mono" are the // Arimo, Tinos and Cousine are a set of fonts metric-compatible with
// tentative names of another set of fonts metric-compatible with
// Arial, Times New Roman and Courier New with a character repertoire // Arial, Times New Roman and Courier New with a character repertoire
// much larger than Liberation. Note that Ascender Sans Mono // much larger than Liberation. Note that Cousine is metrically
// is metrically compatible with Courier New, but the former // compatible with Courier New, but the former is sans-serif while
// is sans-serif while ther latter is serif. // the 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 || struct FontEquivMap {
strcasecmp(fontname, "Liberation Sans") == 0 || FontEquivClass clazz;
strcasecmp(fontname, "Arimo") == 0 || const char name[40];
strcasecmp(fontname, "Ascender Sans") == 0) { };
return SANS;
} else if (strcasecmp(fontname, "Times New Roman") == 0 || static const FontEquivMap kFontEquivMap[] = {
strcasecmp(fontname, "Liberation Serif") == 0 || { SANS, "Arial" },
strcasecmp(fontname, "Tinos") == 0 || { SANS, "Arimo" },
strcasecmp(fontname, "Ascender Serif") == 0) { { SANS, "Liberation Sans" },
return SERIF;
} else if (strcasecmp(fontname, "Courier New") == 0 || { SERIF, "Times New Roman" },
strcasecmp(fontname, "Cousine") == 0 || { SERIF, "Tinos" },
strcasecmp(fontname, "Ascender Sans Mono") == 0) { { SERIF, "Liberation Serif" },
return MONO;
{ MONO, "Courier New" },
{ MONO, "Cousine" },
{ MONO, "Liberation Mono" },
// MS Pゴシック
{ PGOTHIC, "MS PGothic" },
{ PGOTHIC, "\xef\xbc\xad\xef\xbc\xb3 \xef\xbc\xb0"
"\xe3\x82\xb4\xe3\x82\xb7\xe3\x83\x83\xe3\x82\xaf" },
{ PGOTHIC, "IPAPGothic" },
// 宋体
{ SIMSUN, "Simsun" },
{ SIMSUN, "\xe5\xae\x8b\xe4\xbd\x93" },
{ SIMSUN, "Song ASC" },
// MS P明朝
{ PMINCHO, "MS PMincho" },
{ PMINCHO, "\xef\xbc\xad\xef\xbc\xb3 \xef\xbc\xb0"
"\xe6\x98\x8e\xe6\x9c\x9d"},
{ PMINCHO, "IPAPMincho" },
// MS ゴシック
{ GOTHIC, "MS Gothic" },
{ GOTHIC, "\xef\xbc\xad\xef\xbc\xb3 "
"\xe3\x82\xb4\xe3\x82\xb7\xe3\x83\x83\xe3\x82\xaf" },
{ GOTHIC, "IPAGothic" },
// MS 明朝
{ MINCHO, "MS Mincho" },
{ MINCHO, "\xef\xbc\xad\xef\xbc\xb3 \xe6\x98\x8e\xe6\x9c\x9d" },
{ MINCHO, "IPAMincho" },
// 新宋体
{ NSIMSUN, "NSimsun" },
{ NSIMSUN, "\xe6\x96\xb0\xe5\xae\x8b\xe4\xbd\x93" },
{ NSIMSUN, "N Song ASC" },
};
static const size_t kFontCount =
sizeof(kFontEquivMap)/sizeof(kFontEquivMap[0]);
// TODO(jungshik): If this loop turns out to be hot, turn
// the array to a static (hash)map to speed it up.
for (size_t i = 0; i < kFontCount; ++i) {
if (strcasecmp(kFontEquivMap[i].name, fontname) == 0)
return kFontEquivMap[i].clazz;
} }
return OTHER; return OTHER;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment