From 9f3fbe1bd773664b1e86241e71875cd97230d791 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 8 Jan 2012 02:33:34 +0100 Subject: GRAPHICS/GUI: Implement kerning support for Font. This adapts the related graphics code, which is the generic Font API and the TTF font implementation. It furthermore adapts the GUI to properly take care of kerning in text input widgets. --- gui/widgets/edittext.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gui/widgets/edittext.cpp') diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp index 0337fe1e87..af8ab8aa5b 100644 --- a/gui/widgets/edittext.cpp +++ b/gui/widgets/edittext.cpp @@ -67,10 +67,13 @@ void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) { int width = 0; uint i; + uint last = 0; for (i = 0; i < _editString.size(); ++i) { - width += g_gui.theme()->getCharWidth(_editString[i], _font); + const uint cur = _editString[i]; + width += g_gui.getCharWidth(cur, _font) + g_gui.getKerningOffset(last, cur, _font); if (width >= x) break; + last = cur; } if (setCaretPos(i)) draw(); -- cgit v1.2.3