RazrFalcon / rustybuzz

A complete harfbuzz's shaping algorithm port to Rust
MIT License
498 stars 34 forks source link

no_std / constrained memory support #26

Closed xobs closed 3 years ago

xobs commented 3 years ago

I'm looking to do advanced text shaping on an embedded platform. I've found that rusttype can operate in an embedded environment with no_std support, and I've recently added rustybuzz support to advanced features such as Arabic rendering.

rusttype seems like it doesn't use much memory, even when doing actual rendering.

How difficult would it be to track memory consumption and/or add support for no_std?

RazrFalcon commented 3 years ago

rustybuzz is mostly zero-allocation. So technically, if you provide large enough buffers (instead of internal one), it should work fine. But it will require some substantial changes.

So mainly it's two shaping buffers (input code points + output glyphs), GSUB/GPOS data cache and complex shapers context (can be stack-allocated).

PS: not sure what you meant by "track memory consumption".

xobs commented 3 years ago

By "track memory consumption" I mostly meant a way to determine how much data is used. I suspect the answer is to use valgrind, or use a tracing memory allocator in Rust.

I'm glad to hear it's at least within the scope of possibilities! I'll close this issue for now and will look into what it would take and roughly how much memory would be required on my own.