Hi, With help from my AI assistants, I finally put together a rasterizer in HarfBuzz, in a new harfbuzz-raster library. Accompanying the rasterizer is a COLRv1 color-font renderer, but I like to focus on the rasterizer in this email:
While it was designed from scratch, the general algorithm is similar to FreeType's, that is, a coverage based AA rasterizer. From there though, different approaches are taken. The end result is that the code runs 2x or more faster than FreeType's in my testing. I long had intuited that a tightly woven rasterizer code will perform really well, and this experiment seems to prove that. The code is very short (~1000 lines) and readable: https://github.com/harfbuzz/harfbuzz/blob/main/src/hb-raster-draw.cc I chose FreeType-style curve flattening error bounds, which results in the output being very close to FreeType rasterization. Of course, no hinting in HarfBuzz. If you build latest HarfBuzz from main, there are two tools built in util, hb-raster-all and hb-ft-raster-all that can be used for time measurements of rasterizing all glyphs in a font at a certain font size. An optional output dir can also make them save the rasterized glyphs. Two other tools, hb-raster and hb-ft-raster take a font and string and rasterize them to ppm images. Anyway, I thought people here might be interested in this. I'd love to get feedback. Cheers, behdad http://behdad.org/
