freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft-devel] Supersampling of TrueType fonts, or: slight native hinting


From: Nikolaus Waxweiler
Subject: [ft-devel] Supersampling of TrueType fonts, or: slight native hinting
Date: Thu, 5 May 2016 15:27:19 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0

Hey list,
so as the new subpixel hinting code will hopefully soon be mainlined, I found something else to distract me from stem darkening: Keeping these damn TrueType fonts from snapping stems to full pixels like in the bad old GDI days. I'm opening a new thread here so that mails on the topic don't get lost elsewhere.

# What's the problem?
TrueType's explicit programming model leaves the result of hinting completely up to the designer. Font designers have long targeted Windows GDI environments with all of it's idiosyncrasies and limitations, which made strong distortions of the original outlines necessary. The newer DirectWrite gives designers much more room to archive a good compromise between sharpness and design fidelity, but older fonts are typically not updated to use the new possibilities. Even new font families like Source Sans Pro, Acumin and Ubuntu are still programmed to perform well in GDI and no effort was made to strive for higher design fidelity through DirectWrite. This typically means that stems are snapped to full pixel widths. See http://www.freetype.org/ttfautohint/#samples -> Ubuntu Regular, original hinting. Observe the jumping stem thickness as the size goes up.

This is irritating because FreeType has been using a fundamentally different (coverage-based) rasterization mechanism for years that makes all the GDI contortions unnecessary while still looking very good. See the above sample again. According to Dave Arnold of Adobe, the contributed CFF engine does not honor all Type1 hinting concepts, e.g. stem snapping, because it simply isn't necessary for FreeType.

This leaves us with a gigantic pile of TrueType fonts that render worse than they could.

# Possible solutions
Microsoft uses a 6x1 (x, y) supersampling approach to display fonts, which takes care of vertical stems but won't do anything for horizontal ones. An alternative 6x5 approach may be used at bigger sizes to smoothen the y-axis. Adobe uses a 6x2 approach in CoolType to smoothen stems to 50% coverage instead of full pixels. The new minimal subpixel hinting code solves the problem for the x-axis by simply ignoring all hints for the x-axis, but won't help for the y-axis.

I want to find a way to get fonts off their full-pixel snapping. Some approaches I have through of:

- Use a form of supersampling. I'm not sure how to do that. Since FT subdivides a full pixel into 64x64 subpixels, I tried modifying the rounding functions and halving CVT cut-in and minimum distance when on the y-axis. The results are underwhelming (outer edges of stems not aligned to pixel grid at various sizes) and glitchy. Another approach would be to double the size of a glyph before hinting and downscale later, although I don't know how to do that yet.

- Modify IUP[y] to go through all touched points and look for stems whose edges were snapped on both sides to reset the inner edge. It would then get picked up by IUP and follow the outer edge. This would result in a 'slight' native hinting mode. The downside is that this would probably be very difficult to generalize and would need stem-detection machinery.

Anybody have any ideas?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]