allegro_schrift

Drop-in replacement for Allegro_TTF that contains libschrift, instead of using FreeType2.

It is 100% API compatible with the vanilla TrueType addon. Compile Allegro with these files inside of /addons/ttf.

Requires the primitives addon.

Comparison between FreeType2 and schrift when running Allegro's ex_ttf demo

Pros

  • It doesn't require NT 6 kernel calls
  • It doesn't dynamically link against hundreds of thousands of lines of ugly corporate-backed C code you can't read
    • Our addon is only a couple or few hundred lines, and libschrift is less than 2,000. They're compiled together.
      The original Allegro_TTF is over 1,000 lines (for a good reason) and has a relatively massive dependency weight (for a stupid reason).

Caveats

  • Pre-stretching is not implemented.
  • The entire caching system is gone, fonts are baked to textures immediately and no further. This makes supporting some languages with this add-on inconvenient, and increases load times. For many users this an acceptable tradeoff.
    • The cache_text setting in allegro5.cfg is now reused to determine what glyphs can be rendered at all. skip_cache_misses has no effect.
      When cache_text is undefined, the Latin, Germanic, and Romance alphabets will be generated by default. (not necessarily 32 - 255)
    • TODO Alternatively, the developer can force a custom range of unicode characters to be generated using a new parameter in the al_load_ttf_font function.
  • Kerning, per-character advance and offsets, and other features which are exposed by libschrift are not currently implemented, but doing so is possible. See the above comparison screenshot.

In Practice (WIP)

You can see here some of the flaws with this implementation. Line heights are taller than they should be. Not visible in the below example is the atlas size to hold glyph data, which is quite large by default.

The garbage the end of strings is not an issue with allegro_schrift, but a bug in the below example. It does not appear with the vanilla addon because it automatically generates an empty glyph for newlines. You may need to account for how your game handles strings.

Time Falcon main menu with the allegro_schrift plugin, work in progress

Description
libschrift glue addon for Allegro, drop-in replacement for allegro_ttf
Readme 490 KiB
Languages
C 98.6%
CMake 1.4%