Published On: February 24, 2013|Categories: Linux|Tags: , , , , |

Roboto font comes from Android and Google designed it really well. It looks awesome on desktops and laptops. But getting it working as a default system font in Linux is quite a task because the font package of Roboto available has multiple font forms declaring same type of text style.

The standard Roboto package consists of following fonts:

  • Roboto-BlackItalic
  • Roboto-Black
  • Roboto-BoldCondensedItalic
  • Roboto-BoldCondensed
  • Roboto-BoldItalic
  • Roboto-Bold
  • Roboto-CondensedItalic
  • Roboto-Condensed
  • Roboto-Italic
  • Roboto-LightItalic
  • Roboto-Light
  • Roboto-MediumItalic
  • Roboto-Medium
  • Roboto-Regular
  • Roboto-ThinItalic
  • Roboto-Thin

Now the problem is, Roboto Black, Roboto Regular and Roboto Medium, are selected as candidates for the standard font. See the output below:

Read the style field of each font in the above output, you’ll see “Regular” in the field for Roboto-Regular.ttf and Roboto-Medium.ttf. But note another parameter, the weight of font. Robot-Black and Regular declare it as 80 while Medium declares it as 100.

Font selection happens in the alphabetical order first matching weight and then style. The weight for “Regular” size is 80. So the first font selected would be Roboto-Black, since it declares weight as 80 and appears before Roboto-Regular and Roboto-Medium in alphabetical order.
If you delete Roboto-Black, it will match Roboto-Medium which declares a weight of 100, but has “Regular” in the style specification.

The problem is, both these fonts Black and Medium are just too bold for daily use. You just can’t distinguish between bold and normal text and this causes ridiculous amount of confusion in applications like Thunderbird which use bold text to mark unread message and normal text otherwise.

To deal with this, a slight modification is needed in your font configuration file as follows –

If you add the above configuration to your fontconfig, it will blacklist Roboto Lt font with weight 100 (which is Medium) and Roboto Bk font which is Roboto Black. See the earlier fc-query output if you’re interested in how I got these values.

And here’s my /etc/fonts/local.conf:

Just ensure that this configuration is not overridden in any file /etc/fonts/conf.d. A simple way would be to clean up /etc/fonts/conf.d and keep the bare minimum you need.

Some screenshots for Roboto font as requested by Zachary Potter:

Process Monitor

roboto_thunderbird

roboto_dolphin

