pop-os / cosmic-text

Pure Rust multi-line text handling
https://pop-os.github.io/cosmic-text/cosmic_text/
Apache License 2.0
1.59k stars 102 forks source link

Getting bounding box of text after layout #205

Closed ten3roberts closed 3 months ago

ten3roberts commented 9 months ago

Is it possible to get the bounds (width + height) of a Buffer after shaping?

The layout_runs() api does not give the line's total width, neither is it possible to extract it from the glyphs without using the swash cache.

My use case is to layout text and get its size in order to give it a background rectangle.

Thanks

nicoburns commented 9 months ago

It's not particularly nice, but it's possible. See the code linked in https://github.com/pop-os/cosmic-text/issues/70#issuecomment-1712645954

jackpot51 commented 3 months ago

This will be handled in #70.