kotcrab/vis-ui

Highlight TextArea cursor bug

fgnm opened this issue · 1 comments

fgnm commented

I've found another bug in HighlightTextArea. Highlighted text seams cause a visual bug in the cursor that is not able to determine the correct position of a single char.
In this GIF you can see the bug in Test Application when many words are highlighted on the same line:

highlight_bug

Not sure to what is related, because in the code I can see just font.setColor and font.draw nothing that should change char width. Here it's clear that the highlighted a is different:
immagine immagine

I've found also a workaround (for to my use case and my font type) using setFixedWidthGlyphs in BitmapFont:

BitmapFont defaultMono = monoGenerator.generateFont(parameter);
defaultMono.setFixedWidthGlyphs(parameter.characters);

Duplicate of #306, this shouldn't happen with monospaced font. Though I don't why why you would still need to call setFixedWidthGlyphs even when using monospaced font.

Looks like this is an issue with kerning. X offset of highlight is calculated only on the highlighted text itself while cursor is using glyph positions calculated on the entire text. Unfortunately I'm not seeing an easy fix for this.