Linux Commands

How to Render Fonts in Linux?

How to Render Fonts in Linux

Linux used the GUI of the old X11 window system. The API for that was horrendous with plenty of libraries stacked upon one another to make it work. The font rendering across Linux depends on the distribution, with Ubuntu having the best default font rendering settings and Fedora Linux having the worst. Having a bad font rendering, we will see a rough and jagged font rendering across websites when using Linux.

In this article, we will discuss how we can improve the font rendering on Linux.

How to Render Fonts in Linux?

To improve Font Rendering, you will have to make some necessary changes to the font configuration files involving some steps.

Step 1: Creating Local Config File

First, you have to create a local config file using the following command:

sudo nano /etc/fonts/local.config

It will ask for the user password:

Step 2: Adding Content in the File

Open the “local.config” file and add the following content to the file:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<<strong>fontconfig</strong>>
<<strong>match</strong> target="font">
<<strong>edit</strong> name="antialias" mode="assign">
<<strong>bool</strong>>true</<strong>bool</strong>>
</<strong>edit</strong>>
<<strong>edit</strong> name="hinting" mode="assign">
<<strong>bool</strong>>true</<strong>bool</strong>>
</<strong>edit</strong>>
<<strong>edit</strong> mode="assign" name="rgba">
<<strong>const</strong>>rgb</<strong>const</strong>>
</<strong>edit</strong>>
<<strong>edit</strong> mode="assign" name="hintstyle">
<<strong>const</strong>>hintslight</<strong>const</strong>>
</<strong>edit</strong>>
<<strong>edit</strong> mode="assign" name="lcdfilter">
<<strong>const</strong>>lcddefault</<strong>const</strong>>
</<strong>edit</strong>>
</<strong>match</strong>>
</<strong>fontconfig</strong>>

Once added, save the file and Exit using “Ctrl+X”:

Step 3: Create a Backup of Resources File

Create a backup of the resource file. Add the following code in it:

cp ~/.Xresources ~/.Xresources.bak

Create the file if it does not exist. Here we don’t have the resource file:

Step 4: Configuring Resources File

Use the command below to create a Resources file. This command will open the file if it was already made:

nano ~/.Xresources

Once created, it will open up the file. Add the script below to your resource file:

Xft.antialias: 1
Xft.hinting: 1
Xft.rgba: rgb
Xft.hintstyle: hintslight
Xft.lcdfilter: lcddefault

In these attributes, “Anti-Aliasing” is enabled, and “Hinting” is set to 1 which is “Slight”. Use the following command now:

xrdb -merge ~/.Xresources

Once you hit enter, it will merge the settings and the command line will move to the next line:

Step 5: Verify Changes

Now to verify your changes, search for “KDE System Settings” in the search bar:

Open it and search for “Fonts” in the search box of the settings window:

Open the fonts settings and here you can see that the Anti-Aliasing is enabled and the Hinting is set to “Slight”:

Step 6: Reboot System

You have to reboot your system now to apply the changes to fonts for them to render better.

Conclusion

The font rendering across Linux depends on the distribution. Having bad rendering leads to a rough and jagged user interface. This article explains how to create a local config file, add content to it, then add resource files and necessary attributes to it, and once our system restarts we can see the fonts render better across web pages.

Similar Posts