- 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;
- wxString facename;
- int type;
-
- if ( facename )
- family = GetFamily(font->GetFaceName());
- else
- family = NULL;
- if ( family )
- facename = font->GetFaceName();
- else
- facename.Empty();
-
- if ( !family )
- {
- 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;
-}
-
-wxFontsManager::wxFontsManager()
-{
- m_hash = new wxHashTable(wxKEY_STRING);
- m_hash->DeleteContents(FALSE);
- m_list = new wxMGLFontFamilyList;
- m_list->DeleteContents(TRUE);
- MGL_enumerateFonts(enum_callback, (void*)this);
-}
-
-wxFontsManager::~wxFontsManager()
-{
- delete m_hash;
- delete m_list;
-}
-
-void wxFontsManager::AddFamily(const font_info_t *info)
-{
- wxMGLFontFamily *f = new wxMGLFontFamily(info);
- m_hash->Put(f->GetName().Lower(), f);
- m_list->Append(f);