-}
-
-void wxMGLFontLibrary::DecRef()
-{
- wxLogTrace("mgl_font", "decRef(%u) '%s'", m_refs, m_fileName.c_str());
- if ( --m_refs == 0 )
- {
- wxLogTrace("mgl_font", "killing instances of '%s'", m_fileName.mb_str());
- m_instances->Clear();
- wxLogTrace("mgl_font", "closing library '%s'", m_fileName.mb_str());
- MGL_closeFontLib(m_fontLib);
- m_fontLib = NULL;
- }
-}
-
-static int gs_antialiasingThreshold = -1;
-
-wxMGLFontInstance *wxMGLFontLibrary::GetFontInstance(wxFont *font,
- float scale, bool aa)
-{
- wxASSERT_MSG(m_refs > 0 && m_fontLib, wxT("font library not loaded!"));
-
- wxString facename;
- float pt = (float)font->GetPointSize() * scale;
-
- if ( gs_antialiasingThreshold == -1 )
- {
- gs_antialiasingThreshold = 10;
-#if wxUSE_SYSTEM_OPTIONS
- if ( wxSystemOptions::HasOption(wxT("mgl.aa-threshold")) )
- gs_antialiasingThreshold =
- wxSystemOptions::GetOptionInt(wxT("mgl.aa-threshold"));
- wxLogTrace("mgl_font", "AA threshold set to %i", gs_antialiasingThreshold);
-#endif
- }
-
- // Small characters don't look good when antialiased with the algorithm
- // that FreeType uses (mere 2x2 supersampling), so lets disable it AA
- // completely for small fonts.
- bool antialiased = false;
- if (( pt > gs_antialiasingThreshold ) &&
- ( m_fontLib->fontLibType != MGL_BITMAPFONT_LIB ) )
- antialiased = aa;
-
- bool slant = (((m_type & wxFONTFACE_ITALIC) == 0) &&
- (font->GetStyle() == wxSLANT || font->GetStyle() == wxITALIC));
-
- // FIXME_MGL -- MGL does not yet support slant, although the API is there
- slant = false;
-
- wxLogTrace("mgl_font", "requested instance of '%s' slant=%i pt=%0.1f aa=%i",
- m_fileName.mb_str(), slant, pt, antialiased);
-
- wxMGLFontInstance *i;
- wxMGLFontInstanceList::Node *node;
-
- for (node = m_instances->GetFirst(); node; node = node->GetNext())
- {
- i = node->GetData();
- if ( i->GetPt() == pt && i->GetSlant() == slant &&
- i->GetAA() == antialiased )
- {
- wxLogTrace("mgl_font", " got from cache: slant=%i pt=%0.1f aa=%i",
- i->GetSlant(), i->GetPt(), i->GetAA());
- return i;
- }
- }
-
- i = new wxMGLFontInstance(this, pt, slant, antialiased);
- m_instances->Append(i);
- return i;
-}
-
-
-wxMGLFontFamily::wxMGLFontFamily(const font_info_t *info)
-{
- m_name = info->familyName;
- m_fontInfo = info;
-
- if ( info->regularFace[0] == '\0' )
- m_fontLibs[wxFONTFACE_REGULAR] = NULL;
- else
- m_fontLibs[wxFONTFACE_REGULAR] =
- new wxMGLFontLibrary(info->regularFace, wxFONTFACE_REGULAR, this);
-
- if ( info->italicFace[0] == '\0' )
- m_fontLibs[wxFONTFACE_ITALIC] = NULL;
- else
- m_fontLibs[wxFONTFACE_ITALIC] =
- new wxMGLFontLibrary(info->italicFace, wxFONTFACE_ITALIC, this);
-
- if ( info->boldFace[0] == '\0' )
- m_fontLibs[wxFONTFACE_BOLD] = NULL;
- else
- m_fontLibs[wxFONTFACE_BOLD] =
- new wxMGLFontLibrary(info->boldFace, wxFONTFACE_BOLD, this);
-
- if ( info->boldItalicFace[0] == '\0' )
- m_fontLibs[wxFONTFACE_BOLD_ITALIC] = NULL;
- else
- m_fontLibs[wxFONTFACE_BOLD_ITALIC] =
- new wxMGLFontLibrary(info->boldItalicFace, wxFONTFACE_BOLD_ITALIC, this);
-
- 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.empty() )
- family = GetFamily(facename);