It would be nice if there were a solution which gets 90% of the value in 10% of the code.
It would be nice if there were a solution which gets 90% of the value in 10% of the code.
And once upon a time, X11 had another weird little format besides PS and TTF fonts, namely "Speedo" fonts[1]. Also used in plenty of other software, as PS/TTF weren't that common and it was made by Bitstream, one of the major font foundry (because no font format helps if there are no legal fonts available for it).
Alas, both not really in use these days.
(like with the pixel grill on CRTs, often older digital formats were subject to some sort of analogue low-pass filtering before being perceived)
https://paulbourke.net/dataformats/hershey/
It seems to describe a "pen" which draws the character. It is indeed pretty cool!
https://github.com/Michaelangel007/game_dev_pdfs/blob/master...
Very simple at their core but you can incrementally do more work to increase the fidelity you get out of them.
My Ruby rewrite is ~600 lines: https://github.com/vidarh/skrift
Libschrift is very readable.
I did my Ruby rewrite basically just top to bottom before reorganizing it. Mine is... readable if you're well versed in Ruby, but still has some warts where it's less than idiomatic Ruby because I stuck closely to the original.
Basically TTF has a crufty binary format, but the basic font data if you're willing to ignore ligatures, hinting, OpenType support and emoticons, is fairly simple (it's basically a bunch of polygons consisting of quadratic beziers and lines, and quadratic beziers are easy to tesselate into lines if you don't want to do a more complex curve renderer), just error-prone to figure out.
If you want/need OpenType you need to support cubic beziers on top of that, which isn't that bad. If you want to support emoticons you need to support a subset of SVG (!)...
So TTF without those bits is pretty much the halfway point.
Also do look at the Canvas C++ header implementation linked in this comment[1]. It's readable, and more featureful than libschrift or my Ruby rewrite, and it's still small while packing a full rendering library in there not just the font renderer. I intend to pillage it (with credits) for ideas ;)
finally, an approach that's conceptually simpler that i've never seen used (though metafont comes close) is to represent the font as a subroutine in a turing-complete bytecode that takes a glyph index as input and produces an image with font metrics data as output. something like the universal machine from the cult of the bound variable is only about a page of code. this requires you to put the bezier rasterization and polygon filling code in your font file instead, so it doesn't simplify the total system
Before TrueType (System 7, 1991), it was the only thing the OS supported out of the box.
(Adobe Type Manager (https://en.wikipedia.org/wiki/Adobe_Type_Manager) is a bit older than 1991, but (obviously from its name) wasn’t an Apple product)