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:
Vadim Zeitlin
2006-03-04 22:40:16 +00:00
parent f0756835d5
commit 94245f6df0

View File

@@ -1291,10 +1291,10 @@ wxFont wxXmlResourceHandler::GetFont(const wxString& param)
// font attributes:
// size
int isize = wxDEFAULT;
int isize = -1;
bool hasSize = HasParam(wxT("size"));
if (hasSize)
isize = GetLong(wxT("size"), wxDEFAULT);
isize = GetLong(wxT("size"), -1);
// style
int istyle = wxNORMAL;
@@ -1372,36 +1372,38 @@ wxFont wxXmlResourceHandler::GetFont(const wxString& param)
}
// 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)
sysfont.SetPointSize(isize);
if (hasSize && isize != -1)
font.SetPointSize(isize);
else if (HasParam(wxT("relativesize")))
sysfont.SetPointSize(int(sysfont.GetPointSize() *
font.SetPointSize(int(font.GetPointSize() *
GetFloat(wxT("relativesize"))));
if (hasStyle)
sysfont.SetStyle(istyle);
font.SetStyle(istyle);
if (hasWeight)
sysfont.SetWeight(iweight);
font.SetWeight(iweight);
if (hasUnderlined)
sysfont.SetUnderlined(underlined);
font.SetUnderlined(underlined);
if (hasFamily)
sysfont.SetFamily(ifamily);
font.SetFamily(ifamily);
if (hasFacename)
sysfont.SetFaceName(facename);
font.SetFaceName(facename);
if (hasEncoding)
sysfont.SetDefaultEncoding(enc);
m_node = oldnode;
return sysfont;
font.SetDefaultEncoding(enc);
}
else // not based on system font
{
font = wxFont(isize == -1 ? wxNORMAL_FONT->GetPointSize() : isize,
ifamily, istyle, iweight,
underlined, facename, enc);
}
m_node = oldnode;
return wxFont(isize, ifamily, istyle, iweight,
underlined, facename, enc);
return font;
}