- m_fontLibs[wxFONTFACE_ITALIC] =
- new wxMGLFontLibrary(info->italicFace, wxFONTFACE_ITALIC);
-
- if ( info->boldFace[0] == '\0' )
- m_fontLibs[wxFONTFACE_BOLD] = NULL;
- else
- m_fontLibs[wxFONTFACE_BOLD] =
- new wxMGLFontLibrary(info->boldFace, wxFONTFACE_BOLD);
-
- if ( info->boldItalicFace[0] == '\0' )
- m_fontLibs[wxFONTFACE_BOLD_ITALIC] = NULL;
- else
- m_fontLibs[wxFONTFACE_BOLD_ITALIC] =
- new wxMGLFontLibrary(info->boldItalicFace, wxFONTFACE_BOLD_ITALIC);
-
- wxLogTrace("mgl_font", "new family '%s' (r=%s, i=%s, b=%s, bi=%s)\n",
- info->familyName, info->regularFace, info->italicFace,
- info->boldFace, info->boldItalicFace);
-}
-
-wxMGLFontFamily::~wxMGLFontFamily()
-{
- for (size_t i = 0; i < wxFONTFACE_MAX; i++)
- delete m_fontLibs[i];
-}
-
-bool wxMGLFontFamily::HasFace(int type) const
-{
- return (m_fontLibs[type] != NULL);
-}
-
-
-// ----------------------------------------------------------------------------
-// wxFontsManager
-// ----------------------------------------------------------------------------
-
-wxMGLFontLibrary *wxFontsManager::GetFontLibrary(wxFont *font)
-{
- wxMGLFontFamily *family;
- int type;
- wxString facename = font->GetFaceName();
-
- if ( !facename.IsEmpty() )
- family = GetFamily(facename);
- else
- family = NULL;
-
- if ( !family )
- {
- facename.Empty();
- switch (font->GetFamily())
- {
- case wxSCRIPT:
- facename = wxT("Script");
- break;
- case wxDECORATIVE:
- facename = wxT("Charter");
- break;
- case wxROMAN:
- facename = wxT("Times");
- break;
- case wxTELETYPE:
- case wxMODERN:
- facename = wxT("Courier");
- break;
- case wxSWISS:
- facename = wxT("Helvetica");
- break;
- case wxDEFAULT:
- default:
- facename = wxT("Helvetica");
- break;
- }
-
- family = GetFamily(facename);
- if ( !family )
- {
- if ( m_list->GetFirst() )
- family = m_list->GetFirst()->GetData();
- else
- wxFAIL_MSG(wxT("Fatal error, no fonts available!"));
- }
- }
-
- type = wxFONTFACE_REGULAR;
-
- if ( font->GetWeight() == wxBOLD )
- type |= wxFONTFACE_BOLD;
-
- // FIXME_MGL -- this should read "if ( font->GetStyle() == wxITALIC )",
- // but since MGL does not yet support slant, we try to display it with
- // italic face (better than nothing...)
- if ( font->GetStyle() == wxITALIC || font->GetStyle() == wxSLANT )
- {
- if ( family->HasFace(type | wxFONTFACE_ITALIC) )
- type |= wxFONTFACE_ITALIC;
- }
- if ( !family->HasFace(type) )
- {
- for (int i = 0; i < wxFONTFACE_MAX; i++)
- if ( family->HasFace(i) )
- {
- type = i;
- break;
- }
- }
-
- return family->GetLibrary(type);
-}
-
-static ibool enum_callback(const font_info_t *info, void *cookie)
-{
- wxFontsManager *db = (wxFontsManager*)cookie;
- db->AddFamily(info);
- return TRUE;