Comment #77 on issue 12530 by yusu...@chromium.org: Segfault when  
ResourceBundle::GetFont fails -- more font fallback needed?
http://code.google.com/p/chromium/issues/detail?id=12530

The issue similar to kuh3h3's reproduced on trunk (r21053) with my home  
workstation
that uses Japanese locale.

yusu...@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ゴシック

(gdb) bt
#0  gfx::Font::CreateFont (font_fami...@0xbf8c9468, font_size=12) at
/home/yusukes/chromium2/src/app/gfx/font_skia.cc:90
#1  0x096f94f4 in Font (this=0xbe573a0) at
/home/yusukes/chromium2/src/app/gfx/font_gtk.cc:73
#2  0x09702e01 in ResourceBundle::LoadFontsIfNecessary (this=0xbdf0208) at
/home/yusukes/chromium2/src/app/resource_bundle.cc:162
#3  0x09703046 in ResourceBundle::GetFont (this=0xbdf0208,
style=ResourceBundle::BaseFont) at  
/home/yusukes/chromium2/src/app/resource_bundle.cc:189
#4  0x0951ecb6 in TabRendererGtk::InitResources () at
/home/yusukes/chromium2/src/chrome/browser/gtk/tabs/tab_renderer_gtk.cc:822
#5  0x095201a7 in TabRendererGtk::GetMinimumUnselectedSize () at
/home/yusukes/chromium2/src/chrome/browser/gtk/tabs/tab_renderer_gtk.cc:297
#6  0x09520a40 in TabRendererGtk::GetStandardSize () at
/home/yusukes/chromium2/src/chrome/browser/gtk/tabs/tab_renderer_gtk.cc:316
#7  0x09526765 in TabStripGtk (this=0xbe54150, model=0xbe0c348) at
/home/yusukes/chromium2/src/chrome/browser/gtk/tabs/tab_strip_gtk.cc:668
#8  0x094fd41f in BrowserWindowGtk::InitWidgets (this=0xbe0ddf0) at
/home/yusukes/chromium2/src/chrome/browser/gtk/browser_window_gtk.cc:1090
#9  0x095000e4 in BrowserWindowGtk (this=0xbe0ddf0, browser=0xbe0c310) at
/home/yusukes/chromium2/src/chrome/browser/gtk/browser_window_gtk.cc:399
#10 0x094fb8e8 in BrowserWindow::CreateBrowserWindow (browser=0xbe0c310) at
/home/yusukes/chromium2/src/chrome/browser/gtk/browser_window_factory_gtk.cc:12
#11 0x094829b6 in Browser::CreateBrowserWindow (this=0xbe0c310) at
/home/yusukes/chromium2/src/chrome/browser/browser.cc:277
#12 0x09484248 in Browser::Create (profile=0xbdf02b8) at
/home/yusukes/chromium2/src/chrome/browser/browser.cc:255
#13 0x0948edc6 in BrowserInit::LaunchWithProfile::OpenURLsInBrowser  
(this=0xbf8c9e7c,
browser=0x0, process_startup=true, ur...@0xbf8c99e4) at
/home/yusukes/chromium2/src/chrome/browser/browser_init.cc:563
#14 0x0948f476 in BrowserInit::LaunchWithProfile::OpenStartupURLs  
(this=0xbf8c9e7c,
is_process_startup=true, urls_to_op...@0xbf8c9c54) at
/home/yusukes/chromium2/src/chrome/browser/browser_init.cc:540
#15 0x0948f99c in BrowserInit::LaunchWithProfile::Launch (this=0xbf8c9e7c,
profile=0xbdf02b8, process_startup=true) at
/home/yusukes/chromium2/src/chrome/browser/browser_init.cc:431
#16 0x0948ff97 in LaunchBrowser (command_li...@0xbd6cdb8, profile=0xbdf02b8,
cur_d...@0xbf8ca66c, process_startup=true, return_code=0xbf8ca670,
browser_init=0xbf8ca64c) at
/home/yusukes/chromium2/src/chrome/browser/browser_init.cc:335
#17 0x09490eb8 in BrowserInit::ProcessCmdLineImpl (command_li...@0xbd6cdb8,
cur_d...@0xbf8ca66c, process_startup=true, profile=0xbdf02b8,  
return_code=0xbf8ca670,
browser_init=0xbf8ca64c) at
/home/yusukes/chromium2/src/chrome/browser/browser_init.cc:821
#18 0x09262b0f in BrowserInit::Start (this=0xbf8ca64c, cmd_li...@0xbd6cdb8,
cur_d...@0xbf8ca66c, profile=0xbdf02b8, return_code=0xbf8ca670) at
/home/yusukes/chromium2/src/chrome/browser/browser_init.h:39
#19 0x0925f02a in BrowserMain (paramete...@0xbf8cac00) at
/home/yusukes/chromium2/src/chrome/browser/browser_main.cc:761
#20 0x092591cf in ChromeMain (argc=1, argv=0xbf8cad64) at
/home/yusukes/chromium2/src/chrome/app/chrome_dll_main.cc:510
#21 0x0925895e in main (argc=1, argv=0xbf8cad64) at
/home/yusukes/chromium2/src/chrome/app/chrome_exe_main_gtk.cc:33

