diff --git a/changes.txt b/changes.txt index 3a19852f..dd08b927 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,7 @@ Changes in 1.6 + - Fix highlighting in IGUIEditBox where kerning pairs are used in the font. For example in future italic, OS or other custom fonts. + - IOSOperator::getTextFromClipboard returns now const c8* instead of c8* - Support for copy&paste on linux (X11) added (fixing bug 2804014 found by Pan) diff --git a/source/Irrlicht/CGUIEditBox.cpp b/source/Irrlicht/CGUIEditBox.cpp index 7ca53714..217f04cf 100644 --- a/source/Irrlicht/CGUIEditBox.cpp +++ b/source/Irrlicht/CGUIEditBox.cpp @@ -803,6 +803,12 @@ void CGUIEditBox::draw() // highlight start is on this line s = txtLine->subString(0, realmbgn - startPos); mbegin = font->getDimension(s.c_str()).Width; + + // deal with kerning + mbegin += font->getKerningWidth( + &((*txtLine)[realmbgn - startPos]), + realmbgn - startPos > 0 ? &((*txtLine)[realmbgn - startPos - 1]) : 0); + lineStartPos = realmbgn - startPos; } if (i == hlineStart + hlineCount - 1) @@ -846,7 +852,8 @@ void CGUIEditBox::draw() startPos = BrokenTextPositions[cursorLine]; } s = txtLine->subString(0,CursorPos-startPos); - charcursorpos = font->getDimension(s.c_str()).Width; + charcursorpos = font->getDimension(s.c_str()).Width + + font->getKerningWidth(L"_", CursorPos-startPos > 0 ? &((*txtLine)[CursorPos-startPos-1]) : 0); if (focus && (os::Timer::getTime() - BlinkStartTime) % 700 < 350) {