~eliasnaur/gio#70:
Font rendering is lighter than freetype

Gio's font rendering looks substantially lighter than what you would get with freetype, for the same font. For example at:

https://github.com/aarzilli/blah/blob/master/tqbfjotld.png

you can see a sample rendering of DroidSansMono at 20px, on top gio, at the bottom freetype (real freetype, not go-freetype). The bottom was rendered by ftview with hinting off and light grayscale antialiasing. Selecting the normal antialiasing will make the difference even more pronounced.

The shapes look similar enough but gio consistently picks lighter shades of gray for the pixels.

Status
REPORTED
Submitter
Alessandro Arzilli
Assigned to
No-one
Submitted
24 days ago
Updated
20 days ago
Labels
No labels applied.

~eliasnaur 23 days ago

On Fri Nov 22, 2019 at 6:24 AM Alessandro Arzilli wrote:

Gio's font rendering looks substantially lighter than what you would get with freetype, for the same font. For example at:

https://github.com/aarzilli/blah/blob/master/tqbfjotld.png

you can see a sample rendering of DroidSansMono at 20px, on top gio, at the bottom freetype (real freetype, not go-freetype). The bottom was rendered by ftview with hinting off and light grayscale antialiasing. Selecting the normal antialiasing will make the difference even more pronounced.

The shapes look similar enough but gio consistently picks lighter shades of gray for the pixels.

Indeed, I suspect the primary reason for the difference is that Gio draws text with correct sRGB blending. See the discussion at

https://lists.sr.ht/%7Eeliasnaur/gio/%3CCABydZCyyhYKih3CahOXzG-2hZm4Vz9DR0ypTny7VivbQDLJguw%40mail.gmail.com%3E

there's a Freetype article about stem darkening and sRGB at

https://www.freetype.org/freetype2/docs/text-rendering-general.html

In particular, this section stands out:

Qt5 actually had gamma correction enabled for a short time while until someone complained that text was too light and unlike rendering in other toolkits, so the maintainers disabled it for the XCB-backend. Skia (Chrome) can do gamma-correction, but turns it off for X11.

It seems that X11 is treated specially by toolkits.

It's likely there's a bug in the Gio text renderer, of course. Can you somehow convince Freetype to draw with Gamma 2.2 and without any stem darkening or similar enhancements? You also need to disable sub-pixel AA; Gio only implements gray scale AA.

If the difference is caused by stem darkening and different gamma, then I believe this issue is a duplicate of gio#68.

Alessandro Arzilli 21 days ago

On Fri, Nov 22, 2019 at 01:46:51PM -0000, ~eliasnaur wrote:

On Fri Nov 22, 2019 at 6:24 AM Alessandro Arzilli wrote:

Gio's font rendering looks substantially lighter than what you would get with freetype, for the same font. For example at:

https://github.com/aarzilli/blah/blob/master/tqbfjotld.png

you can see a sample rendering of DroidSansMono at 20px, on top gio, at the bottom freetype (real freetype, not go-freetype). The bottom was rendered by ftview with hinting off and light grayscale antialiasing. Selecting the normal antialiasing will make the difference even more pronounced.

The shapes look similar enough but gio consistently picks lighter shades of gray for the pixels.

Indeed, I suspect the primary reason for the difference is that Gio draws text with correct sRGB blending. See the discussion at

https://lists.sr.ht/%7E eliasnaur/gio/%3CCABydZCyyhYKih3CahOXzG-2hZm4Vz9DR0ypTny7VivbQDLJguw%40m ail.gmail.com%3E

there's a Freetype article about stem darkening and sRGB at

https://www.freetype.org/freetype2/docs/text-rendering- general.html

In particular, this section stands out:

Qt5 actually had gamma correction enabled for a short time while until someone complained that text was too light and unlike rendering in other toolkits, so the maintainers disabled it for the XCB-backend. Skia (Chrome) can do gamma-correction, but turns it off for X11.

It seems that X11 is treated specially by toolkits.

It's likely there's a bug in the Gio text renderer, of course. Can you somehow

convince Freetype to draw with Gamma 2.2 and without any stem darkening or similar enhancements? You also need to disable sub-pixel AA; Gio only implements gray scale AA.

I believe I have already disabled sub-pixel AA, and there is no way to (that I can find) to convince ftview to disable stem darkening.

At: https://github.com/aarzilli/blah/blob/master/tqbfjotld2.png you can see on the third line the effect of gamma 2.2, which is still darker than gio.

If the difference is caused by stem darkening and different gamma, then I believe this issue is a duplicate of gio#68.

View on the web: https://todo.sr.ht/~eliasnaur/gio/70#comment-4887

~eliasnaur 20 days ago

On Sun Nov 24, 2019 at 11:34 AM Alessandro Arzilli wrote:

On Fri, Nov 22, 2019 at 01:46:51PM -0000, ~eliasnaur wrote:

On Fri Nov 22, 2019 at 6:24 AM Alessandro Arzilli wrote:

I believe I have already disabled sub-pixel AA, and there is no way to (that I can find) to convince ftview to disable stem darkening.

At: https://github.com/aarzilli/blah/blob/master/tqbfjotld2.png you can see on the third line the effect of gamma 2.2, which is still darker than gio.

Indeed. Another reason for the lighter text is that package opentype does very basic hinting (rounding the advance to the nearest pixel):

https://github.com/golang/image/blob/e7c1f5e7dbb87d8921928a6d9fc52fb31ce73b24/font/sfnt/sfnt.go#L1527

For example, will rounding to nearest pixel will always result in the letter stems be pixel aligned? I don't know (yet).

Register here or Log in to comment, or comment via email.