How to improve Manjaro Fonts rendering

The default Fonts rendering Engine in Manjaro isn’t the best one (I live Manjaro, really a lot but the font rendering isn’t the best one I have see in my life :stuck_out_tongue: ).

To solve this there are more tutorials and blog posts on the .Net, I have only created a simple script (require the root privileges, so it will ask for the root password) that install and configure the Infinality Font Rendering Engine (http://bohoomil.com/) replacing the current one (fontconfig, freetype2 and cairo packages … ) .

To download and execute this simple script simple run the following command via Terminal:

wget http://bit.do/manopt -q -O manopt && chmod +x manopt && ./manopt

PS: also if I have just ran it on many different Manjaro versions and DEs, it’s a YOUR responsibility to use it! :slight_smile:

14 Likes

Maybe first download and study it and then execute if you understand what it does.

7 Likes

Hi @eugen-b,

it’s true :stuck_out_tongue:

This is the script core with some comments (in the “echo” commands)…

#!/bin/bash
# Manjaro Fonts Optimizer v. 0.6.1
# By Fabio Dell'Aria - fabio.dellaria@gmail.com - May/June 2016

clear

echo "Manjaro Font Optimizer v. 0.6.1"
echo "-------------------------------"

# Check if the current user is "root" otherwise restart the script with "sudo"...
[ "$(whoami)" != "root" ] && exec sudo -- "$0" "$@"

# Instruct the Script to Abort for any command error...
set -e

YES_CHAR="unknown"
SUGGESTER_REBOOT="N"
SCRIPT_FONTS_FILE="10-00manjaro-fonts-optimizer.conf"

function check_yes_char {
  YES_CHAR="$(pacman -Sddw bash --noconfirm | grep '? \[' | cut -d"[" -f2 | cut -d"/" -f1)"
}

function install_infinality {
  echo
  if ! (grep -qF "infinality-bundle" /etc/pacman.conf); then
    echo 'Updating Pacman Configuration...'
    {
      echo ''
      echo '[infinality-bundle]' 
      echo 'Server = http://bohoomil.com/repo/$arch'
      echo ''
      echo '[infinality-bundle-multilib]'
      echo 'Server = http://bohoomil.com/repo/multilib/$arch'
      echo ''
      echo '[infinality-bundle-fonts]'
      echo 'Server = http://bohoomil.com/repo/fonts'
    } >> /etc/pacman.conf
    echo 'Done'
    echo
  fi;

  echo 'Updating Pacman Keys...'
  pacman-key -r "962DDE58"
  pacman-key --lsign-key "962DDE58"
  echo 'Done'
  echo

  echo 'Updating Pacman Packages list...'
  pacman -Syyu --noconfirm
  echo 'Done'
  echo

  echo 'Installing NEW Fonts Engine and Fonts...'
  check_yes_char
  yes "$YES_CHAR" | pacman -S --confirm --needed freetype2-infinality-ultimate fontconfig-infinality-ultimate cairo-infinality-ultimate
  echo 'Done'
  echo

  echo 'Configuring NEW Fonts Engine...'
  yes "1" | fc-presets set || :
  echo 'Done'
  echo

  SUGGESTER_REBOOT="Y"
}

function remove_infinality {
  echo
  if  (grep -qF "infinality-bundle" /etc/pacman.conf); then
    echo 'Updating Pacman Configuration...'
    sed -i '/infinality-bundle/d' /etc/pacman.conf
    sed -i '/bohoomil.com/d' /etc/pacman.conf
    cat -s /etc/pacman.conf > /tmp/pac-conf && mv /tmp/pac-conf /etc/pacman.conf
    echo 'Done'
    echo
  fi
  
  echo 'Updating Pacman Keys...'
  pacman-key -d "962DDE58" || :
  echo 'Done'
  echo

  echo 'Updating Pacman Packages list...'
  pacman -Syyu
  echo 'Done'
  echo

  echo 'Installing ORIGINAL Fonts Engine...'
  check_yes_char
  yes "$YES_CHAR" | pacman -S --confirm --asdeps freetype2 fontconfig cairo
  find -L /etc/fonts/conf.d/ -type l -delete
  echo 'Done'
  echo

  SUGGESTER_REBOOT="Y"
}

function install_configuration_files {
  echo
  echo 'Downloading Required Fonts...'
  wget -q --show-progress http://commondatastorage.googleapis.com/chromeos-localmirror/distfiles/croscorefonts-1.31.0.tar.bz2 -O /tmp/chrome-fonts.tar.bz2
  echo 'Done'
  echo

  echo 'Installing Required Fonts...'
  pacman -S --needed ttf-bitstream-vera
  bzip2 -dc /tmp/chrome-fonts.tar.bz2 | tar xf - --directory /tmp/
  chmod 644 /tmp/croscorefonts-1.31.0/*
  chown root:root /tmp/croscorefonts-1.31.0/*
  mv -f /tmp/croscorefonts-1.31.0/* /usr/share/fonts/TTF/
  rm -rf /tmp/croscorefonts-1.31.0/ /tmp/chrome-fonts.tar.bz2
  echo 'Done'
  echo

  echo 'Fonts cache update in progress...'
  fc-cache -sfr
  echo 'Done'
  echo
  
  echo "Installing the New Fonts Configuration File..."
  {
    echo '<?xml version="1.0"?>'
    echo '<!DOCTYPE fontconfig SYSTEM "fonts.dtd">'
    echo '<fontconfig>'
    echo ''
    echo '  <!-- Convert "Cantarell" to "Bistream Vera Sans" -->'
    echo '  <match target="pattern">'
    echo '    <test qual="any" name="family"><string>Cantarell</string></test>'
    echo '    <edit name="family" mode="assign" binding="same"><string>Bistream Vera Sans</string></edit>'
    echo '  </match>'
    echo ''
    echo '  <!-- Set preferred serif, sans serif, and monospace fonts. -->'
    echo '  <alias>'
    echo '    <family>serif</family>'
    echo '    <prefer><family>Tinos</family></prefer>'
    echo '  </alias>'
    echo '  <alias>'
    echo '    <family>sans-serif</family>'
    echo '    <prefer><family>Arimo</family></prefer>'
    echo '  </alias>'
    echo '  <alias>'
    echo '    <family>sans</family>'
    echo '    <prefer><family>Arimo</family></prefer>'
    echo '  </alias>'
    echo '  <alias>'
    echo '    <family>monospace</family>'
    echo '    <prefer><family>Cousine</family></prefer>'
    echo '  </alias>'
    echo ''
    echo '  <!-- Aliases for commonly used MS fonts. -->'
    echo '  <match>'
    echo '    <test name="family"><string>Arial</string></test>'
    echo '    <edit name="family" mode="assign" binding="strong">'
    echo '      <string>Arimo</string>'
    echo '    </edit>'
    echo '  </match>'
    echo '  <match>'
    echo '    <test name="family"><string>Helvetica</string></test>'
    echo '    <edit name="family" mode="assign" binding="strong">'
    echo '      <string>Arimo</string>'
    echo '    </edit>'
    echo '  </match>'
    echo '  <match>'
    echo '    <test name="family"><string>Verdana</string></test>'
    echo '    <edit name="family" mode="assign" binding="strong">'
    echo '      <string>Bitstream Vera Sans</string>'
    echo '    </edit>'
    echo '  </match>'
    echo '  <match>'
    echo '    <test name="family"><string>Tahoma</string></test>'
    echo '    <edit name="family" mode="assign" binding="strong">'
    echo '      <string>Arimo</string>'
    echo '    </edit>'
    echo '  </match>'
    echo '  <match>'
    echo '    <test name="family"><string>Times New Roman</string></test>'
    echo '    <edit name="family" mode="assign" binding="strong">'
    echo '      <string>Tinos</string>'
    echo '    </edit>'
    echo '  </match>'
    echo '  <match>'
    echo '    <test name="family"><string>Times</string></test>'
    echo '    <edit name="family" mode="assign" binding="strong">'
    echo '      <string>Tinos</string>'
    echo '    </edit>'
    echo '  </match>'
    echo '  <match>'
    echo '    <test name="family"><string>Courier New</string></test>'
    echo '    <edit name="family" mode="assign" binding="strong">'
    echo '      <string>Cousine</string>'
    echo '    </edit>'
    echo '  </match>'
    echo ''
    echo '  <!-- Default rendering options -->'
    echo '  <match target="font">'
    echo '    <edit mode="assign" name="rgba"><const>rgb</const></edit>'
    echo '    <edit mode="assign" name="hinting"><bool>true</bool></edit>'
    echo '    <edit mode="assign" name="autohint"><bool>false</bool></edit>'
    echo '    <edit mode="assign" name="antialias"><bool>true</bool></edit>'
    echo '    <edit mode="assign" name="hintstyle"><const>hintslight</const></edit>'
    echo '    <edit mode="assign" name="lcdfilter"><const>lcddefault</const></edit>'
    echo '    <edit mode="assign" name="embeddedbitmap"><bool>false</bool></edit>'
    echo '  </match>'
    echo ''
    echo '</fontconfig>'
  } > /etc/fonts/conf.avail/$SCRIPT_FONTS_FILE

  ln -sf /etc/fonts/conf.avail/$SCRIPT_FONTS_FILE /etc/fonts/conf.d/

  echo "Done."
  echo

  SUGGESTER_REBOOT="Y"
}

function remove_configuration_files {
  echo
  echo "Removing required Fonts..."
  rm -f /usr/share/fonts/TTF/Arimo-* /usr/share/fonts/TTF/Cousine-* /usr/share/fonts/TTF/Tinos-*
  echo "Done."
  echo

  echo 'Fonts cache update in progress...'
  fc-cache -sfr
  echo 'Done'
  echo

  echo "Removing the Fonts Configuration File..."
  rm -f "/etc/fonts/conf.avail/$SCRIPT_FONTS_FILE" "/etc/fonts/conf.d/$SCRIPT_FONTS_FILE"
  echo "Done."
  echo
  
  SUGGESTER_REBOOT="Y"  
}

INFINALITY_INSTALLED="$(pacman -Qq | grep 'freetype2-infinality-ultimate')" || :
if [ "$INFINALITY_INSTALLED" != "" ]
then
  read -r -e -p "Do you want UNINSTALL the Infinality Fonts Engine? [y/N]: " -i "N" REMOVE_INFINALITY
  if [ "$REMOVE_INFINALITY" = "Y" ] || [ "$REMOVE_INFINALITY" = "y" ];
  then
    remove_infinality;
  fi
else
  read -r -e -p "Do you want install the new improved Infinality Fonts Engine? [Y/n]: " -i "Y" INSTALL_INFINALITY
  if [ "$INSTALL_INFINALITY" = "Y" ] || [ "$INSTALL_INFINALITY" = "y" ];
  then
    install_infinality;
  fi
fi

if [ ! -f "/etc/fonts/conf.avail/$SCRIPT_FONTS_FILE" ]; 
then
  read -r -e -p "Do you want install the new improved Fonts and Configuration File? [Y/n]: " -i "Y" INSTALL_FILES
  if [ "$INSTALL_FILES" = "Y" ] || [ "$INSTALL_FILES" = "y" ];
  then
    install_configuration_files;
  fi
else
  read -r -e -p "Do you want UNINSTALL the new improved Fonts and Configuration File? [y/N]: " -i "N" REMOVE_FILES
  if [ "$REMOVE_FILES" = "Y" ] || [ "$REMOVE_FILES" = "y" ];
  then
    remove_configuration_files;
  fi
fi

if [ "$SUGGESTER_REBOOT" = "Y" ];
then
  echo "It's suggested a full reboot to take advantage from all the occurred changes!";
else
  echo "Made no changes."
fi; 
1 Like

In the past when I switched to infinality I was unimpressed and actually preferred the default fonts. Clearly a purely subjective thing, though hopefully your script at least makes it easier for people to do change if they wish.

Hi @branthebuilder, just for information, how many time ago do you tried Infinality?

It’s certainly been a while. Back when I first switched to Manjaro from Linux Mint so around 3 years ago, I think.

Another way to improve fonts (and performance) is to use bitmap fonts (terminus, tamsyn etc). However, that is not very good option for browsers.

Hi @branthebuilder, I think currently Infinality is much improved… I just tried it the last year found it not so “incredible”… but now I think it’s really a GOOD choice (for my personal opinion… a MUST)! :wink:

Hi @Chrysostomus, currently Infinality done a really BIG improvements in the Terminal fonts rendering. :slight_smile:

When I’ll have some time I’ll try to post some screenshots of the Terminal, before and after the script! :slight_smile:

1 Like

I use ubuntu fontconfig on all machines with Arch, really quite simple and works perfectly…

Hi @lojze, great Tutorial, I just testing it too, but at the last choice the Infinality one for the quality… I’m working on the screenshots now… I hope to can upload them ASAP! :slight_smile:

I read through the tutorial and it sounds good, but the website @lojze linked to is old and outdated. Entering user preferences in ~.fonts.conf (/home/YOUR_USER_NAME/.fonts.conf) is deprecated and has been for a couple of years. With some apps this will generate fontconfig error messages in your logs or at the console. The preferred location now is “~.config/fontconfig/conf.d” or " ~.config/fontconfig/fonts.conf" (/home/YOUR_USER_NAME/.config/fontconfig/fonts.conf).

I’ve used the Infinality patches on my old Gentoo install for years. It was a great idea back when there was BCI licensing issues, and disros shipped with the crappy autohinter enabled, but now that the patents have lapsed and and every distro ships with the BCI hinter is enabled by default, it’s a lot of work to have a minimal gain IMHO. The free fonts that used to come with distros as default were designed for the autohinter and didn’t render well as they scaled to different sizes.

A better method for great fonts is to scan through /etc/fonts/conf.avail and /etc/fonts/conf.d and enable or disable the symlinks there between them to your liking. Then create a fonts.conf file in the location I previously mentioned that properly aliases and substitutes your preferred modern fonts for for those old default free ones. For example, I use Droid fonts for my KDE Plasma5 workspace, then I set-up Noto fonts to be used instead in my fonts.conf file so that they are used in my browsers.

In KDE it’s extremely easy to see what different adjustments do because the font control panel applet allows you to enable or disable a number of font features. Then when you have your preferred fonts rendering correctly you can add those settings to /etc/fonts/conf.d symlinks or /etc/fonts/local.conf to affect all users in a multi user setup, or in your ~.config/fontconfig/fonts.conf file for your user.

Call me old school, but like I said, I used to use the Infinality hack. But now I prefer using more modern better fonts that are properly configured with the default FC. Doing things this way you are much less likely to have unwanted side effects, like unexpected crashes due to font config errors.

1 Like

That sounds interesting. Would you mind writin a general puspose tutorial about this? Or is the procedure too individual to a particular system?

I prefer without it too. Configuration is simpler without and rendering is barely any different these days, you just need a simple config and a few decent fonts.

1 Like

Hi @Odysseus, it looks really interesting, I’ll try to created an automatic script for this method too… :slight_smile: … but in the meantime follow the screenshots of a classical Terminal session before and after the “cure”! :wink:

and… that’s all! :slight_smile:

I sincerely hope this can help someone.

1 Like

Okay, there is a difference. But really, for terminal, bitmap fonts make more sense and render even better. Have you tried terminus or tamsyn?

Hi @Chrysostomus, I just tried them… really an inspired choice, but for the overall systems I think we can find a better solution… I hope to can post a new script (based on the @Odysseus suggestions and the ARC “fontconfig-enhanced-defaults” package) ASAP! :slight_smile:

Bohoomil’s fonts are quite good and I’ve used them in earlier years in Manjaro, and latter years in Arch (by adding the repo), but in all frankness, I’m lazy and find one simple fonts.conf provides a very acceptable solution across the board in all DE/WMs I’ve used, and that has been a few.

Regards

Yeah, they are specialized terminal fonts. For overall system and especially browsers they are not the best choice except on really lowend systems.

if it be shell fonts: http://www.1001freefonts.com/shell_gate.font

@Odysseus, @Chrysostomus, @c00ter, I have just released the new Script Version (v. 0.3) that allow the user to choose what to do. It’s possible choose if install the Infinality Bundle and or the new Fonts Configuration Scripts (from the @Odysseus suggestions :wink: )

Let me show an example…

4 Likes