in order to get rid of the warnings completely use the former font descriptor creation sequence and cache the result immediately, fixes #15999

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76393 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2014-04-23 13:40:18 +00:00
parent 60578d63f4
commit 4360902f4e

View File

@@ -200,6 +200,7 @@ wxFontRefData::wxFontRefData(const wxFontRefData& data) : wxGDIRefData()
// ============================================================================ // ============================================================================
wxStringToStringHashMap gs_FontFamilyToPSName; wxStringToStringHashMap gs_FontFamilyToPSName;
static CTFontDescriptorRef wxMacCreateCTFontDescriptor(CFStringRef iFamilyName, CTFontSymbolicTraits iTraits );
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxFontRefData // wxFontRefData
@@ -468,16 +469,20 @@ void wxFontRefData::MacFindFont()
m_ctFont = fontcache[ std::wstring(lookupnameWithSize.wc_str()) ]; m_ctFont = fontcache[ std::wstring(lookupnameWithSize.wc_str()) ];
if ( !m_ctFont ) if ( !m_ctFont )
{ {
wxCFStringRef fontname(m_info.m_faceName);
wxStringToStringHashMap::const_iterator it = gs_FontFamilyToPSName.find(m_info.m_faceName); wxStringToStringHashMap::const_iterator it = gs_FontFamilyToPSName.find(m_info.m_faceName);
if ( it != gs_FontFamilyToPSName.end() ) if ( it != gs_FontFamilyToPSName.end() )
fontname = it->second; {
m_ctFont.reset(CTFontCreateWithName( wxCFStringRef(it->second), m_info.m_pointSize , NULL ));
}
else else
fontname = m_info.m_faceName; {
wxCFRef<CTFontDescriptorRef> desc(wxMacCreateCTFontDescriptor(wxCFStringRef(m_info.m_faceName),0));
m_ctFont.reset(CTFontCreateWithFontDescriptor(desc, m_info.m_pointSize , NULL ));
m_info.UpdateNamesMap(m_info.m_faceName, m_ctFont);
}
m_ctFont.reset(CTFontCreateWithName( fontname, m_info.m_pointSize , NULL ));
if ( m_ctFont.get() == NULL ) if ( m_ctFont.get() == NULL )
{ {
// TODO try fallbacks according to font type // TODO try fallbacks according to font type
@@ -485,10 +490,6 @@ void wxFontRefData::MacFindFont()
} }
else else
{ {
if ( it == gs_FontFamilyToPSName.end() )
{
m_info.UpdateNamesMap(m_info.m_faceName, m_ctFont);
}
if ( traits != 0 ) if ( traits != 0 )
{ {
// attempt native font variant, if not available, fallback to italic emulation mode and remove bold // attempt native font variant, if not available, fallback to italic emulation mode and remove bold
@@ -516,7 +517,7 @@ void wxFontRefData::MacFindFont()
if ( fontWithTraits == NULL ) if ( fontWithTraits == NULL )
{ {
fontWithTraits = CTFontCreateWithName( fontname, m_info.m_pointSize, remainingTransform ); fontWithTraits = CTFontCreateCopyWithAttributes( m_ctFont, m_info.m_pointSize, remainingTransform, NULL );
} }
} }
@@ -929,8 +930,6 @@ const wxNativeFontInfo * wxFont::GetNativeFontInfo() const
// wxNativeFontInfo // wxNativeFontInfo
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if 0 // wxOSX_USE_CORE_TEXT
/* from Core Text Manual Common Operations */ /* from Core Text Manual Common Operations */
static CTFontDescriptorRef wxMacCreateCTFontDescriptor(CFStringRef iFamilyName, CTFontSymbolicTraits iTraits ) static CTFontDescriptorRef wxMacCreateCTFontDescriptor(CFStringRef iFamilyName, CTFontSymbolicTraits iTraits )
@@ -985,7 +984,6 @@ static CTFontDescriptorRef wxMacCreateCTFontDescriptor(CFStringRef iFamilyName,
return descriptor ; return descriptor ;
} }
#endif
void wxNativeFontInfo::Init() void wxNativeFontInfo::Init()
{ {