-}
-
-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;