handle size==-1 or absence of size parameter in font tag as expected, i.e. by ignoring it
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37804 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1291,10 +1291,10 @@ wxFont wxXmlResourceHandler::GetFont(const wxString& param)
|
|||||||
// font attributes:
|
// font attributes:
|
||||||
|
|
||||||
// size
|
// size
|
||||||
int isize = wxDEFAULT;
|
int isize = -1;
|
||||||
bool hasSize = HasParam(wxT("size"));
|
bool hasSize = HasParam(wxT("size"));
|
||||||
if (hasSize)
|
if (hasSize)
|
||||||
isize = GetLong(wxT("size"), wxDEFAULT);
|
isize = GetLong(wxT("size"), -1);
|
||||||
|
|
||||||
// style
|
// style
|
||||||
int istyle = wxNORMAL;
|
int istyle = wxNORMAL;
|
||||||
@@ -1372,36 +1372,38 @@ wxFont wxXmlResourceHandler::GetFont(const wxString& param)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// is this font based on a system font?
|
// is this font based on a system font?
|
||||||
wxFont sysfont = GetSystemFont(GetParamValue(wxT("sysfont")));
|
wxFont font = GetSystemFont(GetParamValue(wxT("sysfont")));
|
||||||
|
|
||||||
if (sysfont.Ok())
|
if (font.Ok())
|
||||||
{
|
{
|
||||||
if (hasSize)
|
if (hasSize && isize != -1)
|
||||||
sysfont.SetPointSize(isize);
|
font.SetPointSize(isize);
|
||||||
else if (HasParam(wxT("relativesize")))
|
else if (HasParam(wxT("relativesize")))
|
||||||
sysfont.SetPointSize(int(sysfont.GetPointSize() *
|
font.SetPointSize(int(font.GetPointSize() *
|
||||||
GetFloat(wxT("relativesize"))));
|
GetFloat(wxT("relativesize"))));
|
||||||
|
|
||||||
if (hasStyle)
|
if (hasStyle)
|
||||||
sysfont.SetStyle(istyle);
|
font.SetStyle(istyle);
|
||||||
if (hasWeight)
|
if (hasWeight)
|
||||||
sysfont.SetWeight(iweight);
|
font.SetWeight(iweight);
|
||||||
if (hasUnderlined)
|
if (hasUnderlined)
|
||||||
sysfont.SetUnderlined(underlined);
|
font.SetUnderlined(underlined);
|
||||||
if (hasFamily)
|
if (hasFamily)
|
||||||
sysfont.SetFamily(ifamily);
|
font.SetFamily(ifamily);
|
||||||
if (hasFacename)
|
if (hasFacename)
|
||||||
sysfont.SetFaceName(facename);
|
font.SetFaceName(facename);
|
||||||
if (hasEncoding)
|
if (hasEncoding)
|
||||||
sysfont.SetDefaultEncoding(enc);
|
font.SetDefaultEncoding(enc);
|
||||||
|
}
|
||||||
m_node = oldnode;
|
else // not based on system font
|
||||||
return sysfont;
|
{
|
||||||
|
font = wxFont(isize == -1 ? wxNORMAL_FONT->GetPointSize() : isize,
|
||||||
|
ifamily, istyle, iweight,
|
||||||
|
underlined, facename, enc);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_node = oldnode;
|
m_node = oldnode;
|
||||||
return wxFont(isize, ifamily, istyle, iweight,
|
return font;
|
||||||
underlined, facename, enc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user