Font substitution with ~/.fonts.conf
Solution 1
I think the binding attribute was missing in your configuration. (see also fonts-conf). Depending on your other configuration, a binding of "same" or "strong" might probably work, while "weak" might not give you what you want.
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="pattern">
<test qual="any" name="family"><string>Helvetica</string></test>
<edit name="family" mode="assign" binding="same"><string>Droid Sans</string></edit>
</match>
</fontconfig>
Solution 2
I'd think the alias mechanism would work for this:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias>
<family>Helvetica</family>
<prefer>Droid Sans</prefer>
</alias>
</fontconfig>
Related videos on Youtube
Matteo Riva
PHP programmer & Web developer. Interests in Perl, regular expressions, database design, computer science and programming in general. Debian user since bo. Hardcore Vim lover.
Updated on September 17, 2022Comments
-
Matteo Riva over 1 year
I'm trying using ~/.fonts.conf to replace Helvetica with Droid Sans, here's the content of the file:
<?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> <match target="pattern"> <test qual="any" name="family"><string>Helvetica</string></test> <edit name="family" mode="assign"><string>Droid Sans</string></edit> </match> </fontconfig>
but no matter what, nothing seems to happen. I tried running fc-cache, I have checked in
/etc/fonts/conf.d
and I found50-user.conf
which seems to explicitly call user specific configurations.What am I missing?
Thanks
EDIT: after investigation I found out that other rules in
/etc/fonts/conf.d
overwrite user configuration, so linkinguser.conf
to00-user.conf
helped. Still it's just a partial success, since I can specify which fonts should be substituted, but the substitute of my choice is ignored: in other words, I can makeHelvetica
invalid and the system falls back to the next font (i.e. in the browser, it takes the next font specified in the style sheet, if none is present it displays standard sans-serif). -
Aaqib Nadeem over 13 yearsIs <alias> not just for substituting not installed fonts?
-
J. M. Becker about 11 years@MaoPU: I thought the same thing, but after reading the documentation, it led me to believe that that behavior is configured.
<accept>
takes precedence when font is not installed,<prefer>
takes precedence regardless if font is installed. -
Marc.2377 over 4 years/\ No, it actually doesn't, unless the
.conf
file containing this rule is read first. -
Marc.2377 over 4 yearsHmm - that said, it does work if
binding="strong"
is used along with the<alias>
element!