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 '_') // width of the font in pixel. Just a Hint for tabing format (computed with '_')
float _FontWidth; float _FontWidth;
// strings to use when computing font size // strings to use when computing font size
::u32string _FontSizingChars; std::string _FontSizingChars;
::u32string _FontSizingFallback; std::string _FontSizingFallback;
// height of the font in pixel. // height of the font in pixel.
// use getFontHeight // use getFontHeight
float _FontHeight; float _FontHeight;

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

Loading…
Cancel
Save