Remix.run Logo
▲ drfuchs 5 hours ago

For prior related work, check out patent US-6377261-B1 "Compiling glyphs into instructions for imaging for execution on a general purpose computer" filed 1996. The basic idea is each character turns into a sequence of "Load Immediate" / "Shift" / "OR to Memory" instructions; so there's no more fetching from a stored bitmap of the font, as the pixels are implicit in the Immediate data in the generated machine code. Then you can get fancy when one row of pixels is the same as the previous row in the character, so you don't even need to do the Load Immediate. Etc. This scheme was used in FrameMaker for Macintosh back in the day, as implemented by Gus Fernandez (who went hog wild on additional optimizations).

▲drfuchs 5 hours ago | parent | next [-]

Permalink: https://patents.google.com/patent/US6377261B1/en

Image 6 (with figures 8 through 12) is fun; you can eliminate the Shift if you're willing to have multiple different JITed functions for each character, each one generated knowing what its shift count is, leading to yet more optimization opportunities.

▲StilesCrisis 5 hours ago | parent [-]

Since he's not caching the JITted code anyway, might as well!

▲bitwize 3 hours ago | parent | prev [-]

Something like this was called "sprite compilation" and used a lot in the DOS game coding scene back in the day. The idea was, given a bitmap image of a sprite, produce the code that would draw that sprite on the screen in assembly and incorporate it into your game. Not very flexible, but fast and useful in the days when games had a lot of 2D bits and bobs moving around, especially for those who could not yet afford a 486 and were stuck on an old Tandy 1000 or something...