I have been raging about the font rendering on Linux for years. It just sucks. Font has jagged edges and it looks very weird. I dual-boot with windows and the font there is very nice. So, I asked Claude ai to help me and it did a great job and my font is now is actually better than windows. I wanted to share it with everyone in case you have the same issue with the font on Linux.

Here it is:

  1. First, install required packages:
sudo pacman -S freetype2 cairo fontconfig

2. Install better fonts:

sudo pacman -S ttf-dejavu ttf-liberation noto-fonts ttf-roboto ttf-roboto-mono ttf-droid ttf-opensans ttf-hack ttf-fira-code

I have also installed Segoe ui and Segoe UI Variable fonts and that is what I’m using now.

3. Create or edit the font configuration file:

sudo mkdir -p /etc/fonts/conf.d

sudo nano /etc/fonts/local.conf

4. Add this configuration to local.conf:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="font">
<edit name="antialias" mode="assign">
<bool>true</bool>
</edit>
<edit name="hinting" mode="assign">
<bool>true</bool>
</edit>
<edit name="hintstyle" mode="assign">
<const>hintslight</const>
</edit>
<edit name="rgba" mode="assign">
<const>rgb</const>
</edit>
<edit name="lcdfilter" mode="assign">
<const>lcddefault</const>
</edit>
<edit name="embeddedbitmap" mode="assign">
<bool>false</bool>
</edit>
<edit name="autohint" mode="assign">
<bool>true</bool>
</edit>
</match>
<!-- Increase contrast slightly for all fonts  This is not mandatory and can be commented out-->
<match target="font">
<edit name="weight" mode="assign">
<const>medium</const>
</edit>
</match>
</fontconfig>

5. Create a file for FreeType settings:

sudo nano/etc/profile.d/freetype2.sh

6. Add these export commands (I found it there already, but it was commented out. Just removed the “#”):

export FREETYPE_PROPERTIES="truetype:interpreter-version=40"

7. Enable subpixel rendering: (You might get a message that says “File exist”, that’s ok. It means it was already there)

sudo ln -s /etc/fonts/conf.avail/70-no-bitmaps.conf /etc/fonts/conf.d/

sudo ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d/

8. Clear and regenerate font cache:

fc-cache -fv

9. For better Java application fonts:

sudo pacman -S jre-openjdk fontconfig

10. Reboot


Additional optional steps: a. For better Firefox font rendering, in about:config: Set

gfx.font_rendering.cleartype_params.rendering_mode

to 5 (This doesn’t exist in FF. You create it, set it to “number” and give it a value of 5)

Set

gfx.webrender.all

to true

b. If you use VSCode, add to settings.json:

{
"editor.fontFamily": "'Fira Code, 'Droid Sans Mono', 'monospace'",

"editor.fontLigatures": true
}

Truly hope this help someone. Share it with others if you think it will help them.

Thanks :)

  • shirro@aussie.zone
    link
    fedilink
    English
    arrow-up
    37
    ·
    edit-2
    12 days ago

    Freetype2, fontconfig and cairo are going to be pulled in as dependencies when you install just about any desktop app/library eg firefox, gtk so this is a no-op. Same for installing the jre and fontconfig again. Its pointless. The freetype2.sh line is commented out because that has been the default setting for the last 8 years so it makes no difference. The gfx.webrender.all setting in firefox is an override to force something it is most likely already doing based on the detected environment. If you check about:support the chances are you are already using hardware rendering. And its a performance and not quality setting. Half of this makes no sense.

    Installing nicer fonts is always a good idea and also setting your desktop and application default fonts.

    Some of the local.conf settings could potentially makes a big difference if your desktop environment defaults/user settings aren’t good. Don’t know a huge amount about freetype settings but I suspect using assign in there might override desktop environment settings which some people might not want. I set mine in a gui like the monkey I am.

    My conversation with any llm tends to go, “you got a, b, c wrong, it should be d, e and f” and it says “sorry, ofcourse it should be d, e and f, my mistake, here it is with d, e, f, g and h”. Then I say “g and h are wrong it should be i and j”. And it keeps going. In the end I write it myself. Huge time wasters.

    Edit: didn’t pick up on it immediately but the two symbolic link commands are suss (they are for debian based distros). Endeavor is arch based and fontconfig on arch has the configs in /usr/share/fontconfig and the ones in the conf.default directory should already be linked into /etc/fonts/conf.d. 10-sub-pixel-rgb is in /usr/share/fontconfig/conf.default so that is already linked for me so attempting to do another link without deleting it would be an error - another no-op. I don’t like rgb sub-pixel rendering so its overridden in my desktop settings. It shouldn’t be necessary on high dpi IMO. The proper path for 70-no-bitmaps is in the /usr/share/fontconfig/conf.avail directory if you want to link it properly. If you use the wrong path as Claude suggested, its another no-op. If, like me, you don’t have any bitmap fonts installed it won’t make any difference anyway. Also /etc/fonts/conf.d is created by the fontconfig package so that is another no-op.

    Edit 2: The setting’s name might be inaccurate but Cleartype is the name of Microsoft’s proprietary font renderer and isn’t available on Linux. So possibly gfx.font_rendering.cleartype_params.rendering_mode was picked up from some StackOverflow discussion about Firefox font rendering on Windows. I won’t say it doesn’t work without reading the Firefox source code and/or trying it but I suspect a setting with that name would not have any effect on Mac or Linux.

    • cyberwolfie@lemmy.ml
      link
      fedilink
      arrow-up
      15
      ·
      12 days ago

      My conversation with any llm tends to go, “you got a, b, c wrong, it should be d, e and f” and it says “sorry, ofcourse it should be d, e and f, my mistake, here it is with d, e, f, g and h”. Then I say “g and h are wrong it should be i and j”. And it keeps going. In the end I write it myself. Huge time wasters.

      And yet people at work will take its word when asking about things they don’t know anything about beforehand and have no real way of fact checking without actually doing the research they are trying to avoid.

    • Womble@lemmy.world
      link
      fedilink
      English
      arrow-up
      5
      arrow-down
      1
      ·
      12 days ago

      The point you are missing is that yes, asking an LLM about these things is not at the level of advice from someone who knows their stuff. But if you dont know what you are doing and dont know enough to even know what the right things to search for are then even partialy useful advice about the thing you are trying to do is a massive help.