glyph-brush
glyph-brush copied to clipboard
Get width of last character
Hello (again ;-) ),
We are face to an issue to draw our underline text.
Based on GlyphCruncher it's possible to retrieve character position.
But in case of:
some
awesome
text longer here
drawn in one section, we cannot retrieve coordinates of awesome
word as Glyph::position
returns le left point of the character. And GlyphCruncher::glyph_bounds cannot be used as last line is longer ...
As all letters does not have the same width, do you have a way to find the width of one character ?
Thank you for your advices. Marc-Antoine
The right of a glyph is its position + the ScaleFont::h_advance
for that glyph. So your horizontal positions to underline "awesome" would start at something like a.position.x
until e.position.x + font.h_advance(e.id)
If the final glyph has another glyph after it (so not the word case) you may also want to apply kerning.
Actually I didn't mention Font::glyph_bounds
which seems a better answer to your question.
Thank you very much, we have implemented and work perfectly