Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: mapping "Times" to (NOT "Nimbus") with fontconfig

  1. #1
    Join Date
    Apr 2006
    Beans
    80

    mapping "Times" to (NOT "Nimbus") with fontconfig

    As noted on this Launchpad bug page, fontconfig maps the font Times to "Nimbus Roman No9 L" by default, which doesn't render very well (in Firefox, at least). For everyday use, I'd very much like to map Times to the DejaVu or Liberation serif fonts.

    One way to accomplish this is apparently to remove gsfonts and/or delete/move /usr/share/fonts/type1/gsfonts, but the number of packages that depend on Ghostscript fonts makes that seem like a seriously bad idea.

    I think one should be able accomplish this by re-mapping the font in ~/.fonts.conf, but I haven't been able to get it to work. Here's the file I'm using:
    Code:
    <?xml version="1.0"?>
    <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
    <fontconfig>
      <alias>
        <family>Times</family>
        <prefer><family>DejaVu Serif</family></prefer>
      </alias>
    </fontconfig>
    This doesn't work at all:
    Code:
    $ sudo fc-cache
    $ fc-match times
    n021003l.pfb: "Nimbus Roman No9 L" "Regular"
    Just to make sure I was modifying the right file, I tried re-mapping the Serif font:

    Code:
    <?xml version="1.0"?>
    <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
    <fontconfig>
      <alias>
        <family>Times</family>
        <prefer><family>DejaVu Serif</family></prefer>
      </alias>
      <alias>
        <family>Serif</family>
        <prefer><family>Monospace</family></prefer>
      </alias>
    </fontconfig>
    This works fine:
    Code:
    $ fc-match serif
    DejaVuSerif.ttf: "DejaVu Serif" "Book"
    $ sudo fc-cache
    $ fc-match serif
    DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
    $ fc-match times
    n021003l.pfb: "Nimbus Roman No9 L" "Regular"
    I've tried moving ~/.fonts.conf to /etc/fonts/conf.d/00-no-nimbus.conf, /etc/fonts/conf.d/99-no-nimbus.conf, and /etc/fonts/conf.d/no-nimbus.conf: all equally useless. What am I missing here?

  2. #2
    Join Date
    Feb 2005
    Beans
    23

    Re: mapping "Times" to (NOT "Nimbus") with fontconfig

    I don't know; I'm the one who suggested moving the gsfonts folder out of the way, so I'll be interested to see if you find a better answer.

    I'm surprised that more people aren't bothered by this--don't they notice the terrible font rendering in Firefox on certain sites?

    Moving gsfonts has not caused any problem for me, except for certain cases where the Nimbus fonts would actually look better, for example rendering certain PDFs in evince.

  3. #3
    Join Date
    May 2007
    Beans
    6

    Re: mapping "Times" to (NOT "Nimbus") with fontconfig

    I am not sure who to credit this to, I think it was Steve Langasek in the bug report. The following works for me:

    0. backup /etc/fonts/conf.d/30-metric-aliases.conf
    1. sudo gedit /etc/fonts/conf.d/30-metric-aliases.conf
    2. ctrl-h, replace all
    Nimbus Roman No9 L -> DejaVu Serif
    Nimbus Sans L -> DejaVu Sans
    Nimbus Mono L -> DejaVu Sans Mono
    3. ctrl-alt-backspace to restart X
    4. fc-match Helvetica //show actual font used

    Of course this is only a temp solution as it 'breaks' the 'correct' mapping to true printer fonts. Since I never need that kind of DTP accuracy, I am OK with this.

    Edit: Sorry, forgot to suggest backing up your conf file in case you want to revert.
    Last edited by feign2; May 23rd, 2008 at 09:57 PM.

  4. #4
    Join Date
    Apr 2006
    Beans
    80

    Re: mapping "Times" to (NOT "Nimbus") with fontconfig

    feign2, Thanks a lot. Instead of modifying the aliases, I just commented out the following lines:

    Code:
    <!-- Map generics to specifics -->
    
    
    	<!-- PostScript -->
            <alias binding="same">
    	  <family>Helvetica</family>
    	  <accept>
    	  <family>Nimbus Sans L</family>
    	  </accept>
    	</alias>
    
            <alias binding="same">
    	  <family>Times</family>
    	  <accept>
    	  <family>Nimbus Roman No9 L</family>
    	  </accept>
    	</alias>
    
            <alias binding="same">
    	  <family>Courier</family>
    	  <accept>
    	  <family>Nimbus Mono L</family>
    	  </accept>
    	</alias>
    Also, it's not necessary to restart X: running fc-cache refreshes the font aliases.

    Code:
    $ fc-cache
    $ fc-match times
    LiberationSerif-Regular.ttf: "Liberation Serif" "Regular"
    Still, it seems there should be a solution that doesn't involve modifying /etc/fonts/conf.d. Why can't I override the 30-metric-aliases.conf settings in ~/.fonts.conf?

  5. #5
    Join Date
    Feb 2005
    Beans
    23

    Re: mapping "Times" to (NOT "Nimbus") with fontconfig

    Quote Originally Posted by clconway View Post
    feign2, Thanks a lot. Instead of modifying the aliases, I just commented out the following lines:
    By the way, this alternative only seems to work because you are using the Liberation fonts. Without the Liberation fonts, commenting out that section (or both sections) still left me with Nimbus. Changing the strings as in the original suggestion still worked.

    These fixes still have the same effect for me as just moving the gsfonts directory, though; i.e. there's no way to get the Nimbus fonts for the few situations where I actually do want them (PDF rendering). (Although I suppose there are fonts in gsfonts other than Nimbus that are used somewhere, I've never noticed them.)

  6. #6
    Join Date
    Apr 2006
    Beans
    80

    Re: mapping "Times" to (NOT "Nimbus") with fontconfig

    I think maybe a better solution (and the right way to close the linked bug) is to modify the above lines to:

    Code:
    <!-- Map generics to specifics -->
    
    
    	<!-- PostScript -->
           	<match target="pattern">
              <test name="family">
                <string>Helvetica</string>
              </test>
              <test name="anymetrics" qual="all" compare="not_eq">
                <bool>true</bool>
              </test>
              <edit name="family" mode="append">
                <string>Nimbus Sans L</string>
              </edit>
         	</match>
    
           	<match target="pattern">
              <test name="family">
                <string>Times</string>
              </test>
              <test name="anymetrics" qual="all" compare="not_eq">
                <bool>true</bool>
              </test>
              <edit name="family" mode="append">
                <string>Nimbus Roman No9 L</string>
              </edit>
         	</match>
    
           	<match target="pattern">
              <test name="family">
                <string>Courier</string>
              </test>
              <test name="anymetrics" qual="all" compare="not_eq">
                <bool>true</bool>
              </test>
              <edit name="family" mode="append">
                <string>Nimbus Mono L</string>
              </edit>
         	</match>
    This preserves the Postscript -> Nimbus font aliases in the case where metric-compatibility is desired and suppresses them when it isn't (i.e., anymetrics=true). This gets me:

    Code:
    $ fc-match times
    LiberationSerif-Regular.ttf: "Liberation Serif" "Regular"
    Now, since the Liberation Serif font is actually too small on my screen (a DPI issue?), I prefer the DejaVu Serif font when metrics aren't an issue. So I added the following to ~/.fonts.conf:

    Code:
      <match target="pattern">
        <test name="family">
          <string>Times</string>
        </test>
        <test name="anymetrics" qual="all" compare="eq">
          <bool>true</bool>
        </test>
        <edit name="family" mode="assign">
          <string>DejaVu Serif</string>
        </edit>
      </match>
    And:
    Code:
    $ fc-match times
    DejaVuSerif.ttf: "DejaVu Serif" "Book"
    This seems to be exactly what I want.

  7. #7
    Join Date
    Apr 2006
    Beans
    80

    Re: mapping "Times" to (NOT "Nimbus") with fontconfig

    By the way, this alternative only seems to work because you are using the Liberation fonts. Without the Liberation fonts, commenting out that section (or both sections) still left me with Nimbus. Changing the strings as in the original suggestion still worked.
    Although I prefer the DejaVu fonts to the Liberation fonts for screen-reading, it makes sense to have a metric-compatible set of alternatives installed, IMHO.

  8. #8
    Join Date
    Feb 2005
    Beans
    23

    Re: mapping "Times" to (NOT "Nimbus") with fontconfig

    EDIT: Oops, never mind, I overlooked the second part of your fix. Yeah, this looks good now.
    Last edited by incandenza; May 27th, 2008 at 05:59 PM.

  9. #9
    Join Date
    May 2006
    Beans
    471

    Re: mapping "Times" to (NOT "Nimbus") with fontconfig

    Not sure if this might help you, but did you check out in synaptic the package called: msttcorefonts ?

    The package is full of the common fonts used. Times New Roman, Courier New, etc...
    t.t.d.
    Segmentation Fault

  10. #10
    Join Date
    Feb 2005
    Beans
    23

    Re: mapping "Times" to (NOT "Nimbus") with fontconfig

    Hmm, actually I'm still having trouble here. I did the same thing in my .fonts.conf as you did, except I did all three fonts (Times, Helvetica, Courier), because I don't want to see Liberation in Firefox.

    But yet, I get Liberation in Firefox anyway. And what's more, I start getting DejaVu in evince, which should be asking for the metric version.

    In fact, there seems to be something strange here, because if I reverse the comparison from "eq" to "not_eq" in the .fonts.conf, it matches anyway. Maybe if the 'anymetrics' key doesn't exist the test is skipped or something?

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •