Bugzilla – Bug 118727
Patch for fontconfig to let cairo/gtk 2.8.x support artificial bold font.
Last modified: 2005-09-29 10:29:44 UTC
The artificial bold font rendering is supported since cairo 1.0. However it depends on "embolden" option of fontconfig. The attached patch will enable this feature by adding such option in fontconfig's conf file.
Created attachment 50791 [details] The patch for fontconfig to let cairo/gtk support artificial bold font.
Created attachment 50792 [details] A new patch. The previous one will break firefox.
Zhe Su> The artificial bold font rendering is supported since cairo 1.0. However it Zhe Su> depends on "embolden" option of fontconfig. Zhe Su> The attached patch will enable this feature by adding such option in Zhe Su> fontconfig's conf file. The "embolden" options was already set in /etc/fonts/fonts.conf, you only added + <!-- It's for Xft --> + <edit name="weight" mode="assign"> + <const>bold</const> + </edit>
Zhe, which application can I use for testing whether it works well with cairo?
Mike> which application can I use for testing whether it works well with Mike> cairo? I ask because in most GTK2 applications I cannot select a bold font if a real bold version of the font in question doesn't exist. In Firefox, I can easily test by creating a .html page which uses something like <span style="font-family:'Sazanami Mincho';font-weight:bold;"> some text ... </span> But I cannot select "bold" for "Sazanami Mincho" directly in most Gnome applications like "gedit". The font selection box doesn't offer "bold" if there is no real bold.
OK, I found that "gucharmap" is useful for testing enboldening with cairo. It links only against cairo and not against xft and I can select bold for "Sazanami Mincho".
I can confirm that with the original setup in the released version of SuSE Linux 10.0, artificial emboldening works in Firefox but not in gucharmap.
But I *cannot* reproduce that your patch from comment #1 breaks firefox. It doesn't seem to matter whether I use <match target="font"> <test name="weight" compare="less_eq"> <const>medium</const> </test> <test target="pattern" name="weight" compare="more"> <const>medium</const> </test> <!-- set the embolden flag --> <edit name="embolden" mode="assign"> <bool>true</bool> </edit> <edit name="weight" mode="assign"> <const>bold</const> </edit> </match> or <match target="font"> <!-- check to see if the font is just regular --> <test name="weight" compare="less_eq"> <int>100</int> </test> <!-- check to see if the pattern requests bold --> <test target="pattern" name="weight" compare="more_eq"> <int>200</int> </test> <!-- set the embolden flag --> <edit name="embolden" mode="assign"> <bool>true</bool> </edit> <edit name="weight" mode="assign"> <const>bold</const> </edit> </match> in /etc/fonts.conf (and no artifical emboldening rule in /etc/fonts/suse-post-user.conf). In both cases artificial emboldening works both in firefox *and* in gucharmap.
With the first patch, I found that firefox couldn't show bold font for some Simplified Chinese website. For example www.linuxsir.org. The second one doesn't have such issue. I'll spend some time later to try to enhance gtk/pango to display fake bold and italic font faces for CJK fonts. Currently you only can choose a generic font face, like "Sans" etc, in order to use bold/italic font faces.
Zhe> With the first patch, I found that firefox couldn't show bold font for Zhe> some Simplified Chinese website. For example www.linuxsir.org. The Zhe> second one doesn't have such issue. Yes, indeed. I can reproduce that.
I think I understand what happens on www.linuxsir.org. The rule <match target="font"> <!-- check to see if the font is just regular --> <test name="weight" compare="less_eq"> <int>100</int> </test> <!-- check to see if the pattern requests bold --> <test target="pattern" name="weight" compare="more_eq"> <int>200</int> </test> <!-- set the embolden flag --> <edit name="embolden" mode="assign"> <bool>true</bool> </edit> <edit name="weight" mode="assign"> <const>bold</const> </edit> </match> does not work on www.linuxsir.org because this site apparently requests a weight greater than 100 but smaller than 200. If I change the rule to <match target="font"> <!-- check to see if the font is just regular --> <test name="weight" compare="less_eq"> <int>100</int> </test> <!-- check to see if the pattern requests bold --> <test target="pattern" name="weight" compare="more"> <int>100</int> </test> <!-- set the embolden flag needed for applications using cairo, e.g. gucharmap, gedit, ... --> <edit name="embolden" mode="assign"> <bool>true</bool> </edit> <!-- set weight to bold needed for applications using Xft directly, e.g. Firefox, ... --> <edit name="weight" mode="assign"> <const>bold</const> </edit> </match> it works for www.linuxsir.org as well. I think the last rule is exactly identical to <match target="font"> <test name="weight" compare="less_eq"> <const>medium</const> </test> <test target="pattern" name="weight" compare="more"> <const>medium</const> </test> <!-- set the embolden flag --> <edit name="embolden" mode="assign"> <bool>true</bool> </edit> <edit name="weight" mode="assign"> <const>bold</const> </edit> </match> "<const>medium</const>" is the same as "<int>100</int>" and "<const>bold</const>" is the same as "<int>200</int>". The difference between the rule which works for www.linuxsir.org and the rule which doesn't is that the former checks for "> 100" and the latter for ">= 200".
Created attachment 50926 [details] artificial-bold-italic.html Test .html page to illustrates what happens on www.linuxsir.org.
When comparing <test target="pattern" name="weight" compare="more"> <const>medium</const> </test> both <span style="font-weight:bold;">foo</span> and <strong>foo</strong> will work in Firefox. But when comparing <test target="pattern" name="weight" compare="more_eq"> <const>bold</const> </test> only <span style="font-weight:bold;">foo</span> works but <strong>foo</strong> does not work.
By the way, I think "font-weight:150;" in the test page attached in comment #12 is an illegal setting. I just included it to see what happens for arbitrary values of "font-weight". Looks like firefox just ignores these.
Fixed package submitted to STABLE.
Packages for SuSE Linux 10.0 uploaded to ftp://ftp.suse.com/pub/projects/m17n/10.0/RPMS/
Zhe Su> I'll spend some time later to try to enhance gtk/pango to display fake bold and Zhe Su> italic font faces for CJK fonts. Currently you only can choose a generic font Zhe Su> face, like "Sans" etc, in order to use bold/italic font faces. Good idea! But why only for CJK? There are several non-CJK fonts which lack either bold or italic or both. For example "Bitstream Vera Serif" is only available in "Roman" and "Bold" but not in italic. And "Gentium" is only available in italic, but not in bold: mfabian@magellan:~$ fc-list : | grep -i gentium Gentium:style=Regular GentiumAlt:style=Italic GentiumAlt:style=Regular Gentium:style=Italic mfabian@magellan:~$ I remember that a while ago the wife of Markus Rex needed a font with many unusual glyphs which was also available only in "Regular". Markus then asked me how to get bold and italic for that font. Therefore I think that this feature is always useful, not only for CJK. In my opinion it is always better to have emulated bold and italic than nothing if a font doesn't have real bold and italic.
Zhe, do you think we need a YOU update for this?
Yes, I think YOU update is necessary.
NEEDINFO → Andreas Jaeger <aj@suse.de>. Andreas, can we make a YOU update?
Ok, Maintenance-Tracker-2411
updated package with patchinfo submitted to /work/src/done/10.0.
Patch submitted upstream to the Fontconfig mailing list. Closing as FIXED.