You are not logged in.

#1 2017-02-18 12:52:44

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Setting monospace, serif & sans-serif default fonts

The fonts listed as monospace, serif and sans-serif are actually font aliases (alii?) used by fontconfig; to view the actual fonts, run:

for i in monospace serif sans-serif; do fc-match $i; done

To change these to your preferred fonts, edit the file at ~/.config/fontconfig/fonts.conf and add these stanzas:

  <alias>
    <family>monospace</family>
    <prefer><family>Inconsolata</family></prefer>
  </alias>
  <alias>
    <family>serif</family>
    <prefer><family>Noto</family></prefer>
  </alias>
  <alias>
    <family>sans-serif</family>
    <prefer><family>Roboto Condensed</family></prefer>
  </alias>

The stanzas must be added between the <fontconfig> & </fontconfig> XML tags.

Substitute "Inconsolata", "Noto" & "Roboto Condensed" with the preferred fonts.

The font aliases can then be used in other configuration files and should also be picked up as the default font options.

fonts.conf can also be used to set aliases for the common MicroSoft fonts used on web pages, although BunsenLabs already includes the MS versions so this should not be needed:

https://seasonofcode.com/posts/how-to-s … linux.html

EDIT: the advice in the above link may not be the best, see this post by @cpoakes for a detailed breakdown:

https://forums.bunsenlabs.org/viewtopic … 591#p45591

Last edited by Head_on_a_Stick (2017-02-20 07:16:41)


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

#2 2017-02-18 14:30:42

cpoakes
Member
Registered: 2016-12-02
Posts: 108

Re: Setting monospace, serif & sans-serif default fonts

This works well on a per user basis. Or if you want to change the default fonts for all users (even if just root and your personal login), create /etc/fonts/local.conf with the same content.

An aside: there are matching patterns in /etc/fonts/fonts.conf substituting "sans-serif" for "sans" and "sans serif" (with the space), and "monospace" for "mono". The comments indicate "sans" and "mono" are deprecated in favor of "sans-serif" and "monospace". I cannot imagine fontconfig devs ever actually dropping these aliases, but then devs don't always think like I do. I stick to "sans-serif" for my config changes.

Offline

#3 2017-02-18 22:26:14

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Re: Setting monospace, serif & sans-serif default fonts

^ Fantastic, thanks for the tips, I have edited the OP.


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

#4 2017-02-19 02:50:20

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,087
Website

Re: Setting monospace, serif & sans-serif default fonts

bunsen-configs provides /usr/share/skel/.config/fontconfig/fonts.conf
This is what we currently ship for that section:

<!-- Set preferred serif, sans serif, and monospace fonts. -->
    <alias>
        <family>serif</family>
        <prefer>
            <family>Droid Serif</family>
        </prefer>
    </alias>
    <alias>
        <family>sans-serif</family>
        <prefer>
            <family>Droid Sans</family>
        </prefer>
    </alias>
    <alias>
        <family>sans</family>
        <prefer>
            <family>Droid Sans</family>
        </prefer>
    </alias>
    <alias>
        <family>monospace</family>
        <prefer>
            <family>Droid Sans Mono</family>
        </prefer>
    </alias>
    <alias>
        <family>mono</family>
        <prefer>
            <family>Droid Sans Mono</family>
        </prefer>
    </alias>

@HoaS thank you for pointing out that this is tweakable! Changing fonts here ensures a consistent look across the user's desktop. Let's put a link here from "list of useful how-tos". (edit: now done)

@cpoakes I didn't know about the 'sans serif' (w. space) alias - I'll add it in the next bunsen-configs upgrade.

Last edited by johnraff (2017-02-19 08:46:56)


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#5 2017-02-19 08:17:12

cpoakes
Member
Registered: 2016-12-02
Posts: 108

Re: Setting monospace, serif & sans-serif default fonts

johnraff wrote:

@cpoakes I didn't know about the 'sans serif' (w. space) alias - I'll add it in the next bunsen-configs upgrade.

While that won't be problematic, it is also not necessary. In the the fontconfig configuration sequence, it reads /etc/fonts/fonts.conf first, which in turn works through /etc/fonts/conf.d, which in turn loads ~/.config/fontconfig/fonts.conf about halfway through.

Since the "sans", "sans serif", and "mono" aliases are applied directly from /etc/fonts/fonts.config before all other rules, it is sufficient for subsequent rule stanzas to employ "sans-serif" or "monospace" - they will be utilized even if the user has specified the other aliases. It does the "right thing" without the need for redundancy.

Offline

#6 2017-02-19 08:31:59

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,087
Website

Re: Setting monospace, serif & sans-serif default fonts

cpoakes wrote:

Since the "sans", "sans serif", and "mono" aliases are applied directly from /etc/fonts/fonts.config before all other rules, it is sufficient for subsequent rule stanzas to employ "sans-serif" or "monospace" - they will be utilized even if the user has specified the other aliases. It does the "right thing" without the need for redundancy.

Ah good - that lets us simplify the user config file a bit. Thanks.


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#7 2017-02-19 08:43:47

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,087
Website

Re: Setting monospace, serif & sans-serif default fonts

NOTE for new BL users:

