23

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 found 50-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 linking user.conf to 00-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 make Helvetica 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).

2
  • I came here because I'd about to accomplish something similar. Hopefully someone has an answer... Mar 6, 2010 at 17:12
  • still looking for an answer. Mar 11, 2010 at 13:11

4 Answers 4

23

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>
2
  • 2
    Worked for me. Seems like adding the binding attribute made the difference. I am using fontconfig-2.8.0.
    – MaoPU
    Sep 20, 2010 at 13:55
  • 1
    This worked for me
    – mhmhmhmh
    Jan 8, 2011 at 13:10
4

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>
5
  • 1
    Is <alias> not just for substituting not installed fonts?
    – MaoPU
    Sep 20, 2010 at 13:54
  • 1
    @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. Mar 3, 2013 at 15:20
  • /\ No, it actually doesn't, unless the .conf file containing this rule is read first.
    – Marc.2377
    Dec 10, 2019 at 2:57
  • Hmm - that said, it does work if binding="strong" is used along with the <alias> element!
    – Marc.2377
    Dec 10, 2019 at 3:15
  • To make it work, there should be <family> inside <prefer> , it will also satisfy the DTD.
    – proski
    Jun 20, 2022 at 20:30
0

Does "fc-list" actually show "Helvetica"? What does fc-match say ? On my box (F-12) I get:

 >fc-match Helvetica
n019003l.pfb: "Nimbus Sans L" "Regular"

Maybe you have to add the aliased font to your substitution as well.

0

I ran into a similar problem when trying to alias Helvetica as sans-serif family. For anyone hitting the same issue look at system configuration in /etc/fonts/conf.d/ which will contain links to files from /etc/fonts/conf.avail. I had to remove a lot of those aliases to get deterministic behaviour.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .