Bug 118727 - Patch for fontconfig to let cairo/gtk 2.8.x support artificial bold font.
Summary: Patch for fontconfig to let cairo/gtk 2.8.x support artificial bold font.
Status: RESOLVED FIXED
Alias: None
Product: SUSE LINUX 10.0
Classification: openSUSE
Component: Basesystem (show other bugs)
Version: RC 4
Hardware: Other All
: P5 - None : Normal
Target Milestone: ---
Assignee: Mike Fabian
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-25 07:08 UTC by Zhe Su
Modified: 2005-09-29 10:29 UTC (History)
0 users

See Also:
Found By: Other
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
The patch for fontconfig to let cairo/gtk support artificial bold font. (869 bytes, patch)
2005-09-25 07:11 UTC, Zhe Su
Details | Diff
A new patch. (1.27 KB, patch)
2005-09-25 10:25 UTC, Zhe Su
Details | Diff
artificial-bold-italic.html (2.58 KB, text/plain)
2005-09-27 11:05 UTC, Mike Fabian
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zhe Su 2005-09-25 07:08:30 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.
Comment 1 Zhe Su 2005-09-25 07:11:27 UTC
Created attachment 50791 [details]
The patch for fontconfig to let cairo/gtk support artificial bold font.
Comment 2 Zhe Su 2005-09-25 10:25:30 UTC
Created attachment 50792 [details]
A new patch.

The previous one will break firefox.
Comment 3 Mike Fabian 2005-09-26 16:30:42 UTC
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>

Comment 4 Mike Fabian 2005-09-26 16:42:34 UTC
Zhe,

which application can I use for testing whether it works well with
cairo?
Comment 5 Mike Fabian 2005-09-26 18:04:06 UTC
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.



Comment 6 Mike Fabian 2005-09-26 18:11:32 UTC
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".

Comment 7 Mike Fabian 2005-09-26 18:29:54 UTC
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.
Comment 8 Mike Fabian 2005-09-26 18:43:51 UTC
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.
Comment 9 Zhe Su 2005-09-27 00:23:56 UTC
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.
Comment 10 Mike Fabian 2005-09-27 10:31:54 UTC
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.

Comment 11 Mike Fabian 2005-09-27 10:51:41 UTC
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".

Comment 12 Mike Fabian 2005-09-27 11:05:18 UTC
Created attachment 50926 [details]
artificial-bold-italic.html

Test .html page to illustrates what happens on www.linuxsir.org.
Comment 13 Mike Fabian 2005-09-27 11:08:39 UTC
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.

Comment 14 Mike Fabian 2005-09-27 11:53:41 UTC
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.
Comment 15 Mike Fabian 2005-09-27 13:16:58 UTC
Fixed package submitted to STABLE.
Comment 16 Mike Fabian 2005-09-27 13:49:07 UTC
Packages for SuSE Linux 10.0 uploaded to

ftp://ftp.suse.com/pub/projects/m17n/10.0/RPMS/
Comment 17 Mike Fabian 2005-09-27 13:59:36 UTC
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.

Comment 18 Mike Fabian 2005-09-27 14:00:41 UTC
Zhe, do you think we need a YOU update for this?

Comment 19 Zhe Su 2005-09-28 00:53:54 UTC
Yes, I think YOU update is necessary.
Comment 20 Mike Fabian 2005-09-28 21:06:37 UTC
NEEDINFO → Andreas Jaeger <aj@suse.de>.

Andreas, can we make a YOU update?
Comment 21 Andreas Jaeger 2005-09-29 06:41:15 UTC
Ok, Maintenance-Tracker-2411
Comment 22 Mike Fabian 2005-09-29 09:53:17 UTC
updated package with patchinfo submitted to /work/src/done/10.0.
Comment 23 Mike Fabian 2005-09-29 10:29:44 UTC
Patch submitted upstream to the Fontconfig mailing list.

Closing as FIXED.