Adjust font sizing

develop
kaetemi 4 years ago
parent 592ec2aaf1
commit 7ea4b2b989

@ -262,8 +262,8 @@ namespace NLGUI
// width of the font in pixel. Just a Hint for tabing format (computed with '_')
float _FontWidth;
// strings to use when computing font size
::u32string _FontSizingChars;
::u32string _FontSizingFallback;
std::string _FontSizingChars;
std::string _FontSizingFallback;
// height of the font in pixel.
// use getFontHeight
float _FontHeight;

@ -119,11 +119,9 @@ namespace NLGUI
// - "_" that should be the character with the lowest part
// - A with an accent for the highest part
// https://www.compart.com/en/unicode/U+00C4
static const u32char chars[] = { (u32char)'_', 0x000000C4, 0 };
_FontSizingChars = chars;
_FontSizingChars = "_\xC3\x84q";
// fallback if SizingChars are not supported by font
static const u32char fallback[] = { (u32char)'|', 0 };
_FontSizingFallback = fallback;
_FontSizingFallback = "|XO";
computeFontSize ();
}
@ -399,12 +397,12 @@ namespace NLGUI
else
if ( name == "sizing_chars" )
{
return CUtfStringView(_FontSizingChars).toUtf8();
return _FontSizingChars;
}
else
if ( name == "sizing_fallback" )
{
return CUtfStringView(_FontSizingFallback).toUtf8();
return _FontSizingFallback;
}
else
return "";
@ -691,13 +689,13 @@ namespace NLGUI
else
if( name == "sizing_chars" )
{
_FontSizingChars = CUtfStringView(value).toUtf32();
_FontSizingChars = value;
return true;
}
else
if( name == "sizing_fallback" )
{
_FontSizingFallback = CUtfStringView(value).toUtf32();
_FontSizingFallback = value;
return true;
}
else
@ -769,8 +767,8 @@ namespace NLGUI
xmlSetProp( node, BAD_CAST "clamp_right", BAD_CAST toString( _ClampRight ).c_str() );
xmlSetProp( node, BAD_CAST "auto_clamp_offset", BAD_CAST toString( _AutoClampOffset ).c_str() );
xmlSetProp( node, BAD_CAST "continuous_update", BAD_CAST toString( _ContinuousUpdate ).c_str() );
xmlSetProp( node, BAD_CAST "sizing_chars", BAD_CAST CUtfStringView(_FontSizingChars).toUtf8().c_str() );
xmlSetProp( node, BAD_CAST "sizing_fallback", BAD_CAST CUtfStringView(_FontSizingFallback).toUtf8().c_str() );
xmlSetProp( node, BAD_CAST "sizing_chars", BAD_CAST _FontSizingChars.c_str() );
xmlSetProp( node, BAD_CAST "sizing_fallback", BAD_CAST _FontSizingFallback.c_str() );
return true;
}
@ -956,18 +954,18 @@ namespace NLGUI
}
// "_Ä" lowest/highest chars (underscore, A+diaeresis)
static const u32char chars[] = { (u32char)'_', 0x000000C4, 0 };
_FontSizingChars = chars;
prop = (char*) xmlGetProp( cur, (xmlChar*)"sizing_chars" );
if (prop)
_FontSizingChars = CUtfStringView((const char*)prop).toUtf32();
_FontSizingChars = (const char*)prop;
else
_FontSizingChars = "_\xC3\x84q";
// fallback if SizingChars are not supported by font
static const u32char fallback[] = { (u32char)'|', 0 };
_FontSizingFallback = fallback;
prop = (char*) xmlGetProp( cur, (xmlChar*)"sizing_fallback" );
if (prop)
_FontSizingFallback = CUtfStringView((const char*)prop).toUtf32();
_FontSizingFallback = (const char *)prop;
else
_FontSizingFallback = "|XO";
computeFontSize ();
}
@ -1475,10 +1473,8 @@ namespace NLGUI
// ***************************************************************************
void CViewText::setFontSizing(const std::string &chars, const std::string &fallback)
{
_FontSizingChars.clear();
_FontSizingChars = CUtfStringView(chars).toUtf32();
_FontSizingFallback.clear();
_FontSizingFallback = CUtfStringView(fallback).toUtf32();
_FontSizingChars = chars;
_FontSizingFallback = fallback;
}
// ***************************************************************************

Loading…
Cancel
Save