+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(wxT("size"), 12);
+
+ wxString style = GetParamValue(wxT("style"));
+ wxString weight = GetParamValue(wxT("weight"));
+ int istyle = wxNORMAL, iweight = wxNORMAL;
+ if (style == wxT("italic")) istyle = wxITALIC;
+ else if (style == wxT("slant")) istyle = wxSLANT;
+ if (weight == wxT("bold")) iweight = wxBOLD;
+ else if (weight == wxT("light")) iweight = wxLIGHT;
+
+ wxString family = GetParamValue(wxT("family"));
+ int ifamily = wxDEFAULT;
+ if (family == wxT("decorative")) ifamily = wxDECORATIVE;
+ else if (family == wxT("roman")) ifamily = wxROMAN;
+ else if (family == wxT("script")) ifamily = wxSCRIPT;
+ else if (family == wxT("swiss")) ifamily = wxSWISS;
+ else if (family == wxT("modern")) ifamily = wxMODERN;
+
+ bool underlined = GetBool(wxT("underlined"), FALSE);
+
+ wxString encoding = GetParamValue(wxT("encoding"));
+ wxFontMapper mapper;
+ wxFontEncoding enc = wxFONTENCODING_DEFAULT;
+ if (!encoding.IsEmpty()) enc = mapper.CharsetToEncoding(encoding);
+ if (enc == wxFONTENCODING_SYSTEM) enc = wxFONTENCODING_SYSTEM;
+
+ wxString faces = GetParamValue(wxT("face"));
+ wxString facename = wxEmptyString;
+ wxFontEnumerator enu;
+ enu.EnumerateFacenames();
+ wxStringTokenizer tk(faces, wxT(","));
+ 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;
+}
+
+