Font hinting appears broken on 18.04

Bug #1722508 reported by Denis Kalinin
156
This bug affects 29 people
Affects Status Importance Assigned to Milestone
Qt
New
Undecided
Unassigned
freetype (Ubuntu)
Confirmed
High
Unassigned
qtbase-opensource-src (Ubuntu)
Confirmed
High
Unassigned

Bug Description

It appears that font hinting in 17.10 (beta) doesn't work as expected. The issue is easy to miss if you have antialiasing enabled system-wise. However, if you install "gnome-tweak-tool" and disable antialiasing there, the problem becomes obvious.

Here is how it looks on 17.10 beta:
https://postimg.org/image/3auqsbkqtn/

And here is how it looks on my 16.04 machine (and this is pretty much how it's supposed to look):
https://postimg.org/image/85n5ss3l4b/

* When comparing the pictures make sure you "Open image in new tab" and see them without browser zoom, otherwise the problem may no be obvious.

I suspect that this issue is caused by a bug in some base font rendering package that Ubuntu uses (edit: the problem is probably caused by FreeType 2.8.0, see my comments below). A couple of months ago a similar issue was reported (and promptly fixed) in Chromium after they had changed something in FreeType rendering (https://bugs.chromium.org/p/chromium/issues/detail?id=748997).

lsb_release -rd
Description: Ubuntu Artful Aardvark (development branch)
Release: 17.10

Revision history for this message
Denis Kalinin (denisftw) wrote :
Denis Kalinin (denisftw)
tags: added: artful
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at https://wiki.ubuntu.com/Bugs/FindRightPackage. You might also ask for help in the #ubuntu-bugs irc channel on Freenode.

To change the source package that this bug is filed about visit https://bugs.launchpad.net/ubuntu/+bug/1722508/+editstatus and add the package name in the text box next to the word Package.

[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]

tags: added: bot-comment
Revision history for this message
Denis Kalinin (denisftw) wrote :

I've just checked 17.04, and it also looks fine. My guess is that something has changed in "freetype" when it was updated from 2.6.3 to 2.8.0, so I'm setting "freetype" as the package for this bug.

affects: ubuntu → freetype (Ubuntu)
Changed in freetype (Ubuntu):
importance: Undecided → High
Revision history for this message
Denis Kalinin (denisftw) wrote :

OK, I've just compiled freetype 2.8.1 from the latest source

https://sourceforge.net/projects/freetype/files/freetype2/2.8.1/

and re-pointed the `libfreetype.so.6` link to a newly built .SO-file. I restarted the system and the hinting started working great. So, apparently only the 2.8.0 version of "freetype" is affected. Unfortunately, this is the version that's going to be shipped with Artful.

description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in freetype (Ubuntu):
status: New → Confirmed
Revision history for this message
mrvanes (mrvanes) wrote :

freetype 2.8.1 fixes hinting of normal fonts, but not bold.

Revision history for this message
Denis Kalinin (denisftw) wrote :

That's strange because bold letters of "Courier New" certainly look fine with freetype 2.8.1.
Do you mind telling me which font you're using?

Revision history for this message
mrvanes (mrvanes) wrote :

I'm using Ubuntu for all Desktop fonts. Attached is a screenshot of the problem.
Title is Ubuntu 9 bold, menu is Ubuntu 9 and terminal is Ubuntu Mono 9.
This is after updating Artful's libfreetype 2.8.0 to 2.8.1 from Michael Marley's PPA.

Revision history for this message
mrvanes (mrvanes) wrote :

It seems a plasma desktop bug, window title renders fine now, but bold fonts in panel and kmail still render the ugly way.

Revision history for this message
Denis Kalinin (denisftw) wrote :

The title of Konsole definitely doesn't look right, but I'm not sure I would blame FreeType for that. It could be some KDE or Qt problem.

On my installation, Ubuntu Tweak Tool doesn't allow me to set Window Font to "Ubuntu Bold 9". It simply switches to "Ubuntu Medium 9" and makes window titles look regular, not bold. However, when I increase the font size, it does make the title appear bold and it looks perfectly fine to me (attaching the screenshot).

I also updated to Michael's PPA and tried installing Konsole - the fonts still look OK.

Revision history for this message
Denis Kalinin (denisftw) wrote :

Oh, totally missed your comment. That confirms it.

Revision history for this message
mrvanes (mrvanes) wrote :

I meant to write "fine after upgrade to plasma 5.11".

Changed in freetype (Ubuntu Artful):
milestone: none → artful-updates
Revision history for this message
mrvanes (mrvanes) wrote :

I think I'm looking at a Qt problem, but still relevant for 17.10 as a whole I guess?
https://bugreports.qt.io/browse/QTBUG-63792

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

You may want to report the problem upstream to make some progress:

https://savannah.nongnu.org/bugs/?group=freetype

Revision history for this message
mrvanes (mrvanes) wrote :

In the meantime the problem has been narrowed down to QFont::toString() appending too much fontstyle information.
https://bugs.kde.org/show_bug.cgi?id=376630
https://bugs.kde.org/show_bug.cgi?id=378523

With Qt being alerted and kde having more issues reported I think problem reveived more than enough attention and more important, there's an easy work-around.

Revision history for this message
Denis Kalinin (denisftw) wrote :

Yeah, I'm not sure what progress could be made at this point.
The way I see it, the issue was resolved in a new version of libfreetype (2.8.1). The only thing that is left is to propagate the fix to main Ubuntu repo.

Revision history for this message
mrvanes (mrvanes) wrote :

No, only half of the problem was caused by libfreetype 2.8.0 (normal TT hinting) but should indeed be updated as soon as possible in Artful, the other part (bold/italics) is a Qt 5.9.x problem and needs some love from Qt.

Revision history for this message
Jeremy Bícha (jbicha) wrote :

We can't update freetype to 2.8.1 in Ubuntu 17.10 because it will break Electron apps (LP: #1728329). But Ubuntu 18.04 LTS will likely get freetype 2.8.1 (or possibly a newer version).

Revision history for this message
mrvanes (mrvanes) wrote :

Then, my advise would be to backport the TT hinting fix to 2.8.0 in Artful for all those not able to use 2.8.1 from ppa? Bionic is still a long way to go. Anyway, all is fine for me, so feel free to decide as you see fit...

Revision history for this message
md_5 (md-5) wrote :

I can confirm this, originally thought it was a Java bug since that is the only place I've seen the issue - https://bugs.launchpad.net/ubuntu/+source/openjdk-8/+bug/1729257

Major annoyance, I second the request for a backport.

Thanks!

Revision history for this message
HorstBort (haukemuentinga) wrote :

Downgrading to 2.6.3 from zesty (https://packages.ubuntu.com/zesty-updates/libfreetype6) fixed this *really* annoying issue for me.

Revision history for this message
mrvanes (mrvanes) wrote :

In my (humble) opinion the best way to solve this thinking forward, is to upgrade to freetype 2.8.1, plasma 5.11 and adjust font queries in kdeglobals and trolltecht.conf without weight specific strings as described in this bug:
https://bugreports.qt.io/browse/QTBUG-63792
It's also nice to see that trolltech is working on it!

Revision history for this message
Woko (wolfram-koehn) wrote :

I had the same Problem. The monospace-font in konsole looked ugly after upgrade from 17.04.
Same with freetype 2.8.1.
Then I downgraded libfreetype to 2.6.3 as HorstBort mentioned, and konsole looks nice again.
Here the description how I managed it:

1. add 'deb http://archive.ubuntu.com/ubuntu/ zesty main restricted universe multiverse' in '/etc/apt/sources.list'

2. create the file '/etc/apt/preferences' with the following contents:
 ---
 Package: libfreetype6:amd64
 Pin: version 2.6.3*
 Pin-Priority: 1001

 Package: *
 Pin: release v=17.04, l=Ubuntu
 Pin-Priority: -1

 Package: libfreetype6:i386
 Pin: version 2.6.3*
 Pin-Priority: 1001

 Package: *
 Pin: release v=17.04, l=Ubuntu
 Pin-Priority: -1
 ---

3. apt-get update

Jeremy Bícha (jbicha)
Changed in qtbase-opensource-src (Ubuntu):
status: New → Confirmed
importance: Undecided → High
Changed in qtbase-opensource-src (Ubuntu Artful):
status: New → Confirmed
importance: Undecided → High
Revision history for this message
Ragnar Dunbar (zaroff) wrote :

In 17.10 (Gnome), when I change the font to 'Ubuntu Mono Regular', as I always do, and switch to Antialiasing LCD in gnome-tweak-tool and Hinting to Full, fonts look messy. When I do the same in Ubuntu 16.04 via unity-tweak-tool, fonts are crisp and sharp. Comparison is depicted in the attachment.

Revision history for this message
Woko (wolfram-koehn) wrote :

Downgrade libfreetype6 to 2.6.3 as I decribed and it will be fixed.

Revision history for this message
Woko (wolfram-koehn) wrote :

I just created two VMWare-machines to show the difference. One with a Kubuntu17.10-image, one with a KDE-Neon-image. In Kubuntu I installed the freetype-PPA to get Version 2.8.1, in KDE-Neon they stick to 2.6.1. On both I startet a Konsole-Session with Monospace-Font. The Result is attached.

Revision history for this message
imachine (m-jedrasik) wrote :

Cool,

Fixed as Woko wrote, cheers man.

However, firefox still happens to show _some_ fonts incorrectly - possibly, bitmap fonts?

Some fonts downloaded from the web (like on Gmail) work fine.

Others don't.

See attached SSots.

Revision history for this message
imachine (m-jedrasik) wrote :

Then see here the correctly displayed fonts on Gmail (also downloaded from Gmail's server, no local font).

Works fine and hints correctly.

What gives?

Running last stable firefox (56.0, 57 all messed up, so locked 56 with apt-lock)

Ubuntu 17.10

Revision history for this message
gldickens3 (gordon-dickens) wrote :

One of the primary differences in freetype-2.8 and prior Ubuntu versions of freetype is the introduction of TT_CONFIG_OPTION_SUBPIXEL_HINTING in /include/freetype/config/ftoption.h in freetype-2.7.X and later. The default value is:

#define TT_CONFIG_OPTION_SUBPIXEL_HINTING 2

This needs to be undefined (uncommented) in order for freetype-2.7 and 2.8 to render fonts identically to prior versions of Ubuntu freetype (freetype-2.6.X and earlier).

The diff file (freetype_2.8-0.2ubuntu2.diff.gz) at https://launchpad.net/ubuntu/+source/freetype/2.8-0.2ubuntu2 enables FT_CONFIG_OPTION_SUBPIXEL_RENDERING in /include/freetype/config/ftoption.h with:

#define FT_CONFIG_OPTION_SUBPIXEL_RENDERING

This properly enables subpixel rendering to render fonts identical to MS cleartype, however, if TT_CONFIG_OPTION_SUBPIXEL_HINTING is also set then the fonts are rendered differently than before. So, this problem is fixed simply by undefining TT_CONFIG_OPTION_SUBPIXEL_HINTING.

Revision history for this message
gldickens3 (gordon-dickens) wrote :

In the first line of third paragraph of my prior post I meant to say "(commented out)" instead of "(uncommented)" So, that line should read: "This needs to be undefined (commented out) in order for freetype-2.7 and 2.8 to render fonts identically to prior versions of Ubuntu freetype (freetype-2.6.X and earlier)."

Revision history for this message
gldickens3 (gordon-dickens) wrote :

Adding the attached patch to the diff file will cause freetype-2.8 to render fonts exactly like in earlier Ubuntu versions (such as freetype-2.4.X, 2.5.X and 2.6.X).

Revision history for this message
Jeremy Bícha (jbicha) wrote :

Gordon, according to earlier comments, the Qt part of this bug will be fixed before 18.04 LTS's release. Are you using Kubuntu or Qt apps?

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "Patch to disable #define TT_CONFIG_OPTION_SUBPIXEL_HINTING" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
gldickens3 (gordon-dickens) wrote :

Hello jbicha,

I am not running Kubuntu but I am running KDE Plasma 5 and Qt apps on several OpenSUSE installations. On my Ubuntu installation I am running Gnome Shell. As an FYI, I maintain a freetype2 repository with subpixel rendering enabled for OpenSUSE Leap and Tumbleweed. Like most of the other Linux desktop OS versions, OpenSUSE does NOT enable subpixel rendering with the FT_CONFIG_OPTION_SUBPIXEL_RENDERING variable and I provide that option with my repo. In one of my repos I use the Ubuntu freetype2 diff file for implementing the subpixel rendering patches. Several months ago, I noticed that the font rendering changed when I upgraded my font repositories to freetype-2.7.1 and the difference in the rendering was caused by the introduction of the TT_CONFIG_OPTION_SUBPIXEL_HINTING parameter in ftoptions.h. Its not so much that the font rendering is better or worse but that it is different than before with freetype-2.6.X. In any event, at that time, I discovered that the font rendering would be made exactly the same as before by not defining TT_CONFIG_OPTION_SUBPIXEL_HINTING in freetype2 versions 2.7 and later.

Revision history for this message
Jeremy Bícha (jbicha) wrote :

> Its not so much that the font rendering is better or worse but that it is different than before

Gordon, thanks for your reply.

I think your issue is different than the Qt issue mentioned by many of the commenters here.

I help maintain Ubuntu's font packages, but I just started with that and I wasn't involved in the freetype 2.7/2.8 upgrade nor am I familiar with how Ubuntu's font rendering used to work. I encourage you to start a Desktop topic at https://community.ubuntu.com/ for your suggestion. If you could provide before and after screenshots, that would be helpful.

We might want to keep a more upstream default font rendering. I don't know, but I am hopeful that your post will help us figure out what to do.

By the way, I expect we'll be upgrading to freetype 2.8.1 for Ubuntu 18.04 LTS, but I am waiting for the next Electron release first. See LP: #1728329

Revision history for this message
Martin Dauskardt (md001) wrote :

In german ubuntuusers forum there is an simpler solution without need to downgrade libfreetype.
https://forum.ubuntuusers.de/post/8914328/

Just add

FREETYPE_PROPERTIES="truetype:interpreter-version=35 cff:no-stem-darkening=1 autofitter:warping=1"

in /etc/environment and restart x-server or reboot.

Revision history for this message
gldickens3 (gordon-dickens) wrote :

Hi Martin,

Thanks for the tip! Defining the FREETYPE_PROPERTIES as you suggested in /etc/environment did indeed disable hinting and renders the same crisper fonts as was in earlier versions of Ubuntu. Personally, I still prefer to disable hinting in the source code but your suggestion works just as well.

Thanks again!

Gordon

Revision history for this message
Woko (wolfram-koehn) wrote :

I can report that the solution Martin reported works also for Monospace in Konsole-sessions.
Because it's much better than downgrading, I removed all the changes I described in #23 and it works like a charm.

Thanks a lot Martin!

Wolfram

Revision history for this message
roots (roots) wrote :

Thanks Martin,

this did the trick with Ubuntu 18.04 as well.

Cheers,
r.

Revision history for this message
Woko (wolfram-koehn) wrote :

I just installed the new KDE Neon Bionic version as a VM. The Trick doesn't work there. The freetype-version is 2.8.1-2ubuntu2 like on the Kubuntu Host. Maybe the /etc/environment is ignored there. I'm just researching.

Revision history for this message
Antoine Pitrou (pitrou) wrote :

This issue hit me when upgrading from Xubuntu 16.04 to 18.04.1. Martin's trick above worked to bring rendering back to a pleasant state (thanks!).

fcole90 (fcole90)
summary: - Font hinting appears broken on 17.10 beta
+ Font hinting appears broken on 18.04
tags: added: bionic
Revision history for this message
Woko (wolfram-koehn) wrote :

Martins trick worked till 19.04. Since 19.10 it seems to be ignored.
Freetype now has version 2.9.1. Any ideas ?

no longer affects: freetype (Ubuntu Artful)
no longer affects: qtbase-opensource-src (Ubuntu Artful)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.