From 5df8ec43a04d377bfaf2b745d32b4c49e6574118 Mon Sep 17 00:00:00 2001 From: Ben Saine Date: Wed, 22 Dec 2021 17:10:55 +0000 Subject: [PATCH] Resolve "Encoding issues in client beta (after core4 merge)" --- nel/include/nel/gui/view_text.h | 4 +++- nel/src/gui/view_text.cpp | 38 ++++++++------------------------- 2 files changed, 12 insertions(+), 30 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 89f31d40d..814f88469 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; @@ -1767,7 +1768,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 +1952,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; } // @@ -3113,8 +3114,6 @@ namespace NLGUI TextContext->setEmbolden (_Embolden); TextContext->setOblique (_Oblique); -#if 1 - UTextContext::CStringInfo si = TextContext->getStringInfo("XO"); float xoHeight = si.StringHeight; @@ -3145,34 +3144,14 @@ namespace NLGUI si = TextContext->getStringInfo(" "); _SpaceWidth = si.StringWidth; - // Font Width (used for ) + // Font Width si = TextContext->getStringInfo("O"); _FontWidth = si.StringWidth; -#else - - // Letter size - UTextContext::CStringInfo si = TextContext->getStringInfo(_FontSizingChars); - - // font generator changes unknown glyphs to dot '.'. use fallback if it looks odd - if (_FontSize > (si.StringHeight + si.StringLine)) - { - si = TextContext->getStringInfo(_FontSizingFallback); - } - - // add a padding of 1 pixel else the top will be truncated - _FontHeight = si.StringHeight + 1; - _FontLegHeight = si.StringLine; - - // Space width - si = TextContext->getStringInfo(" "); - _SpaceWidth = si.StringWidth; - - // Font Width (used for ) + // Tab Width (used for {Txx}) + // if not set to "_", breaks item help window si = TextContext->getStringInfo("_"); - _FontWidth = si.StringWidth; - -#endif + _TabWidth = si.StringWidth; } @@ -3641,6 +3620,7 @@ namespace NLGUI f.serial(_Localized); SERIAL_SINT(_FontSize); SERIAL_UINT(_FontWidth); + SERIAL_UINT(_TabWidth); SERIAL_UINT(_FontHeight); SERIAL_UINT(_FontLegHeight); f.serial(_SpaceWidth);