backport, get rid of performance warnings "For best performance, only use PostScript names when calling this API", see #15999
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@76396 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -155,6 +155,9 @@ public:
|
|||||||
void Free();
|
void Free();
|
||||||
void EnsureValid();
|
void EnsureValid();
|
||||||
|
|
||||||
|
static void UpdateNamesMap(const wxString& familyname, CTFontDescriptorRef descr);
|
||||||
|
static void UpdateNamesMap(const wxString& familyname, CTFontRef font);
|
||||||
|
|
||||||
bool m_descriptorValid;
|
bool m_descriptorValid;
|
||||||
|
|
||||||
#if wxOSX_USE_ATSU_TEXT
|
#if wxOSX_USE_ATSU_TEXT
|
||||||
|
@@ -199,6 +199,9 @@ wxFontRefData::wxFontRefData(const wxFontRefData& data) : wxGDIRefData()
|
|||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
|
wxStringToStringHashMap gs_FontFamilyToPSName;
|
||||||
|
static CTFontDescriptorRef wxMacCreateCTFontDescriptor(CFStringRef iFamilyName, CTFontSymbolicTraits iTraits );
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxFontRefData
|
// wxFontRefData
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -466,7 +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 )
|
||||||
{
|
{
|
||||||
m_ctFont.reset(CTFontCreateWithName( wxCFStringRef(m_info.m_faceName), m_info.m_pointSize , NULL ));
|
|
||||||
|
wxStringToStringHashMap::const_iterator it = gs_FontFamilyToPSName.find(m_info.m_faceName);
|
||||||
|
|
||||||
|
if ( it != gs_FontFamilyToPSName.end() )
|
||||||
|
{
|
||||||
|
m_ctFont.reset(CTFontCreateWithName( wxCFStringRef(it->second), m_info.m_pointSize , NULL ));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
if ( m_ctFont.get() == NULL )
|
if ( m_ctFont.get() == NULL )
|
||||||
{
|
{
|
||||||
// TODO try fallbacks according to font type
|
// TODO try fallbacks according to font type
|
||||||
@@ -501,7 +517,7 @@ void wxFontRefData::MacFindFont()
|
|||||||
|
|
||||||
if ( fontWithTraits == NULL )
|
if ( fontWithTraits == NULL )
|
||||||
{
|
{
|
||||||
fontWithTraits = CTFontCreateWithName( wxCFStringRef(m_info.m_faceName), m_info.m_pointSize, remainingTransform );
|
fontWithTraits = CTFontCreateCopyWithAttributes( m_ctFont, m_info.m_pointSize, remainingTransform, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -902,8 +918,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 )
|
||||||
@@ -958,7 +972,6 @@ static CTFontDescriptorRef wxMacCreateCTFontDescriptor(CFStringRef iFamilyName,
|
|||||||
return descriptor ;
|
return descriptor ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void wxNativeFontInfo::Init()
|
void wxNativeFontInfo::Init()
|
||||||
{
|
{
|
||||||
@@ -1002,6 +1015,8 @@ void wxNativeFontInfo::Init(CTFontDescriptorRef descr)
|
|||||||
|
|
||||||
wxCFStringRef familyName( (CFStringRef) CTFontDescriptorCopyAttribute(descr, kCTFontFamilyNameAttribute));
|
wxCFStringRef familyName( (CFStringRef) CTFontDescriptorCopyAttribute(descr, kCTFontFamilyNameAttribute));
|
||||||
m_faceName = familyName.AsString();
|
m_faceName = familyName.AsString();
|
||||||
|
|
||||||
|
UpdateNamesMap(m_faceName, descr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNativeFontInfo::EnsureValid()
|
void wxNativeFontInfo::EnsureValid()
|
||||||
|
Reference in New Issue
Block a user