Fix NSFont bridging crash with Asian input methods on 10.11

There's a bug in OS X 10.11 where a toll-free bridged font may have an
attributed of private class __NSCFCharacterSet that unlike
NSCharacterSet doesn't conform to NSSecureCoding. This poses a problem
when such font is used in user-editable content, because some Asian
input methods then crash in 10.11 when editing the string. As a
workaround for this bug, don't use toll-free bridging, but re-create
NSFont from the descriptor instead on buggy OS X versions.

Fixes regression introduced in a77066d530
(#507).
This commit is contained in:
Václav Slavík
2017-11-10 18:23:03 +01:00
committed by Václav Slavík
parent af16d8ba5c
commit 926d486f54
2 changed files with 42 additions and 29 deletions

View File

@@ -680,35 +680,6 @@ CGFontRef wxFont::OSXGetCGFont() const
#endif
#if wxOSX_USE_COCOA
NSFont* wxFont::OSXGetNSFont() const
{
wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
// cast away constness otherwise lazy font resolution is not possible
const_cast<wxFont *>(this)->RealizeResource();
return const_cast<NSFont*>(reinterpret_cast<const NSFont*>(OSXGetCTFont()));
}
#endif
#if wxOSX_USE_IPHONE
UIFont* wxFont::OSXGetUIFont() const
{
wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
// cast away constness otherwise lazy font resolution is not possible
const_cast<wxFont *>(this)->RealizeResource();
return const_cast<UIFont*>(reinterpret_cast<const UIFont*>(OSXGetCTFont()));
}
#endif
const wxNativeFontInfo * wxFont::GetNativeFontInfo() const
{
wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );