From 7300f2b0791bff35418e3db6500e14228a555b87 Mon Sep 17 00:00:00 2001 From: bensaine Date: Wed, 22 Dec 2021 11:50:49 -0500 Subject: [PATCH] Seperate tabwidth and fontsize vars --- nel/include/nel/gui/view_text.h | 4 +++- nel/src/gui/view_text.cpp | 29 +++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/nel/include/nel/gui/view_text.h b/nel/include/nel/gui/view_text.h index cc92cf47d..e7405a2dd 100644 --- a/nel/include/nel/gui/view_text.h +++ b/nel/include/nel/gui/view_text.h @@ -282,8 +282,10 @@ namespace NLGUI bool _FontSizeCoef; bool _Embolden; bool _Oblique; - // width of the font in pixel. Just a Hint for tabing format (computed with '_') + // width of the font in pixel. float _FontWidth; + // width of tabs + float _TabWidth; // strings to use when computing font size std::string _FontSizingChars; std::string _FontSizingFallback; diff --git a/nel/src/gui/view_text.cpp b/nel/src/gui/view_text.cpp index 58db75fdc..5600c3564 100644 --- a/nel/src/gui/view_text.cpp +++ b/nel/src/gui/view_text.cpp @@ -95,6 +95,7 @@ namespace NLGUI _FontWidth= 0; _FontHeight = 0; _FontLegHeight = 0; + _TabWidth= 0; _TextSelection= false; _TextSelectionStart= 0; @@ -1284,7 +1285,7 @@ namespace NLGUI px += firstSpace; // skip tabulation before current word if(currWord.Format.TabX) - px= max(px, (float)(_XReal * _Scale + currWord.Format.TabX*_FontWidth)); + px= max(px, (float)(_XReal * _Scale + currWord.Format.TabX*_TabWidth)); // draw. We take floorf px to avoid filtering of letters that are not located on a pixel boundary float fx = px / _Scale; @@ -1688,6 +1689,12 @@ namespace NLGUI return _FontWidth / _Scale; } + // *************************************************************************** + uint CViewText::getTabWidth() const + { + return _TabWidth / _Scale; + } + // *************************************************************************** uint CViewText::getFontHeight() const { @@ -1767,7 +1774,7 @@ namespace NLGUI getFormatTagChange(i, formatTagIndex, wordFormat); // Ensure the line witdh count the tab - rWidthCurrentLine= max(rWidthCurrentLine, (float)wordFormat.TabX*_FontWidth); + rWidthCurrentLine= max(rWidthCurrentLine, (float)wordFormat.TabX*_TabWidth); } NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName); @@ -1951,7 +1958,7 @@ namespace NLGUI // compute size of spaces/Tab + word newLineWidth = lineWidth + numSpaces * _SpaceWidth; - newLineWidth = max(newLineWidth, (float)wordFormat.TabX*_FontWidth); + newLineWidth = max(newLineWidth, (float)wordFormat.TabX*_TabWidth); newLineWidth+= si.StringWidth; } // @@ -3145,10 +3152,14 @@ namespace NLGUI si = TextContext->getStringInfo(" "); _SpaceWidth = si.StringWidth; - // Font Width (used for ) + // Font Width + si = TextContext->getStringInfo("O"); + _FontWidth = si.StringWidth; + + // Tab Width (used for {Txx}) // if not set to "_", breaks item help window si = TextContext->getStringInfo("_"); - _FontWidth = si.StringWidth; + _TabWidth = si.StringWidth; #else @@ -3169,10 +3180,15 @@ namespace NLGUI si = TextContext->getStringInfo(" "); _SpaceWidth = si.StringWidth; - // Font Width (used for ) + // Font Width si = TextContext->getStringInfo("_"); _FontWidth = si.StringWidth; + // Tab Width (used for {Txx}) + // if not set to "_", breaks item help window + si = TextContext->getStringInfo("_"); + _TabWidth = si.StringWidth; + #endif } @@ -3642,6 +3658,7 @@ namespace NLGUI f.serial(_Localized); SERIAL_SINT(_FontSize); SERIAL_UINT(_FontWidth); + SERIAL_UINT(_TabWidth); SERIAL_UINT(_FontHeight); SERIAL_UINT(_FontLegHeight); f.serial(_SpaceWidth);