I'm using Ubuntu 9.04 with default desktop environment (Gnome), and
/usr/bin/gnome-appearance-properties command shows that my default font  
(more
precisely "Application font") is the "IPA モナー Pゴシック", that is one of  
the most
popular Japanese font on Linux. Note that the font in question,
/usr/share/fonts/truetype/ttf-ipamonafont/ipagp-mona.ttf, has two family  
names - an
English name and an internationalized (Japanese) one.

$ uname -a
Linux yusukes-desktop 2.6.28-13-generic #45-Ubuntu SMP Tue Jun 30 19:49:51  
UTC 2009
i686 GNU/Linux

$ 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

I'm not a Linux font expert, but font matching algorithm in  
FontConfigDirect::Match()
seems to be the culprit.

In Font::Font() function, the GtkSettings object returns internationalized  
font
family name, at least on my end:

(gdb) up
#1  0x096f94f4 in Font (this=0xbe573a0) at
/home/yusukes/chromium2/src/app/gfx/font_gtk.cc:73
(gdb) p font_name
$1 = (gchar *) 0xbe573f8 "IPA \343\203\242\343\203\212\343\203\274
P\343\202\264\343\202\267\343\203\203\343\202\257 12"
(gdb) call printf("%s\n", font_name)
IPA モナー Pゴシック 12
$2 = 31
(gdb) p family_name
$3 = 0xbe57470 "IPA \343\203\242\343\203\212\343\203\274
P\343\202\264\343\202\267\343\203\203\343\202\257"
(gdb) call printf("%s\n", family_name)
IPA モナー Pゴシック
$4 = 28
(gdb) call printf("%ls\n", font_family.c_str())
IPA モナー Pゴシック
$5 = 28

and the returned font name (L"IPA モナー Pゴシック") is then passed in to  
the
FontConfigDirect::Match() function:

#0  FontConfigDirect::Match (this=0xc27e240, result_family=0x0,
result_fileid=0xbfa6126c, fileid_valid=false, fileid=4294967295,  
fami...@0xbfa61278,
is_bold=0xbfa6127e, is_italic=0xbfa6127d) at
/home/yusukes/chromium2/src/skia/ext/SkFontHost_fontconfig_direct.cpp:157
#1  0x098f8ae7 in SkFontHost::CreateTypeface (familyFace=0x0,  
familyName=0xc27e204
"IPA \343\203\242\343\203\212\343\203\274
P\343\202\264\343\202\267\343\203\203\343\202\257",  
style=SkTypeface::kNormal) at
/home/yusukes/chromium2/src/skia/ext/SkFontHost_fontconfig.cpp:116
#2  0x098ec8c8 in SkTypeface::CreateFromName (name=0xc27e204 "IPA
\343\203\242\343\203\212\343\203\274
P\343\202\264\343\202\267\343\203\203\343\202\257", style=kNormal) at
/home/yusukes/chromium2/src/third_party/skia/src/core/SkTypeface.cpp:31
#3  0x096f9f3c in gfx::Font::CreateFont (font_fami...@0xbfa61608,  
font_size=12) at
/home/yusukes/chromium2/src/app/gfx/font_skia.cc:87
#4  0x096f94f4 in Font (this=0xc231eb0) at
/home/yusukes/chromium2/src/app/gfx/font_gtk.cc:73

The Match() function first tries to resolve a post_config_family from the
internationalized family name (at L.117) and gets "IPA モナー Pゴシック"  
(identical
name. it's still internationalized). Then it tries to get a  
post_match_family by
calling FcPatternGetString(match, FC_FAMILY, 0, &post_match_family) at  
L.158 and this
time it gets *English* name of the font, "IPAMonaPGothic". Since the
post_config_family and the post_match_family are not the same, the function  
returns
false and it ends up the CHECK failure.

     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;
     if (!family_names_match && !IsFallbackFontAllowed(family)) {
         FcFontSetDestroy(font_set);
         return false;
     }

I've created a small patch which should fix this by changing the logic so  
that it
tries to retrieve and compare all post_match_families in the font file. I  
believe
this patch should fix at least kuh3h3's case, though I'm not sure if it  
fixes
"Bitstream Vera Sans" cases too.

Adam, can you review http://codereview.chromium.org/155751?

--Yusuke


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
Automated mail from issue updates at http://crbug.com/
Subscription options: http://groups.google.com/group/chromium-bugs
-~----------~----~----~----~------~----~------~--~---

Reply via email to