[Fontconfig] Problem when <alias> is followed by more than one <family>

Petr Gajdos pgajdos at suse.cz
Mon Feb 27 09:23:18 PST 2012


Hi,

> Can you help me understand what is happening?

I am really new to fontconfig, so please correct me if I am wrong 
somewhere; I am learning it and I have taken this bug as an 
oportunity to familiarize myself with it a little.

I think that the point is, that the fontconfig mechanism pick first 
<family> in the provided multiple family list in the alias, which 
exists in the family priority list yet and that is prepended 
(prefer), appended (accept) or appended_last (default).

For example, config like

        <alias binding="same">
                <family>font</family>
                <accept>
                        <family>foo</family>
                        <family>bar</family>
                </accept>
        </alias>
        <alias binding="same">
                <family>foo</family>    <!-- multiple family  -->
                <family>bar</family>    <!-- list of an alias -->
                <accept>
                        <family>bar1</family>
                        <family>bar2</family>
                </accept>
        </alias>
        <alias binding="same">
                <family>bar1</family>
                <prefer><family>Liberation Mono</family></prefer>
        </alias>
        <alias binding="same">
                <family>bar2</family>
                <accept><family>Droid Serif</family></accept>
        </alias>
        <alias binding="same">
                <family>bar</family>
                <prefer><family>STIXGeneral</family></prefer>
        </alias>


will result (assuming all real fonts from there installed) 
into 

$ FC_DEBUG=4 fc-match font | grep family:     # shows growing family priority list 
        family: "font"(s)
        family: "font"(s) "foo"(s) "bar"(s)                                             
   (!)  family: "font"(s) "foo"(s) "bar1"(s) "bar2"(s) "bar"(s)
        family: "font"(s) "foo"(s) "Liberation Mono"(s) "bar1"(s) "bar2"(s) "bar"(s)
        family: "font"(s) "foo"(s) "Liberation Mono"(s) "bar1"(s) "bar2"(s) "Droid Serif"(s) "bar"(s)
        family: "font"(s) "foo"(s) "Liberation Mono"(s) "bar1"(s) "bar2"(s) "Droid Serif"(s) "STIXGeneral"(s) "bar"(s)
        family: "font"(s) "foo"(s) "Liberation Mono"(s) "bar1"(s) "bar2"(s) "Droid Serif"(s) "STIXGeneral"(s) "bar"(s)
        family: "Liberation Mono"(s)
        family: "Liberation Mono"(s)

I switch order of <family>foo</family> 
and <family>bar</family> in _second_ alias to get

$ FC_DEBUG=4 fc-match font | grep family:
        family: "font"(s)
        family: "font"(s) "foo"(s) "bar"(s)
   (!)  family: "font"(s) "foo"(s) "bar"(s) "bar1"(s) "bar2"(s)
        family: "font"(s) "foo"(s) "bar"(s) "Liberation Mono"(s) "bar1"(s) "bar2"(s)
        family: "font"(s) "foo"(s) "bar"(s) "Liberation Mono"(s) "bar1"(s) "bar2"(s) "Droid Serif"(s)
        family: "font"(s) "foo"(s) "STIXGeneral"(s) "bar"(s) "Liberation Mono"(s) "bar1"(s) "bar2"(s) "Droid Serif"(s)
        family: "font"(s) "foo"(s) "STIXGeneral"(s) "bar"(s) "Liberation Mono"(s) "bar1"(s) "bar2"(s) "Droid Serif"(s)
        family: "STIXGeneral"(s)
        family: "STIXGeneral"(s)

You see from the debug output, why order of <families> in the multiple
family list in the second alias have impact on the final result.

Assuming I am right, _as_far_as_I_can_see_:
1. <default> alias isn't affected, because when any from multiple
<families> exists in the present family priority list, default family 
is _appended_ to the end of family priority list.
2. <prefer> or <accept> alias can be wrong with more complex config
of aliased families (e. g. Arial, Helvetica *); that could be maybe
improved by changing behaviour of this multiple family list aliases: 
prepend/append _each_ family in the multiple family list in the 
alias mimicking (shorthanding)

        <alias binding="same">
                <family>foo</family>
                <accept>
                        <family>bar1</family>
                        <family>bar2</family>
                </accept>
        </alias>
        <alias binding="same">
                <family>bar</family>
                <accept>
                        <family>bar1</family>
                        <family>bar2</family>
                </accept>
        </alias>

(same with <prefer>).

@list: What should I do:
0. Forget. It can't work this way.
1. Forget. Don't make conf more complex. One <family> per alias is
   perfectly ok and who believe it works with <default>, let him to 
   use it.
2. This shorthand could improve config files readability. Try 
   to check the code if you are right and if it can be implemented 
   as soon as you have time for it.


Petr


*) Enclosing log from fc-match Arial and fc-match Helvetica commands
with ~/.fonts.conf on my real system containing

  <alias binding="same">
    <family>Arial</family>
    <family>Helvetica</family>
    <prefer>
      <family>STIXGeneral</family>
    </prefer>
  </alias>

Little bit long, but you can search for "\.conf" tagged parts.
Especially interesting is of course ~/.fonts.conf.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: fc-match-arial.log
Type: text/x-log
Size: 94351 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/fontconfig/attachments/20120227/c43c1d2a/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fc-match-helvetica.log
Type: text/x-log
Size: 84194 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/fontconfig/attachments/20120227/c43c1d2a/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/fontconfig/attachments/20120227/c43c1d2a/attachment-0001.pgp>


More information about the Fontconfig mailing list