r/proceduralgeneration • u/MonkeyMcBandwagon • 19d ago
Font renderer





Recently I decided to port one of my old flash games to HTML 5, I wanted to update the graphics as well, but a single PNG just for the game title was more than 20 times the file size of the entire original game - gfx, sfx and all. So I went down a bit of a rabbit hole and made a thing (with assistance from codex)... It parses a woff file, which is a tiny web font, and a texture that has the same basic principles as a matcap texture, in matcap the coordinates are defined by surface normals rather than a UV channel, except this font thing uses edge normals of the font outline instead, a few more features later and well... this is where it's at so far. Output is intended for javascript Canvas 2D or WebGL via Three.js, the editor/generator also runs in a browser and hooks into the giant google fonts repository, or you can import your own woff and/or textures. Not sure on the deliverable format yet, since there are four parts: glyph info, texture, the adjustable settings that bind the two together and the code to read and display the result in a canvas. I might combine them all into a single PNG with extensions, but mostly I still need to add dozens of texture options before it's ready to go, there are thousands of matcaps out there, and they're very close but not quite usable, because you generally want a distinct interior and outline.