There are three levels: NORMAL (the default), LIGHT and NONE.
The LIGHT level makes FreeType align font outlines to pixel
boundaries vertically, but not horizontally.
Displays text in various sizes, with checkboxes to play with settings
that affect the way text is rendered:
- Color (white-on-black versus black-on-white)
- Autohinter
- sRGB output conversion (not available on all platforms)
The key thing is to to trust the metrics in slot->bitmap, which
are always correctly rounded up to integral values, rather than
also looking at the fixed-point values in slot->metrics and
rounding them manually.
Previously, CanLoadAllGlyphs was pre-flighting the texture atlas
allocation without rendering the glyphs. However, slot->bitmap
isn't populated until the glyph is rendered. I've therefore
removed CanLoadAllGlyphs entirely, and tweaked the preflight
process so that it calls LoadCharGlyph directly.
This should be slightly faster, as we don't have to load the
glyphs twice. It also reduces the total code size a bit, and
guarantees that the "preflight" is always consistent.
The new preflight behavior is *slightly* different, in that it
will expand the first texture atlas up to its maximum size (but
won't move on to a second atlas). Previously, if CanLoadAllGlyphs
failed, we would render only as far as char code 255 (probably
leaving some of the initial texture atlas free).
Closes#1976
FontFaceFreeType checks at runtime whether the whole font can be loaded
into a single texture, by preflighting all the necessary texture atlas
placements in CanLoadAllGlyphs.
However, this preflight operation was slightly different from the real
texture atlas generation, so sometimes CanLoadAllGlyphs was incorrectly
returning true. The LoadCharGlyph would then switch to a new texture
atlas (via SetupNextTexture). This would usually make Text elements
vanish, as the rendered glyphs were in the wrong texture.
We fix this bug with two changes:
- Make CanLoadAllGlyphs process the same char codes in the same order
- Make CanLoadAllGlyphs skip zero-size glyphs (as LoadCharGlyph does)
We also log an error if SetupNextTexture is called unexpectedly, to
help catch future occurrences.