2021-11-30 05:58 AM
I'm developping a small textEdition window to let the user move a cursor and select the text in order to edit it more easily. Therefore, in order to position the cursor correctly, I need to know the x and y position of each char in the textBuffer. I thought it was easy and that I could calculate the x coordinate of each char adding the width of the previous char with the help of that function :
_textArea.getTypedText().getFont()->getCharWidth()
And it works fine… until it meets certain dots or commas (and I guess the problem must appear too with other chars). See for yourself :
The dot is positionned below the r char. That is, the total width of the "r." string does not equal the width of the r char + the width of the dot. However, if a m precedes the dot (for instance), the problem doesn't occur :
My question is therefore the following : in the specific case that the dot "merges" with the character it is place next to, how can I calculate the width that the dot actually takes in relation to the previous char ?
I use the verdana font. I don't know if that merge phenomenon is font specific ?
Thanks in advance.
2021-11-30 06:15 AM
This situation is kerning and touchgfx generates file for this for example Kerning_verdana_40_4bpp.cpp
i mean handle it is hard with your cursor and better is replace your string with add | on cursor possition
2021-11-30 06:51 AM
Thanks for your message. So, for anyone wondering, this information is retrieved with the function _textArea.getTypedText().getFont()->getKerning();