fontdue
fontdue copied to clipboard
Rasterize a whole string
Hi, I'm making a wordcloud program and I'd like to be able to convert a whole string such as "Hello world" to a bitmap directly, like we can already do with individual chars.
Could this be added to fontdue ?
If this feature is out of scope for the library could you help me in implementing that ?
I'm lost in all the Layout and Metrics parameters and I'm not sure how to interpret them,
especially the negative xmin and ymin of Metrics.
I ran into the same problem when trying to put text on opencv's Mat
. To me, it seems I have to rasterize char by char and it is especially hard considering that advance_width
is actually a f32
instead of i32
.
I'd appreciate if anyone can share a solution for this, maybe something like rusttype
's example to make a image
I ran into the same problem when trying to put text on opencv's
Mat
. To me, it seems I have to rasterize char by char and it is especially hard considering thatadvance_width
is actually af32
instead ofi32
.I'd appreciate if anyone can share a solution for this, maybe something like
rusttype
's example to make a image
I actually succeeded in rasterizing a string ! Wasn't too complicated, documentation was just somewhat lacking (and my own understanding of the topic is poor too).
Check out this project for a concrete example https://github.com/Inspirateur/wordcloud-rs/blob/main/src/text.rs
Rendering a string is tightly coupled to your render pipeline, which isn't something fontdue
wants to get involved with.
Ideally it is basically just make a layout, append your text to the layout, then iterate though layout.glyphs() and perform whatever operation you need to do on each glyph. Usually it's rasterizing them, caching them in an atlas, and generating sprites.
I'll leave this issue open, I probably need some kind of example for a whole string if it's not clear in its current state.