X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ef344ff86223f1f0961f025c0b249c898529c095..e7300ec6d9ebbd1cfa2fcf12c0ce6e5aee85a152:/src/mgl/fontutil.cpp diff --git a/src/mgl/fontutil.cpp b/src/mgl/fontutil.cpp index 7e26290862..f73a6fb862 100644 --- a/src/mgl/fontutil.cpp +++ b/src/mgl/fontutil.cpp @@ -4,7 +4,7 @@ // Author: Vaclav Slavik // Created: 2001/04/29 // RCS-ID: $Id$ -// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com) +// Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com) // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// @@ -30,6 +30,7 @@ #include "wx/listimpl.cpp" +#include "wx/sysopt.h" #include "wx/mgl/private.h" #include @@ -188,8 +189,10 @@ wxMGLFontInstance::~wxMGLFontInstance() MGL_unloadFontInstance(m_font); } -wxMGLFontLibrary::wxMGLFontLibrary(const wxString& filename, int type) +wxMGLFontLibrary::wxMGLFontLibrary(const wxString& filename, int type, + wxMGLFontFamily *parentFamily) { + m_family = parentFamily; m_type = type; m_fileName = filename; m_refs = 0; @@ -228,6 +231,8 @@ void wxMGLFontLibrary::DecRef() } } +static int gs_antialiasingThreshold = -1; + wxMGLFontInstance *wxMGLFontLibrary::GetFontInstance(wxFont *font, float scale, bool aa) { @@ -235,10 +240,28 @@ wxMGLFontInstance *wxMGLFontLibrary::GetFontInstance(wxFont *font, wxString facename; bool slant; - bool antialiased = - (m_fontLib->fontLibType == MGL_BITMAPFONT_LIB) ? FALSE : aa; + bool antialiased; 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. + if ( pt <= gs_antialiasingThreshold ) + antialiased = FALSE; + else + antialiased = (m_fontLib->fontLibType == MGL_BITMAPFONT_LIB) ? FALSE : aa; + slant = (((m_type & wxFONTFACE_ITALIC) == 0) && (font->GetStyle() == wxSLANT || font->GetStyle() == wxITALIC)); @@ -278,25 +301,25 @@ wxMGLFontFamily::wxMGLFontFamily(const font_info_t *info) m_fontLibs[wxFONTFACE_REGULAR] = NULL; else m_fontLibs[wxFONTFACE_REGULAR] = - new wxMGLFontLibrary(info->regularFace, 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); + 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); + 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); + 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, @@ -393,7 +416,7 @@ wxMGLFontLibrary *wxFontsManager::GetFontLibrary(wxFont *font) return family->GetLibrary(type); } -static ibool enum_callback(const font_info_t *info, void *cookie) +static ibool MGLAPI enum_callback(const font_info_t *info, void *cookie) { wxFontsManager *db = (wxFontsManager*)cookie; db->AddFamily(info);