My words on free/open source software

Tuesday, October 20, 2009

Understanding how fontconfig scan conf files

I've been fixing fonts issues in Moblin for some time, and I've to admit that GNOME fontconfig is really hard to understand.

The rules in /etc/fonts/conf.d/ are scanned in alphanumeric order. After carefully read the fontconfig user's manual, I thought that if they were processed in alphanumeric order, the later conf should overwrite the earlier conf. WRONG! But rules scanned first take precedence over rules later. Let's see how they are applied to the Pattern.

For example: if you run `fc-match sans`, the Pattern here is family="sans".

Let's say we've a 01-rulefile:
<alias>
<family>sans</family>
<prefer><family>DejaVu<family></prefer>
</alias>



After processing it the Pattern becomes:

family="DejaVu", "sans"


Then a 02-rulefile:
<alias>
<family>sans</family>
<prefer><family>Droid<family></prefer>
</alias>



After it the Pattern becomes:

family="DejaVu", "Droid", "sans"


Noted that the "Droid" from 02-rulefile is prepended to "sans", not
the whole Pattern. So 01-rulefile takes precedence over 02-rulefile.

No comments:

About Me

My photo
Santa Cruz, California, United States