Get position of a character in Label/RichText

Get position of a character in Label/RichText
0

Hi everyone,

I need to set position of a node at exactly a character in a Label/RichText.
Example:image

If you have a solution for this, please help me!

Is this hard coded text, or will it be variably different at run time? That might make the solution different…

If the second, what is the logic behind choosing a specific character? Use case etc. Some background information might help simplify the thought/solution process.

Thanks,
It will be variable, choosing character by index in the string.

Ok… there might be a way built in that I do not know of… but, you can always make a temp label, and populate it with all characters ‘up to’ the one you want, from there you can find the height (from the top). Then with similar logic, remove all lines up to the line the character is on, populate the temp label, and find the width. Now you have a general x,y distance from top left of the original label to the character, minus some offset you decide for a character probably based on font size.

I found: Sprite* Label::getLetter(int letterIndex). inside the Label class. Look around inside the node’s codes and see if there is anything that can help find built in functionality.