Font size difference between Windows and Linux

Hi all,

I’m having an issue with difference in font size between windows and Linux, using the “Europa Full Map” module. The module designer has set a “Factors” label which is a text label added to the bottom of each counter. The font that has been chosen for this label is “Sans Serif” size 24. Here’s a screen shot of the relevant part of the prototype definition:

image

On the designers screen (he is using Windows), this makes the text label fit the space on the counter like this:

image

However on my system, which runs Linux, the text appears in a noticeably larger font, and overflows the available space on the counter, like this:

image

Is there anything that I can do to make sure that I’m using exactly the same font and font size as the designer? I suspect that between the two systems, “Sans Serif” is a font class and the actual font being picked on each system is different. Can we force the use of a specific (truetype or other) font?

To answer my own question:

Create a file called ~/.config/fontconfig/fonts.conf

Include this:

<?xml version="1.0"?><!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
 <dir>~/.fonts</dir>
<alias>
    <family>Sans Serif</family>
    <prefer>
        <family>Roboto</family>
    </prefer>
</alias>
<alias>
    <family>sans-serif</family>
    <prefer>
        <family>Roboto</family>
    </prefer>
</alias>
</fontconfig>

Now I’m not sure if “Roboto” is the correct font but it seems to fit better and be closer to the font in use on Windows. I guess that Windows might use Arial but that’s a Microsoft font and not free. Roboto is by Google and is free.

2 Likes

I guess the Sans Serif font used is set by your theme - depending on the GUI you use. For GNOME, you can probably also set it via gnome-tweaks.

Free (as in beer and speech) alternatives to Arial (which is free - as in beer - to use and installs with sudo apt install ttf-mscorefonts-installer) are

  • Liberation Sans (same metric as Arial) - apt install fonts-liberation
  • OpenSans - apt install texlive-fonts-extra
  • Noto (newer version of Roboto) - apt install fonts-noto
  • Arimo (same metric as Arial) apt install fonts-croscore
  • … and countless others

Note that you may be able to do a per-application setting with something like

<?xml version="1.0"?><!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="pattern">
    <test name="prgname" compare="eq">
      <string>java</string>
    </test>
    <test name="family" compare="contains">
      <string>Sans Serif</string>
    </test>
    <edit mode="assign" name="family" binding="same">
      <string>Liberation Sans</string>
    </edit>
  </match>
</fontconfig>

or similar. Or you could do

FONTCONFIG_FILE=~/.config/fonts/vassal.conf vassal ...

where ~/.config/fonts/vassal.conf contains a copy of the /etc/fonts/fonts.conf and your edits.

Yours,
Christian