cosmic-text icon indicating copy to clipboard operation
cosmic-text copied to clipboard

Getting bounding box of text after layout

Open ten3roberts opened this issue 2 years ago • 1 comments

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

ten3roberts avatar Dec 11 '23 22:12 ten3roberts

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

nicoburns avatar Dec 12 '23 00:12 nicoburns

This will be handled in #70.

jackpot51 avatar Jun 11 '24 14:06 jackpot51