diff --git a/src/guiengine/scalable_font.cpp b/src/guiengine/scalable_font.cpp index 23579e512..6b0ea6f16 100644 --- a/src/guiengine/scalable_font.cpp +++ b/src/guiengine/scalable_font.cpp @@ -452,11 +452,15 @@ void ScalableFont::draw(const core::stringw& text, core::position2d offset = position.UpperLeftCorner; core::dimension2d text_dimension; - if (m_rtl || hcenter || vcenter || clip) + // When we use the "tab" hack, disable right-alignment, it messes up everything + bool has_tab = (text.findFirst(L'\t') != -1); + + if ((m_rtl && !has_tab) || hcenter || vcenter || clip) { text_dimension = getDimension(text.c_str()); - if (hcenter) offset.X += (position.getWidth() - text_dimension.Width) / 2; - else if (m_rtl) offset.X += (position.getWidth() - text_dimension.Width); + + if (hcenter) offset.X += (position.getWidth() - text_dimension.Width) / 2; + else if (m_rtl && !has_tab) offset.X += (position.getWidth() - text_dimension.Width); if (vcenter) offset.Y += (position.getHeight() - text_dimension.Height) / 2; if (clip) @@ -465,7 +469,15 @@ void ScalableFont::draw(const core::stringw& text, clippedRect.clipAgainst(*clip); if (!clippedRect.isValid()) return; } - } // if rtl, centered, or clip + } + + if (m_rtl && has_tab) + { + const int where = text.findFirst(L'\t'); + core::stringw substr = text.subString(0, where-1); + text_dimension = getDimension(text.c_str()); + offset.X += (position.getWidth()/2 - text_dimension.Width); + } // ---- collect character locations const unsigned int text_size = text.size();