X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d7ae4a62645d369fbd6b8b5f3f0e12ee86536da1..23318a5358be74727fb62854f623da84a4545bcd:/src/common/fontmgrcmn.cpp diff --git a/src/common/fontmgrcmn.cpp b/src/common/fontmgrcmn.cpp index 6a5d0683ec..7d7ef9d35d 100644 --- a/src/common/fontmgrcmn.cpp +++ b/src/common/fontmgrcmn.cpp @@ -24,9 +24,15 @@ WX_DECLARE_LIST(wxFontInstance, wxFontInstanceList); WX_DEFINE_LIST(wxFontInstanceList) WX_DEFINE_LIST(wxFontBundleList) + WX_DECLARE_HASH_MAP(wxString, wxFontBundle*, wxStringHash, wxStringEqual, - wxFontBundleHash); + wxFontBundleHashBase); +// in STL build, hash class is typedef to a template, so it can't be forward +// declared, as we do; solve it by having a dummy class: +class wxFontBundleHash : public wxFontBundleHashBase +{ +}; // ============================================================================ // implementation @@ -65,17 +71,14 @@ wxFontInstance *wxFontFaceBase::GetFontInstance(float ptSize, bool aa) { wxASSERT_MSG( m_refCnt > 0, _T("font library not loaded!") ); - wxFontInstance *i; - wxFontInstanceList::Node *node; - - for ( node = m_instances->GetFirst(); node; node = node->GetNext() ) + for ( wxFontInstanceList::const_iterator i = m_instances->begin(); + i != m_instances->end(); ++i ) { - i = node->GetData(); - if ( i->GetPointSize() == ptSize && i->IsAntiAliased() == aa ) - return i; + if ( (*i)->GetPointSize() == ptSize && (*i)->IsAntiAliased() == aa ) + return *i; } - i = CreateFontInstance(ptSize, aa); + wxFontInstance *i = CreateFontInstance(ptSize, aa); m_instances->Append(i); return i; } @@ -110,7 +113,8 @@ wxFontFace *wxFontBundleBase::GetFace(FaceType type) const wxFontFace * wxFontBundleBase::GetFaceForFont(const wxFontMgrFontRefData& font) const { - wxASSERT_MSG( font.GetFaceName().empty() || font.GetFaceName() == GetName(), + wxASSERT_MSG( font.GetFaceName().empty() || + GetName().CmpNoCase(font.GetFaceName()) == 0, _T("calling GetFaceForFont for incompatible font") ); int type = FaceType_Regular; @@ -129,6 +133,8 @@ wxFontBundleBase::GetFaceForFont(const wxFontMgrFontRefData& font) const if ( !HasFace((FaceType)type) ) { + // if we can't get the exact font requested, substitute it with + // some other variant: for (int i = 0; i < FaceType_Max; i++) { if ( HasFace((FaceType)i) )