diff options
author | yusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-19 02:39:34 +0000 |
---|---|---|
committer | yusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-19 02:39:34 +0000 |
commit | 7b0c831d53de99b71eed1a09b63d205458ea63b0 (patch) | |
tree | fdd9202acada931bb1cd2eca301fd47c99bff02e /skia | |
parent | 22c10591b5c2d3ade6824b6a4e58d7e97e06a8c5 (diff) | |
download | chromium_src-7b0c831d53de99b71eed1a09b63d205458ea63b0.zip chromium_src-7b0c831d53de99b71eed1a09b63d205458ea63b0.tar.gz chromium_src-7b0c831d53de99b71eed1a09b63d205458ea63b0.tar.bz2 |
Tries to retrieve all post_match_families in the font file to support non-ascii
fonts. This patch should fix CHECK failures like this:
yusukes@yusukes-desktop:~/chromium2/src/build$ ../sconsbuild/Release/chrome
[20666:20666:544922424350:FATAL:/home/yusukes/chromium2/src/app/gfx/font_skia.cc(90)]
Check failed: tf. Could not find font: IPA モナー Pゴシック
Since some fonts have multiple font family names, the FontConfigDirect::Match()
function should try to compare post_config_family with _all_ family names in the
font, rather than with only the first (usually English) family name. For
example, a popular Japanese font called ipagpmona.ttf has two family names, an
English name and an internationalized (Japanese) one, and post_config_family for
the font can be either the English name or the Japanese name depending on the
situation.
$ showttf /usr/share/fonts/truetype/ttf-ipamonafont/ipagp-mona.ttf | egrep -A 1
-e
"platform=1 .* Family"
platform=1 plat spec encoding=0 language=0 name=1 Family
strlen=14 stroff=288 IPAMonaPGothic
--
platform=1 plat spec encoding=1 language=b name=1 Family
strlen=20 stroff=871 IPA <83><82><83>i<81>[ P<83>S<83>V<83>b<83>N
Original review URL: http://codereview.chromium.org/155751
BUG=12530
TEST=none
Review URL: http://codereview.chromium.org/159061
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21063 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r-- | skia/ext/SkFontHost_fontconfig_direct.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/skia/ext/SkFontHost_fontconfig_direct.cpp b/skia/ext/SkFontHost_fontconfig_direct.cpp index fe4dc36..a7caadb 100644 --- a/skia/ext/SkFontHost_fontconfig_direct.cpp +++ b/skia/ext/SkFontHost_fontconfig_direct.cpp @@ -152,20 +152,30 @@ bool FontConfigDirect::Match(std::string* result_family, return false; } - FcChar8* post_match_family; - FcPatternGetString(match, FC_FAMILY, 0, &post_match_family); - const bool family_names_match = - family.empty() ? - true : - strcasecmp((char *)post_config_family, (char *)post_match_family) == 0; - - FcPatternDestroy(pattern); - - if (!family_names_match && !IsFallbackFontAllowed(family)) { + if (!IsFallbackFontAllowed(family)) { + bool family_names_match = false; + for (int id = 0; id < 255; ++id) { + FcChar8* post_match_family; + if (FcPatternGetString(match, FC_FAMILY, id, &post_match_family) != + FcResultMatch) + break; + family_names_match = + family.empty() ? + true : + strcasecmp((char *)post_config_family, + (char *)post_match_family) == 0; + if (family_names_match) + break; + } + if (!family.empty() && !family_names_match) { + FcPatternDestroy(pattern); FcFontSetDestroy(font_set); return false; + } } + FcPatternDestroy(pattern); + FcChar8* c_filename; if (FcPatternGetString(match, FC_FILE, 0, &c_filename) != FcResultMatch) { FcFontSetDestroy(font_set); |