Resolve "Encoding issues in client beta (after core4 merge)"

merge-requests/34/merge
Ben Saine 3 years ago committed by Nuno Gonçalves (Ulukyn)
parent 9e3064871a
commit 5df8ec43a0

@ -282,8 +282,10 @@ namespace NLGUI
bool _FontSizeCoef; bool _FontSizeCoef;
bool _Embolden; bool _Embolden;
bool _Oblique; bool _Oblique;
// width of the font in pixel. Just a Hint for tabing format (computed with '_') // width of the font in pixel.
float _FontWidth; float _FontWidth;
// width of tabs
float _TabWidth;
// strings to use when computing font size // strings to use when computing font size
std::string _FontSizingChars; std::string _FontSizingChars;
std::string _FontSizingFallback; std::string _FontSizingFallback;

@ -95,6 +95,7 @@ namespace NLGUI
_FontWidth= 0; _FontWidth= 0;
_FontHeight = 0; _FontHeight = 0;
_FontLegHeight = 0; _FontLegHeight = 0;
_TabWidth= 0;
_TextSelection= false; _TextSelection= false;
_TextSelectionStart= 0; _TextSelectionStart= 0;
@ -1284,7 +1285,7 @@ namespace NLGUI
px += firstSpace; px += firstSpace;
// skip tabulation before current word // skip tabulation before current word
if(currWord.Format.TabX) 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 // draw. We take floorf px to avoid filtering of letters that are not located on a pixel boundary
float fx = px / _Scale; float fx = px / _Scale;
@ -1767,7 +1768,7 @@ namespace NLGUI
getFormatTagChange(i, formatTagIndex, wordFormat); getFormatTagChange(i, formatTagIndex, wordFormat);
// Ensure the line witdh count the tab // 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); NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName);
@ -1951,7 +1952,7 @@ namespace NLGUI
// compute size of spaces/Tab + word // compute size of spaces/Tab + word
newLineWidth = lineWidth + numSpaces * _SpaceWidth; newLineWidth = lineWidth + numSpaces * _SpaceWidth;
newLineWidth = max(newLineWidth, (float)wordFormat.TabX*_FontWidth); newLineWidth = max(newLineWidth, (float)wordFormat.TabX*_TabWidth);
newLineWidth+= si.StringWidth; newLineWidth+= si.StringWidth;
} }
// //
@ -3113,8 +3114,6 @@ namespace NLGUI
TextContext->setEmbolden (_Embolden); TextContext->setEmbolden (_Embolden);
TextContext->setOblique (_Oblique); TextContext->setOblique (_Oblique);
#if 1
UTextContext::CStringInfo si = TextContext->getStringInfo("XO"); UTextContext::CStringInfo si = TextContext->getStringInfo("XO");
float xoHeight = si.StringHeight; float xoHeight = si.StringHeight;
@ -3145,34 +3144,14 @@ namespace NLGUI
si = TextContext->getStringInfo(" "); si = TextContext->getStringInfo(" ");
_SpaceWidth = si.StringWidth; _SpaceWidth = si.StringWidth;
// Font Width (used for <tab>) // Font Width
si = TextContext->getStringInfo("O"); si = TextContext->getStringInfo("O");
_FontWidth = si.StringWidth; _FontWidth = si.StringWidth;
#else // Tab Width (used for {Txx})
// if not set to "_", breaks item help window
// 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>)
si = TextContext->getStringInfo("_"); si = TextContext->getStringInfo("_");
_FontWidth = si.StringWidth; _TabWidth = si.StringWidth;
#endif
} }
@ -3641,6 +3620,7 @@ namespace NLGUI
f.serial(_Localized); f.serial(_Localized);
SERIAL_SINT(_FontSize); SERIAL_SINT(_FontSize);
SERIAL_UINT(_FontWidth); SERIAL_UINT(_FontWidth);
SERIAL_UINT(_TabWidth);
SERIAL_UINT(_FontHeight); SERIAL_UINT(_FontHeight);
SERIAL_UINT(_FontLegHeight); SERIAL_UINT(_FontLegHeight);
f.serial(_SpaceWidth); f.serial(_SpaceWidth);

Loading…
Cancel
Save