+wxFont wxXmlResourceHandler::GetFont(const wxString& param)
+{
+ wxXmlNode *font_node = GetParamNode(param);
+ if (font_node == NULL)
+ {
+ wxLogError(_("Cannot find font node '%s'."), param.mb_str());
+ return wxNullFont;
+ }
+
+ wxXmlNode *oldnode = m_Node;
+ m_Node = font_node;
+
+ long size = GetLong(_T("size"), 12);
+
+ wxString style = GetParamValue(_T("style"));
+ wxString weight = GetParamValue(_T("weight"));
+ int istyle = wxNORMAL, iweight = wxNORMAL;
+ if (style == _T("italic")) istyle = wxITALIC;
+ else if (style == _T("slant")) istyle = wxSLANT;
+ if (weight == _T("bold")) iweight = wxBOLD;
+ else if (weight == _T("light")) iweight = wxLIGHT;
+
+ wxString family = GetParamValue(_T("family"));
+ int ifamily = wxDEFAULT;
+ if (family == _T("decorative")) ifamily = wxDECORATIVE;
+ else if (family == _T("roman")) ifamily = wxROMAN;
+ else if (family == _T("script")) ifamily = wxSCRIPT;
+ else if (family == _T("swiss")) ifamily = wxSWISS;
+ else if (family == _T("modern")) ifamily = wxMODERN;
+
+ bool underlined = GetBool(_T("underlined"), FALSE);
+
+ wxString encoding = GetParamValue(_T("encoding"));
+ wxFontMapper mapper;
+ wxFontEncoding enc = wxFONTENCODING_DEFAULT;
+ if (!encoding.IsEmpty()) enc = mapper.CharsetToEncoding(encoding);
+ if (enc == wxFONTENCODING_SYSTEM) enc = wxFONTENCODING_SYSTEM;
+
+ wxString faces = GetParamValue(_T("face"));
+ wxString facename = wxEmptyString;
+ wxFontEnumerator enu;
+ enu.EnumerateFacenames();
+ wxStringTokenizer tk(faces, _T(","));
+ while (tk.HasMoreTokens())
+ {
+ int index = enu.GetFacenames()->Index(tk.GetNextToken(), FALSE);
+ if (index != wxNOT_FOUND)
+ {
+ facename = (*enu.GetFacenames())[index];
+ break;
+ }
+ }
+
+ m_Node = oldnode;
+
+ wxFont font(size, ifamily, istyle, iweight, underlined, facename, enc);
+ return font;
+}
+
+