I'm currently working on a FOSS crate for which I need to be able to rasterize arbitrary text that becomes known at runtime. I'm looking for a crate to help with this, and I have these requirements:
- Can rasterize individual letters/characters in a meaningful sense (I need to be able to know where specific characters are in my rasterization, and I need some control over that)
- Ability to use font that is packaged in the compiled binary
- Some easy-to-use system that prevents alignment issues (see the screenshot below)
- Good documentation (ideally, more than just reference documentation in docs.rs, but good reference documentation is essential — every function that is needed to make it do these things should be documented)
- Does not overly rely on some 3rd party 2D graphics system — my crate has its own 2D graphics system, and I have no interest in external dependencies here. Ideally, I would get a 2D array/slice/vector (or a 1D array/slice/vector with 2D data) that has the pixel data in it, and I wouldn't need to muck around with paths or curves in someone else's 2D graphics system.
- CPU-rendering is a must — I want my crate to work on all systems, even when GPU acceleration isn't available. It's fine if it uses GPU rendering when it's available, as long as the CPU-rendering option is reasonably efficient and is pixel-for-pixel identical.
- No external C libraries (It's fine if it compiles a C library into itself, but I want compilation to be trivial and to work with every --target parameter out of the box and without any custom configuration. This is a feature that I want for my crate, so all of my dependencies must have it too.)
Things that are desired, but not essential:
- Support for scripts without a single concept of a discrete character
I tried font-kit, and with its freetype loader being used, it has all features that I need, except I can't figure out how to properly align text:
Also, it relies on
pathfinder_geometry in its interface to me a bit more than I would like, but not to the extent that it becomes a real problem.