All BunsenLabs fonts are set to "sans-serif", "serif" or "monospace" so they will automatically use whatever fonts you have chosen in  ~/.config/fontconfig/fonts.conf. This means that openbox titles and menus, text editors etc. will all show consistent fonts. (If you want, you can still set a different font for some particular application via that app's interface.)


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#8 2017-02-19 11:43:38

ohnonot
...again
Registered: 2015-09-29
Posts: 3,484
Website

Re: Setting monospace, serif & sans-serif default fonts

Head_on_a_Stick wrote:

fonts.conf can also be used to set aliases for the common MicroSoft fonts used on web pages, although BunsenLabs already includes the MS versions so this should not be needed:

https://seasonofcode.com/posts/how-to-s … linux.html

this is the important addition imo.

the extended script would look like this:

for i in mono monospace serif sans sans-serif helvetica "helvetica neue" verdana arial "lucida grande" tahoma freesans clean "Times New Roman" "Courier New"; do echo -n "$i: " ; fc-match $i; done

and to avoid unpleasant surprises while browsing (falling back to some bitmap font for helvetica is something i experienced a few times) all types should have an entry in fonts.conf.
of course a list like this can never be complete, the internet being what it is.

Offline

#9 2017-02-20 00:55:40

cpoakes
Member
Registered: 2016-12-02
Posts: 108

Re: Setting monospace, serif & sans-serif default fonts

@ohnonot - I appreciate the extended list of web fonts. Only "Helvetica Neue", "Lucida Grande", "Verdana", and "Tahoma" are not handled by fontconfig with accurate replacements. What the hell is "clean"?

The best way to deal with missing fonts is to actually install them. The following are freely distributed ("non-free", not open source):

Verdana, Georgia - Found in the freely distributed msttfcorefonts (non-free debian package ttf-mscorefonts-installer).

Tahoma - Found in the discontinued Word 97 Viewer (wd97vwr32.exe). The license makes this freely distributable with no expiration and has no restrictions on the use of the fonts (unlike the newer Word and PowerPoint viewers after MS caught on to this loophole).  Though no longer available directly from MS, still widely available from many sources on the internet. Or an easier source, you can install libwine (jessie, a lot of bloat for a single font), font-wine (when you get to stretch), or just grab the font from the wine source repo: http://source.winehq.org/source/fonts/

Lucida Grande - Found in the discontinued Safari for Windows Version 3 Beta (SafariSetup.exe, not version 4 or 5).    The license makes this freely distributable with no expiration and no limitations on the use of the fonts (unusual for an Apple product, not true for newer versions).

Use your favorite archive manager to extract fonts from the "exe" files.

This leaves "Helvetica Neue" as the only font that needs a fontconfig alias. I'd use the metric-equivalents for "Helvetica": "Nimbus Sans L", "FreeSans", or "Tex Gyre Heros".

Edit: added wine repository for Tahoma (27 Feb 2017).

Last edited by cpoakes (2017-02-28 02:14:01)

Offline

#10 2017-02-20 00:57:43

cpoakes
Member
Registered: 2016-12-02
Posts: 108

Re: Setting monospace, serif & sans-serif default fonts

@HoaS - Sorry, but I find the SeasonOfCode recommendations to be piss-poor. First off, they map: "Times" to "Tinos" (metric equivalent for "Times New Roman"), and "Helvetica" to "Arimo" (metric equivalent for "Arial").  If you're making the effort to configure your fonts, use the best opensource alternatives (which are already installed in BL).

The metric equivalent open source replacement for "Times" is "Nimbus Roman No9 L", "FreeSerif" (the unicode extended version of "Nimbus Roman No9"), or "Tex Gyre Termes" (the version of "Nimbus Roman No9" enhanced by the Tex Gyre project). The best replacement for "Helvetica" is "Nimbus Sans L", "FreeSans" (unicode extended "Nimbus Sans"), or "Tex Gyre Heros" ("Nimbus Sans" extended by Tex Gyre). Furthermore, the gsfont and FreeFont replacements are already installed and correct translations are already handled by fontconfig (see /etc/fonts/conf.d/30-metric-aliases.conf). The SeasonOfCode recommendations actually screw up a well configured BL font system.

Additionally, the Google (croscore) fonts are unnecessary. "Arimo", "Tinos", "Cousine" are derived from Red Hat "Liberation" fonts; Ascender made minor tweaks and re-issued them to Google under a different license. But wait there's more... to resolve potential issues with the Red Hat font license of "Liberation" v1.0, the developers made "Liberation" 2.0 a verbatim copy of the Google fonts with just a name change and now use the SIL license. There is no need to install the Google fonts (fonts-croscore) when "Liberation Sans, Serif, and Mono" are identical, already installed, and already correctly translated by fontconfig. You can even ask fontconfig for the Google name and get the matching Liberation font (try "fc-match Arimo").

While fontconfig is notoriously complex, it is reasonably configured to work well with gsfonts/FreeFont/Tex Gyre plus Croscore/Liberation fonts to cover all the Apple/Adobe/MS basics.

Edit: Got ahead of myself - fonts-liberation2 (v2) with the Apache license is available in stretch; jessie still uses fonts-liberation (v1) with the RHGPL license. Fontconfig handles the Google name translation to Liberation correctly no matter which version is installed.

Last edited by cpoakes (2017-02-22 02:19:04)

Offline

#11 2017-02-20 07:15:18

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Re: Setting monospace, serif & sans-serif default fonts

cpoakes wrote:

@HoaS - Sorry, but I find the SeasonOfCode recommendations to be piss-poor.

OK, thank you very much for the recommendations, I have edited the OP to link to your post.


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

Board footer

Powered by FluxBB