13 Comments

  1. wafel December 16, 2013 at 9:43 PM - Reply

    Doesn’t work. It seems in version 1.2 of font, bold and medium variants has only one family name, not Roboto LT and Roboto Bk, so fontconfig rule cannot block them.

    • nilesh December 16, 2013 at 9:50 PM

      Yes, that’s right.
      I didn’t get time to update the post, but here’s the modified configuration I’m using –

      http://pastebin.kde.org/plmoylcce

    • BubuXP January 5, 2014 at 8:39 AM

      I usually don’t blacklist fonts.
      With version 1.2 now I got this problem in my system: Thin looks like Light, and Regular looks like Black too.
      Looking for fonts properties, now every non-condensed fonts has:

      family: “Roboto”

      while each fonts specific fields are (in order of boldness):

      style: “Thin”
      fullname: “Roboto Thin”
      weight: 50

      style: “Light”
      fullname: “Roboto Light”
      weight: 50

      style: “Regular”
      fullname: “Roboto Regular”
      weight: 80

      style: “Medium”
      fullname: “Roboto Medium”
      weight: 100

      style: “Bold”
      fullname: “Roboto Bold”
      weight: 200

      style: “Black”
      fullname: “Roboto Black”
      weight: 80

      The weights in fontconfig http://cgit.freedesktop.org/fontconfig/tree/fontconfig/fontconfig.h#n129 are defined this way:

      thin=0
      extralight=ultralight=40
      light=50
      book=75
      regular=normal=80
      medium=100
      demibold=semibold=180
      bold=200
      extrabold=ultrabold=205
      black=heavy=210
      extrablack=ultrablack=215

      (intermediate values can be used).

      Adjusting the wrong values via fontconfig could fix my problem:

      ———————————————

      Roboto Thin

      0

      Roboto Thin Italic

      0

      Roboto Black

      210

      Roboto Black Italic

      210

      ———————————————

      Other problem: Qt apps (like VLC) supports only five weights
      https://qt.gitorious.org/qt/qt/source/ece0bd590a06d8d8f4f922395a8e68f7b0e678e6:src/gui/text/qfont.h#L103
      that are translated from fontconfig this way:

      light = 0 ~ 75
      normal = 76 ~ 140
      demibold = 141 ~ 190
      bold = 191 ~ 205
      black = 206 ~ 215+

      This can cause fonts weights overlap. Example: Medium (100) is used instead of Regular (80) because both fall in the Qt ‘normal’ weight (76~140).
      In this case to use all the Roboto weights without blacklisting, a possible solution could be to separate them in two groups:
      Thin, Regular and Bold in the family “Roboto” (the default family name, no changes);
      Light, Medium and Black in the family “Roboto Thick” (or whatever name, as we’ll use fontconfig).
      The resulting config, including the previous weights corrections is:

      ———————————————

      Roboto Thin

      0

      Roboto Thin Italic

      0

      Roboto Light

      Roboto Thick

      Roboto Light Italic

      Roboto Thick

      Roboto Medium

      Roboto Thick

      Roboto Medium Italic

      Roboto Thick

      Roboto Black

      Roboto Thick

      210

      Roboto Black Italic

      Roboto Thick

      210

      ———————————————

      This config could be added in already existing configuration files, like /etc/fonts/local.conf or saved as /etc/fonts/conf.d/81-roboto.conf (adding the header and tags).

      Note: in Android platform source code (and I think in all Android devices too), Medium and Black aren’t included, nor used. They’re present only in the separate .zip download.

  2. Dave June 20, 2013 at 2:39 PM - Reply

    On Arch Linux the simpler method is
    pacaur -S –aur ttf-roboto

    • nilesh June 24, 2013 at 7:24 AM

      Somebody has done the hard work for you, nevertheless, it’s good to know.

  3. zerocrates March 28, 2013 at 10:28 AM - Reply

    The fonts seem to just declare their weights incorrectly internally, which is what messes Fontconfig up. I’ve tried to report it a few places, with little luck. Maybe it’s only the “OS/2” older-style data that’s wrong, but that’s what Fontconfig seems to use.

    • nilesh March 28, 2013 at 10:42 AM

      Google committing such a mistake doesn’t get me. Probably there’s some reason it’s that way. Don’t know.

  4. Daniel March 2, 2013 at 9:34 AM - Reply

    Thank you very much! I still prefer Droid Sans on my Laptop, but Roboto looks a lot better now!

    • nilesh March 2, 2013 at 12:32 PM

      I tried Droid Sans, but didn’t like it and found not much difference between Liberation Sans and DejaVu Sans. Or may be I was mislead by some similar configuration bug :O

  5. Alex February 28, 2013 at 12:33 AM - Reply

    No wonder Roboto was so bold! Seriously, the fontconfig developers should include these hacks in their software instead of making people write massive fonts.conf file to fix their issues (disabling hinting for Microsoft fonts at low sizes, for example)

    • nilesh February 28, 2013 at 12:36 AM

      I took clue from Android. Font is not as bold as you see with default config in the OS.

  6. Zachary Potter February 25, 2013 at 4:04 AM - Reply

    I’d love to see a couple of screenshots before trying this!

    • nilesh February 25, 2013 at 4:19 AM

      Updated, hope that helps 🙂

Comments

This site uses Akismet to reduce spam. Learn how your comment data is processed.