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).

Matteo Riva
  • 9,031
  • 3
  • 28
  • 33

4 Answers4

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>
fr_nk
  • 396
  • 2
  • 5
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>
Geoff Reedy
  • 337
  • 2
  • 2
  • 1
    Is not just for substituting not installed fonts? – MaoPU Sep 20 '10 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. `` takes precedence when font is not installed, `` takes precedence regardless if font is installed. – J. M. Becker Mar 03 '13 at 15:20
  • /\ No, it actually doesn't, unless the `.conf` file containing this rule is read first. – Marc.2377 Dec 10 '19 at 02:57
  • Hmm - that said, it *does* work if `binding="strong"` is used along with the `` element! – Marc.2377 Dec 10 '19 at 03:15
  • To make it work, there should be `` inside `` , it will also satisfy the DTD. – proski Jun 20 '22 at 20:30
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.

j605
  • 86
  • 2
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.

vasquez
  • 159
  • 6