X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8f7b34a878bbcb2f71a0c7694e2a3bec51460218..17271c793e0d938dc4a189b540b6438ce1839230:/src/mgl/fontutil.cpp?ds=sidebyside diff --git a/src/mgl/fontutil.cpp b/src/mgl/fontutil.cpp index 78d0443857..3fcbc396d8 100644 --- a/src/mgl/fontutil.cpp +++ b/src/mgl/fontutil.cpp @@ -21,16 +21,16 @@ #endif #ifndef WX_PRECOMP + #include "wx/log.h" + #include "wx/fontutil.h" + #include "wx/fontmap.h" + #include "wx/tokenzr.h" + #include "wx/hash.h" #endif // PCH -#include "wx/fontutil.h" -#include "wx/fontmap.h" -#include "wx/tokenzr.h" -#include "wx/hash.h" -#include "wx/module.h" #include "wx/listimpl.cpp" -#include "wx/log.h" +#include "wx/sysopt.h" #include "wx/mgl/private.h" #include @@ -229,6 +229,8 @@ void wxMGLFontLibrary::DecRef() } } +static int gs_antialiasingThreshold = -1; + wxMGLFontInstance *wxMGLFontLibrary::GetFontInstance(wxFont *font, float scale, bool aa) { @@ -236,10 +238,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)); @@ -323,20 +343,17 @@ bool wxMGLFontFamily::HasFace(int type) const wxMGLFontLibrary *wxFontsManager::GetFontLibrary(wxFont *font) { wxMGLFontFamily *family; - wxString facename; int type; + wxString facename = font->GetFaceName(); - if ( facename ) - family = GetFamily(font->GetFaceName()); + if ( !facename.IsEmpty() ) + family = GetFamily(facename); else family = NULL; - if ( family ) - facename = font->GetFaceName(); - else - facename.Empty(); - + if ( !family ) { + facename.Empty(); switch (font->GetFamily()) { case wxSCRIPT: @@ -433,24 +450,3 @@ wxMGLFontFamily *wxFontsManager::GetFamily(const wxString& name) const wxFontsManager *wxTheFontsManager = NULL; - - -// A module that takes care of fonts DB initialization and destruction: - -class wxFontutilModule: public wxModule -{ -DECLARE_DYNAMIC_CLASS(wxFontutilModule) -public: - wxFontutilModule() {} - bool OnInit() - { - wxTheFontsManager = new wxFontsManager; - return TRUE; - } - void OnExit() - { - delete wxTheFontsManager; - } -}; - -IMPLEMENT_DYNAMIC_CLASS(wxFontutilModule, wxModule)