-//-----------------------------------------------------------------------------
-// local utilities to find a X font
-//-----------------------------------------------------------------------------
-
-static GdkFont*wxLoadQueryFont( int pointSize, int family, int style, int weight,
- bool WXUNUSED(underlined), const wxString &facename )
-{
- 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) );
-}
-
-static GdkFont *wxLoadQueryNearestFont( int point_size, int family, int style, int weight,
- bool underlined, const wxString &facename )
-{
- GdkFont *font = wxLoadQueryFont( point_size, family, style, weight, underlined, facename );
-
- if (!font)
- {
- /* search up and down by stepsize 10 */
- int max_size = point_size + 20 * (1 + (point_size/180));
- int min_size = point_size - 20 * (1 + (point_size/180));
-
- int i;
-
- /* Search for smaller size (approx.) */
- for (i=point_size-10; !font && i >= 10 && i >= min_size; i -= 10)
- font = wxLoadQueryFont(i, family, style, weight, underlined, facename );
-
- /* Search for larger size (approx.) */
- for (i=point_size+10; !font && i <= max_size; i += 10)
- font = wxLoadQueryFont( i, family, style, weight, underlined, facename );
-
- /* Try default family */
- if (!font && family != wxDEFAULT)
- font = wxLoadQueryFont( point_size, wxDEFAULT, style, weight, underlined, facename );
-
- /* Bogus font */
- if (!font)
- font = wxLoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL, underlined, facename );
- }
-
- return font;
-}
-
-/*
-
-//-----------------------------------------------------------------------------
-// face names and index functions
-//-----------------------------------------------------------------------------
-
-static char *font_defaults[] = {
- "FamilyDefault", "Default",
- "FamilyRoman", "Roman",
- "FamilyDecorative", "Decorative",
- "FamilyModern", "Modern",
- "FamilyTeletype", "Teletype",
- "FamilySwiss", "Swiss",
- "FamilyScript", "Script",
-
- "AfmMedium", "",
- "AfmBold", "Bo",
- "AfmLight", "",
- "AfmStraight", "",
- "AfmItalic", "${AfmSlant}",
- "AfmSlant", "O",
- "AfmRoman", "Ro",
- "AfmTimes", "Times",
- "AfmHelvetica", "Helv",
- "AfmCourier", "Cour",
-
- "Afm___", "${AfmTimes,$[weight],$[style]}",
-
- "AfmTimes__", "${AfmTimes}${Afm$[weight]}${Afm$[style]}",
- "AfmTimesMediumStraight", "${AfmTimes}${AfmRoman}",
- "AfmTimesLightStraight", "${AfmTimes}${AfmRoman}",
- "AfmTimes_Italic", "${AfmTimes}$[weight]${AfmItalic}",
- "AfmTimes_Slant", "${AfmTimes}$[weight]${AfmItalic}",
-
- "AfmSwiss__", "${AfmHelvetica}${Afm$[weight]}${Afm$[style]}",
- "AfmModern__", "${AfmCourier}${Afm$[weight]}${Afm$[style]}",
-
- "AfmTeletype__", "${AfmModern,$[weight],$[style]}",
-
- "PostScriptMediumStraight", "",
- "PostScriptMediumItalic", "-Oblique",
- "PostScriptMediumSlant", "-Oblique",
- "PostScriptLightStraight", "",
- "PostScriptLightItalic", "-Oblique",
- "PostScriptLightSlant", "-Oblique",
- "PostScriptBoldStraight", "-Bold",
- "PostScriptBoldItalic", "-BoldOblique",
- "PostScriptBoldSlant", "-BoldOblique",
-
-#if WX_NORMALIZED_PS_FONTS
- "PostScript___", "${PostScriptTimes,$[weight],$[style]}",
-#else
- "PostScriptRoman__", "${PostScriptTimes,$[weight],$[style]}",
- "PostScript___", "LucidaSans${PostScript$[weight]$[style]}",
-#endif
-
- "PostScriptTimesMedium", "",
- "PostScriptTimesLight", "",
- "PostScriptTimesBold", "Bold",
-
- "PostScriptTimes__", "Times${PostScript$[weight]$[style]}",
- "PostScriptTimesMediumStraight", "Times-Roman",
- "PostScriptTimesLightStraight", "Times-Roman",
- "PostScriptTimes_Slant", "Times-${PostScriptTimes$[weight]}Italic",
- "PostScriptTimes_Italic", "Times-${PostScriptTimes$[weight]}Italic",
-
- "PostScriptSwiss__", "Helvetica${PostScript$[weight]$[style]}",
- "PostScriptModern__", "Courier${PostScript$[weight]$[style]}",
-
- "PostScriptTeletype__", "${PostScriptModern,$[weight],$[style]}",
-
-#if !WX_NORMALIZED_PS_FONTS
- "PostScriptScript__", "Zapf-Chancery-MediumItalic",
-#endif
-
- "ScreenMedium", "medium",
- "ScreenBold", "bold",
- "ScreenLight", "light",
- "ScreenStraight", "r",
- "ScreenItalic", "i",
- "ScreenSlant", "o",
-
- "ScreenDefaultBase", "*-times",
-
- "ScreenRomanBase", "*-times",
- "ScreenDecorativeBase", "*-helvetica",
- "ScreenModernBase", "*-courier",
- "ScreenTeletypeBase", "*-lucidatypewriter",
- "ScreenSwissBase", "*-lucida",
- "ScreenScriptBase", "*-zapfchancery",
-
- "ScreenStdSuffix", "-${Screen$[weight]}-${Screen$[style]}"
- "-normal-*-*-%d-*-*-*-*-*-*",
-
- "Screen___",
- "-${ScreenDefaultBase}${ScreenStdSuffix}",
- "ScreenRoman__",
- "-${ScreenRomanBase}${ScreenStdSuffix}",
- "ScreenDecorative__",
- "-${ScreenDecorativeBase}${ScreenStdSuffix}",
- "ScreenModern__",
- "-${ScreenModernBase}${ScreenStdSuffix}",
- "ScreenTeletype__",
- "-${ScreenTeletypeBase}${ScreenStdSuffix}",
- "ScreenSwiss__",
- "-${ScreenSwissBase}${ScreenStdSuffix}",
- "ScreenScript__",
- "-${ScreenScriptBase}${ScreenStdSuffix}",
- (char *) NULL
-};
-
-enum {wxWEIGHT_NORMAL, wxWEIGHT_BOLD, wxWEIGHT_LIGHT, wxNUM_WEIGHTS};
-enum {wxSTYLE_NORMAL, wxSTYLE_ITALIC, wxSTYLE_SLANT, wxNUM_STYLES};
-
-static int WCoordinate(int w)
-{
- switch (w)
- {
- case wxBOLD: return wxWEIGHT_BOLD;
- case wxLIGHT: return wxWEIGHT_LIGHT;
- case wxNORMAL:
- default: return wxWEIGHT_NORMAL;
- }
-};
-
-static int SCoordinate(int s)