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