by syockit · 5y ago · 0 comments
But I still get distracted by this one issue that bugged me since I first tried it 15 years ago: the anti-aliasing quality. The font doesn't look as crisp as what you'd see in other ClearType-enabled applications.
Earlier this year, I checkout out the SVN repository to see what's going with the renderer. The default Roman font is not TTF and cannot be rendered by FreeType, so TeXmacs has its own bitmap renderer for TFM fonts.
Basically, a glyph is rendered monochrome at a large size and then scaled down to the needed size with 8 color grayscale, IIRC. The bitmap is cached so wherever the glyph of the same style and size is needed, the same thing is drawn. Due to this, the font can sometimes look like it has weird kerning.
I tried to at least try subpixel rendering of the glyph bitmap to see if it makes things look better. The subpixel thing worked, but it didn't look any better. In the end, I gave up working on the issue.
In the future, we might only use Opentype fonts and use a font like TeX Gyre Pagella as our default font. I am afraid that we need to keep the old (tfm+pfb) Computer Modern as a legacy font so that people can reliably continue to use their old TeXmacs documents (remind that minor microtypographic changes may completely change lines and pages are broken).
On the other hand, regarding the kerning problem, there's not much you can do with the current one bitmap per glyph approach. One idea is to create multiple subpixel offset versions of the glyph. It'll cost more memory though. And the offset version of the bitmap may need to have its leftmost or rightmost column overlap the neighbouring glyph, and I'm not sure if the renderer supports gray level addition or if it would just overwrite the existing column from the previous neighbour.
As for Freetype supported fonts, there is an API for enabling subpixel rendering which you can call right before rendering the glyph. I've never experimented with it.
By the way, there is already a bug report created for this: https://savannah.gnu.org/bugs/?45629
The idea would be to see words that are "broken" into characters and use a global hyphenation algorithm for optimizing the "breaking".