Seperate tabwidth and fontsize vars

26-encoding-issues-in-client-beta-after-core4-merge
bensaine 3 years ago
parent bd25e2d356
commit 7300f2b079

@ -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;

@ -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 <tab>)
// 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 <tab>)
// 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);

Loading…
Cancel
Save