4 ms·
I wonder, is there something on the complexity curve between 8x8 bitmap and fullblown ttf with all the complexity as you've outlined? It would be nice if there
by vitiral 3y ago
I wonder, is there something on the complexity curve between 8x8 bitmap and fullblown ttf with all the complexity as you've outlined?
It would be nice if there were a solution which gets 90% of the value in 10% of the code.
- vidarh 3y agolibschrift is ~1500 lines of C: https://github.com/tomolt/libschrift https://github.com/tomolt/libschrift My Ruby rewrite is ~600 lines: https://github.com/vidarh/skrift 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 ;) [1] https://news.ycombinator.com/item?id=38839114 https://news.ycombinator.com/item?id=38839114
- stravant 3y agoYou're looking for SDF fonts. Very simple at their core but you can incrementally do more work to increase the fidelity you get out of them.
- colonwqbang 3y agoUsing a better, higher-resolution bitmap font? They don't have to look as awful as that https://terminus-font.sourceforge.net/img1/12x24b.gif https://terminus-font.sourceforge.net/img1/12x24b.gif
- vitiral 3y agoThat does look a lot better!
- grishka 3y agoProportional bitmap fonts in several fixed sizes. One place where they were used a lot that comes to mind is those phones from the 00s, but also many other embedded devices that have a screen with text-based menus.
- Someone 3y agoThat’s what the Mac used, too. For examples, see http://kare.com/apple-icons/ http://kare.com/apple-icons/ 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 https://en.wikipedia.org/wiki/Adobe_Type_Manager) is a bit older than 1991, but (obviously from its name) wasn’t an Apple product)
- djmips 3y agoHere's a link to a Valve paper from 2007 Siggraph but certainly there's been a lot of dev since then but this is kind of cool still! https://github.com/Michaelangel007/game_dev_pdfs/blob/master/graphics/signed_distance_field/SIGGRAPH2007_AlphaTestedMagnification.pdf https://github.com/Michaelangel007/game_dev_pdfs/blob/master...
- rzzzt 3y agoI nominate the BGI vector fonts that you could use in Turbo Pascal programs.
- kragen 3y agotex's metafont format might be simpler or more complex than truetype, depending on your utility function. sdf fonts are clearly in the range you want, as several commenters have said, and likewise for proportional and scalable bitmap (and grayscale, or color) fonts. also worth mentioning are stroke fonts, especially hershey fonts, and polygonal outline fonts without beziers 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
- mhd 3y agoHershey fonts[0] look a bit odd on high-res pixel screens, but one might be able to cope with that by carefully selecting sizes and fudging with the definitions. Definitely low-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. [0]: https://en.wikipedia.org/wiki/Hershey_fonts https://en.wikipedia.org/wiki/Hershey_fonts [1]: https://en.wikipedia.org/wiki/Bitstream_Speedo_Fonts https://en.wikipedia.org/wiki/Bitstream_Speedo_Fonts
- 082349872349872 3y agoNote that Hershey's (physical!) pens were about 3 times as large as his coordinate system; rendering them with a suitable thickness gives me reasonable results even at higher resolutions. (like with the pixel grill on CRTs, often older digital formats were subject to some sort of analogue low-pass filtering before being perceived)
- vitiral 3y agoI haven't looked deeply yet, thanks for the resources!
- vitiral 3y agoI found this reference for Hershey Vector font https://paulbourke.net/dataformats/hershey/ https://paulbourke.net/dataformats/hershey/ It seems to describe a "pen" which draws the character. It is indeed pretty cool!
- lifthrasiir 3y agoI once worked on an almost-bitmap font with its own description language [1] that can be extended to work on subpixel grids. I went as far as combining marks (not in the public repository though). [1] https://github.com/lifthrasiir/unison https://github.com/lifthrasiir/unison
- vitiral 3y agoUnison looks more like what I was thinking, thanks!
- pcwalton 3y agoJust use a TrueType subset with no hinting. stb_truetype implements one in 5k lines of code and that includes CFF format outlines. You could omit those and get it even smaller.