- char buffer[512];
- char *name = wxTheFontNameDirectory->GetScreenName( fontid, weight, style );
-
- if (!name)
- name = "-*-*-*-*-*-*-*-%d-*-*-*-*-*-*";
- sprintf(buffer, name, point_size);
-
- return gdk_font_load( buffer );
+ wxChar *xfamily = (wxChar*) NULL;
+ wxChar *xstyle = (wxChar*) NULL;
+ wxChar *xweight = (wxChar*) NULL;
+
+ switch (family)
+ {
+ case wxDECORATIVE: xfamily = _T("lucida"); break;
+ case wxROMAN: xfamily = _T("times"); break;
+ case wxMODERN: xfamily = _T("courier"); break;
+ case wxSWISS: xfamily = _T("helvetica"); break;
+ case wxTELETYPE: xfamily = _T("lucidatypewriter"); break;
+ case wxSCRIPT: xfamily = _T("utopia"); break;
+ default: xfamily = _T("*");
+ }
+
+ if (!facename.IsEmpty())
+ {
+ wxSprintf( wxBuffer, _T("-*-%s-*-*-normal-*-*-*-*-*-*-*-*-*"), facename.c_str() );
+ GdkFont *test = gdk_font_load( wxConvCurrent->cWX2MB(wxBuffer) );
+ if (test)
+ {
+ gdk_font_unref( test );
+ xfamily = WXSTRINGCAST facename;
+ }
+ }
+
+ switch (style)
+ {
+ case wxITALIC: xstyle = _T("i"); break;
+ case wxSLANT: xstyle = _T("o"); break;
+ case wxNORMAL: xstyle = _T("r"); break;
+ default: xstyle = _T("*"); break;
+ }
+ switch (weight)
+ {
+ case wxBOLD: xweight = _T("bold"); break;
+ case wxLIGHT:
+ case wxNORMAL: xweight = _T("medium"); break;
+ default: xweight = _T("*"); break;
+ }
+
+ wxSprintf( wxBuffer, _T("-*-%s-%s-%s-normal-*-*-%d-*-*-*-*-*-*"),
+ xfamily, xweight, xstyle, pointSize);
+
+ return gdk_font_load( wxConvCurrent->cWX2MB(wxBuffer) );