Bug 8219 - user configuration files precedence problem
Summary: user configuration files precedence problem
Status: RESOLVED FIXED
Alias: None
Product: fontconfig
Classification: Unclassified
Component: library (show other bugs)
Version: 2.3
Hardware: x86 (IA32) Linux (All)
: high normal
Assignee: Keith Packard
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-10 17:08 UTC by Jose
Modified: 2006-09-10 18:22 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Jose 2006-09-10 17:08:30 UTC
I'm not sure if this is an actual bug or the behaviour was intended, I don't
know that much about fontconfig. In any case it did bug me, so here it goes. I
have freetype-2.3.2 on an x86 and an amd64, both running gentoo.

My issue is about how the user configuration files '/etc/fonts/local.conf' and
'~/.fonts.conf' get handled. 

Users have to enter their settings in either '/etc/fonts/local.conf' or
'~/.fonts.conf' and are not supposed to touch '/etc/fonts/fonts.conf' at all.
This seems like a good idea assuming that user configuration files take
precedence over the default configuration file.

So, any change I make on '/etc/fonts/local.conf' should take precedence over
/etc/fonts/fonts.conf'. And any change to '~/.fonts.conf' should take
precedence over the other two.

Looking around I saw that files '/etc/fonts/local.conf' '~/.fonts.conf' get
included inside '/etc/fonts/fonts.conf' somewhere in the middle of the file.
This means that any settings defined after the inclusion will override our user
defined settings. Instead, it seems to me that the inclusion should happen at
the end of '/etc/fonts/fonts.conf'.

I recently ran into this issue with a font that doesn't have a bold face
defined. Inside '/etc/fonts/fonts.conf' there's a section to force synthetic
emboldening of such fonts. In my particular case this synthetic emboldening
produced a huge ugly bold font. I tried to disable the synthetic emboldening for
this font by editing '/etc/fonts/local.conf' with no luck.

The problem for me was that inside of '/etc/fonts/fonts.conf' the synthetic
emboldening was defined after the inclusion of the user configuration files. So
any settings I defined about emboldening were overruled by the default
configuration.

Applying this patch to '/etc/fonts/fonts.conf' solved the issue for me:

$ diff -u fonts.conf fonts.conf.fix
--- fonts.conf  2006-09-04 16:17:30.000000000 -0600
+++ fonts.conf.fix      2006-09-04 16:19:29.000000000 -0600
@@ -241,16 +241,6 @@
                </edit>
        </match>

-<!--
-  Load per-user customization file
--->
-       <include ignore_missing="yes">~/.fonts.conf</include>
-
-<!--
-  Load local system customization file
--->
-       <include ignore_missing="yes">conf.d</include>
-       <include ignore_missing="yes">local.conf</include>

 <!--
   Provide required aliases for standard names
@@ -446,4 +436,17 @@
                </rescan>
        </config>

+
+<!--
+  Load local system customization file
+-->
+        <include ignore_missing="yes">conf.d</include>
+        <include ignore_missing="yes">local.conf</include>
+
+<!--
+  Load per-user customization file
+-->
+        <include ignore_missing="yes">~/.fonts.conf</include>
+
+
 </fontconfig>
Comment 1 Keith Packard 2006-09-10 18:22:43 UTC
You just need to set the weight to 'bold' in your ~/.fonts.conf file for this
family when bold is requested but not found. That will disable the synthetic
emboldening code. You can't just skip it; many applications will complain if
they ask for a bold font and discover that it isn't bold. Here's a snippet which
does this for Kochi Mincho.

<match target="font">
        <test name="family">
                <string>Kochi Mincho</string>
        </test>
        <!-- check to see if the font is just regular -->
        <test name="weight" compare="less_eq">
                <const>medium</const>
        </test>
        <!-- check to see if the pattern requests bold -->
        <test target="pattern" name="weight" compare="more">
                <const>medium</const>
        </test>
        <!--
         set weight to bold
         needed for applications using Xft directly, e.g. Firefox, ...
        -->
        <edit name="weight" mode="assign">
                <const>bold</const>
        </edit>
</match>


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.