Skip to content

Commit 52954e6

Browse files
committed
qt: fix broken unicode chars on osx 10.10
The default font changed again. The real fix is to compile qt against a >= 10.8 sdk, but this is simple enough to backport to 0.10 to avoid having to do that there. Note: NSAppKitVersionNumber is a double and there's no official value for NSAppKitVersionNumber10_10. Since == isn't reliable for doubles, use Apple's guidelines for testing versions here: https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKit/ Chinese and Japanese fonts have been hard-coded as well, otherwise they fail to show up at all.
1 parent f5ad78b commit 52954e6

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/qt/guiutil.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ static boost::filesystem::detail::utf8_codecvt_facet utf8;
6767

6868
#if defined(Q_OS_MAC)
6969
extern double NSAppKitVersionNumber;
70+
#if !defined(NSAppKitVersionNumber10_8)
71+
#define NSAppKitVersionNumber10_8 1187
72+
#endif
7073
#if !defined(NSAppKitVersionNumber10_9)
7174
#define NSAppKitVersionNumber10_9 1265
7275
#endif
@@ -393,12 +396,28 @@ void SubstituteFonts(const QString& language)
393396
// If this fallback is not properly loaded, some characters may fail to
394397
// render correctly.
395398
//
399+
// The same thing happened with 10.10. .Helvetica Neue DeskInterface is now default.
400+
//
396401
// Solution: If building with the 10.7 SDK or lower and the user's platform
397402
// is 10.9 or higher at runtime, substitute the correct font. This needs to
398403
// happen before the QApplication is created.
399404
#if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8
400-
if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_9)
401-
QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
405+
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_8)
406+
{
407+
if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_9)
408+
/* On a 10.9 - 10.9.x system */
409+
QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
410+
else
411+
{
412+
/* 10.10 or later system */
413+
if (language == "zh_CN" || language == "zh_TW" || language == "zh_HK") // traditional or simplified Chinese
414+
QFont::insertSubstitution(".Helvetica Neue DeskInterface", "Heiti SC");
415+
else if (language == "ja") // Japanesee
416+
QFont::insertSubstitution(".Helvetica Neue DeskInterface", "Songti SC");
417+
else
418+
QFont::insertSubstitution(".Helvetica Neue DeskInterface", "Lucida Grande");
419+
}
420+
}
402421
#endif
403422
#endif
404423
}

0 commit comments

Comments
 (0)