Autohinter and TrueType engine should provide stem darkening
Migrated from: [SAVANNAH-42446]
Dave Arnold reported:
Hi Werner,
Over the past few months, I've seen more examples of FreeType clients misusing gamma. Usually, this is an attempt to improve text contrast when stems are small, on the order of one pixel or less. Usually this involves setting a gamma too low to "darken" black text, but I've also seen teams that set gamma too high to "improve" white text. Gamma has this apparent effect because it modifies the density of "mid tone" pixels, whose values are between 0 and 1. The problem is that gamma does not modify pixels at the ends of the range, where density is either 0 or 1. Since the effect is not uniform, this leads to a geometric distortion in the perceived shape of the glyph. There was a recent example where the slight taper of a stem was exaggerated. There are other bad effects of incorrect gamma, but this one is the most common, since black and white text colors are so common.
In my opinion, "stem darkening" as performed by the Adobe CFF rasterizer is the correct solution to the low contrast problem. The rasterizer compensates for low contrast by uniformly adding weight to the entire glyph. This creates a minimum of distortion. And by gradually reducing the amount of darkening as the scaled stem width increases, we preserve relative weights of fonts (e.g., light vs. regular) and sizes.
I think it is a problem for FreeType clients that stem darkening is only available for CFF fonts. If gamma is set correctly (and I believe this is a function of physics and not of personal taste) then darkened CFF fonts look good but undarkened TT fonts look wrong. If gamma is misadjusted to "improve" TT fonts, then CFF fonts look wrong (or stem darkening is turned off or reduced to match TT).
What do you think about adding stem darkening to TrueType?
In CFF, we have a convenient way to simultaneously adjust the hints and the outlines, so the darkened result remains hinted. This same approach is not possible with native TrueType because of the way TT hints work. But with the autohinter, it should be relatively easy to darken the outline before computing the hints.
For native TT hints, a compromise is possible with "light" hinting. In "light" mode, only horizontal stems are hinted, and hints that operate on vertical stems are carefully ignored. (This is true also for subpixel rendering, or LCD mode.) We actually do this at Adobe in our TT rasterizer. We darken the outlines in the x-direction only. There is no bad interaction between the darkened vertical stems and the native hints, because those hints are disabled. We don't darken the horizontal stems and they remain properly hinted. In Western scripts, vertical stems dominate the total ink anyway, so the limited darkening still works well. And grid-aligned horizontal stems serve the purpose of improving readability.
I propose that we apply stem darkening at least to autohinted rendering, since that is the most common mode for TT. This would solve a problem for clients using a mix of CFF and TT.
-Dave