Why Ubuntu Renders Fonts Better Than Debian

debianfontsgnomeUbuntu

As Ubuntu obtains its packages from Debian repositories, I would like to know if Ubuntu developers do some modification to the original Debian packages to improve font rendering.

I ask this because I just installed Debian 10 and the font rendering is worse than Ubuntu, even after downloading Ubuntu fonts and configuring Gnome Tweaks to use it with the same values of Ubuntu (including Subpixel and Hinting values).

Thank you!

Best Answer

Yes, there are a number of differences between the Debian and Ubuntu versions of the fontconfig package, which is the package which handles font rendering:

  • DejaVu is preferred to BitStream Vera;
  • the lcdlegacy filter is applied to DejaVu Sans Mono up to 12 pixels;
  • anti-aliasing is enabled in the engine.

You can replicate all this on your Debian system:

  • edit /etc/fonts/conf.d/60-latin.conf and swap the DejaVu and BitStream Vera entries;
  • add /etc/fonts/conf.d/53-monospace-lcd-filter.conf with the following contents:

    <?xml version="1.0"?>
    <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
    <!-- conf.d/monospace-lcd-filter.conf -->
    <fontconfig>
    <!--  Use legacy LCD filter on smaller Monospace fonts -->
      <match target="pattern">
        <test name="family">
          <string>DejaVu Sans Mono</string>
        </test>
        <test name="pixelsize" compare="less_eq">
          <double>12.0</double>
        </test>
    
        <edit name="lcd_filter" mode="append">
          <const>lcdlegacy</const>
        </edit>
        <edit name="hintstyle" mode="append">
          <const>hintfull</const>
        </edit>
      </match>
      <match target="pattern">
        <test name="family">
          <string>Bitstream Vera Sans Mono</string>
        </test>
        <test name="pixelsize" compare="less_eq">
          <double>12.0</double>
        </test>
    
        <edit name="lcd_filter" mode="append">
          <const>lcdlegacy</const>
        </edit>
        <edit name="hintstyle" mode="append">
          <const>hintfull</const>
        </edit>
      </match>
    </fontconfig>
    
  • add /etc/fonts/conf.d/10-antialias.conf with the following contents:

    <?xml version="1.0"?>
    <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
    <fontconfig>
    <!--  Use the Antialiasing -->
      <match target="pattern">
        <edit name="antialias" mode="append"><bool>true</bool></edit>
      </match>
    </fontconfig>
    
Related Question