cancel
Showing results for 
Search instead for 
Did you mean: 

How to obtain the actual width of a dot char when it's merged with the char it just follows ?

GMeur
Senior

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 :

0693W00000GZUq1QAH.pngThe 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 :

0693W00000GZUs7QAH.pngMy 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.

2 REPLIES 2
MM..1
Chief II

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

Thanks for your message. So, for anyone wondering, this information is retrieved with the function _textArea.getTypedText().getFont()->getKerning();