Hi,
I use chromium on MeeGo netbook OS. Doird font is designed for
compact
screen such as netbook. MeeGo netbook OS sets it as preferred font.
But the CJK bold font are rendered to box in chromium. It's really a
bad user experience.
I found there is a issue (
http://code.google.com/p/chromium/issues/detail?id=31232) which has same problem on Fedora Core.
I investigated this issue on Moblin/Meego which have droid font
installed (the fontconfig is very similar to Fedora Core).
From my trace of 5.0.355:
1. When Webkit wants to select a font for rendering a bold Chinese
(or
JK) character,
it calls into WebCore::FontCache::getFontDataForCharacters
(FontCacheLinux.cpp).
2. the ChromiumBridge::getFontFamilyForCharacters returns "Droid
Sans" family
3. then Webkit uses this family name to invoke
SkFontHost::CreateTypeface
(skia/ext/SkFontHost_fontconfig.cpp) which will try to match a font.
4. FontConfigDirect::Match (skia/ext/
SkFontHost_fontconfig_direct.cpp)
uses family
name (here is "Droid Sans") + weight (here is bold) to call
fontconfig
to match a font.
5. fontconfig returns "/usr/share/fonts/droid/DroidSans-Bold.ttf",
but
this font has
no Chinese glyph data. So when skia wants to draw it, it fails.
In my test, if we specify the lang info (here zh-cn) to call
fontconfig (the match pattern is 'Droid Sans' + 'bold' + 'zh-cn',
fontconfig will return /usr/share/fonts/droid/DroidSansFallback.ttf,
then skia will use fake bold to draw the bold Chinese character
successfully.
We can exam the current chromium (webkit) behavior by fc-match
command.
In this case, webkit choose font only family + weight (of cause, also
by italic and
scalable, for simplicity, we ignore them in this case).
fc-match -s "Droid Sans":weigth=bold
DroidSans.ttf: "Droid Sans" "Regular"
DroidSansFallback.ttf: "Droid Sans" "Regular"
...
however, DroidSans.ttf has no glyph data for CJK language
fc-match -s "Droid Sans":weigth=bold:lang=zh-cn
DroidSansFallback.ttf: "Droid Sans" "Regular"
DroidSans.ttf: "Droid Sans" "Regular"
...
DroidSansFallback.ttf has the glyph data for CJK, skia can use them
to
do fake bold rendering.
So suggest to to introduce language info when webkit invokes
fontconfig to select font.
Comments are welcome.
regards,
ningxin