I'm trying to find a way to figure out the byte length of the text inside the PangoLayout
. I'm setting the text like this:
pango_layout_set_markup(layout, "<i>Hello World</i>", -1);
Since the markup tags don't count as part of the text, the byte length of this layout is 11 but I don't seem to be able to get this value from Pango. It only allows me to get the number of characters using pango_layout_get_character_count()
but this returns the number of characters, not the bytes.
The reason why I need the byte length of the text inside the layout is that I want to find out the cursor position after the last character, so I need to pass the byte length of the text inside the PangoLayout
to pango_layout_get_cursor_pos()
to get that cursor position.
However, I don't seem to find a way to get this byte length. Of course, I could calculate it manually but before doing that I'd first like to ask if there's a Pango way to get this.
To answer my own question, of course the solution is rather obvious. Just get the text from the layout and use strlen
to compute its byte length, i.e.
size_t bytelen = strlen(pango_layout_get_text(f->layout));