canonical / Ubuntu-Sans-fonts

Other
54 stars 4 forks source link

Font rendering on Ubuntu: font-size appears smaller #82

Open lyubomir-popov opened 1 year ago

lyubomir-popov commented 1 year ago

Hi @djrrb a developer from our OS team reported the following:

"GNOME’s font viewer shows some height differences in the smaller font sizes."

and provided these 2 screenshots (easiest way to compare is to download them and switch back and forth from one to the other).

Is this due to aliasing on the OS side? Is there anything we can do short of hinting?

7436235d-5541-4d6b-86ae-e882926f2f0f 95e0d31d-91e9-45b7-93a7-d395aab4d0a9

elioqoshi commented 1 year ago

Animated gif here to visualize it better

ezgif-4-76907917ad

djrrb commented 1 year ago

Thank you for providing these screenshots and animation! Just to clarify, we are looking at the previous version vs. the new version?

elioqoshi commented 1 year ago

@djrrb Correct! The new version is the one with a lower visual weight.

lyubomir-popov commented 1 year ago

The other thing I notice is that in this screenshot, kerning seems off - see c and k for example: image Wondering if the choice of OS impacts that too?

jpnurmi commented 1 year ago

Looks better on macOS

macos

jpnurmi commented 1 year ago

The issue is visible on Windows

windows

jpnurmi commented 1 year ago

With the native Windows 11 font viewer

windows-native

djrrb commented 1 year ago

I’m still working on an answer to this, but I didn’t want to leave you hanging for the weekend. My preliminary response is: yes, I think this is due to the change in hinting, and OSes will vary in how they interpret this (in the case of MacOS/iOS, the hinting is hardly used at all, hence the much more consistent appearance).

In the new version, the static fonts use ttfautothint, which I think is trying to improve readability at small sizes by making the letters as big as possible. The variable font is unhinted (a standard practice), so you may see slightly different results between the new static and variable font.

We aren’t able to fine-tune each letter at each size, but there might be some steps we can make to nudge things in the right direction. I’ll look into this. And actually, in the Windows example, I think I mostly prefer the new appearance to the old, except for the few situations where the dot on the i begins to merge with the stroke...we could consider raising the dot slightly to try and sidestep this.

guidoferreyra commented 1 year ago

At first glance, I will say the new version renders better. Having a bigger pixel size at small point size it’s helping to improve the legibility. We can see if changing TTFAutohint options can make any difference but sometimes different options can have 0 positive impact so we will need to do a proper test and comparison. We can set the TTFA’s option "xHeight Increase limit" to a bigger point size to prevent increasing at small sizes, then probably size will match with old version but I doubt this will be an improvement since that "extra" pixel is really helping on sizes below 12px. In addition these settings can not be hooked to Google’s builder so we will need to patch the fonts at the end.

elioqoshi commented 1 year ago

Thanks for the input folks!

Considering we are close to releasing the new Ubuntu version in a few weeks, I do think we are cutting it too close here and think we might need to hold off including the new font in this release and see if we can test it more for the release after in October. @lyubomir-popov do you agree?

lyubomir-popov commented 1 year ago

@elioqoshi this is a conversation for the Desktop team, this issue is to see if we can influence things like kerning in the correct direction.

moyogo commented 1 year ago

If I remember correctly this is because of hinting; TrueType instructions were used to make some weights look bolder at some sizes.

mrvanes commented 1 year ago

As the last man standing using B/W + hinting let my voice be heard and known that I regret the loss of proper hinting in the new (variable) Ubuntu font. Autohinting doesn't even come close to what the font looked like in 22.10. But I can downgrade and hold the ubuntu-font for as long as I want, so I'm still fine looking at a crisp and sharp rendered Ubuntu font on my desktop.

djrrb commented 1 year ago

I meant to follow up here and record that we did the following to improve the i/j dot issue in particular: — increased distance between i/j dot and base stroke — converted i/j to components

The build process is also using more specific autohinting commands, thanks to @guidoferreyra.

djrrb commented 1 year ago

I am leaving this issue open since other concerns were raised about hinting in general that I am not able to address.

To summarize my current thoughts:

— I’m not a hinting expert, and I don’t know the ins and outs of the hinting in the original fonts. But generally speaking I don’t know of a way to replicate the level of hinting in the original fonts in a variable font using contemporary techniques.

— While it will not be identical to the original, my hope is that between improvements to font renderers and autohinters, the appearance of the autohinted / unhinted fonts will continue to get better.

— It would be possible to do limited manual hinting on the variable font. The benefits of that would have to be weighed against the additional complexity that it introduces, making it more cumbersome and costly to update or expand the family, and increasing the risk of introducing a significant bug if the hints no longer match the outlines.