summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorculler <culler>2019-11-17 17:31:32 (GMT)
committerculler <culler>2019-11-17 17:31:32 (GMT)
commit31e614ca16b2ba0cd71b928754679adecc80be80 (patch)
tree321af4cfbd554a787dc590566b18bd572c1c3929
parent5bc76fef182c52a50e34b7f95c43f194ea8711fe (diff)
parentcdca750ab797e44fcabca5f2c4f4f61b5a8db6a6 (diff)
downloadtk-31e614ca16b2ba0cd71b928754679adecc80be80.zip
tk-31e614ca16b2ba0cd71b928754679adecc80be80.tar.gz
tk-31e614ca16b2ba0cd71b928754679adecc80be80.tar.bz2
Fix [90d555e088]: work around an Apple bug which causes NSFontManager to find fonts with unwanted traits in macOS Catalina.
-rw-r--r--macosx/tkMacOSXFont.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c
index 5f3ea54..df7f770 100644
--- a/macosx/tkMacOSXFont.c
+++ b/macosx/tkMacOSXFont.c
@@ -176,6 +176,18 @@ FindNSFont(
size = [defaultFont pointSize];
}
nsFont = [fm fontWithFamily:family traits:traits weight:weight size:size];
+
+ /*
+ * A second bug in NSFontManager that Apple created for the Catalina OS
+ * causes requests as above to sometimes return fonts with additional
+ * traits that were not requested, even though fonts without those unwanted
+ * traits exist on the system. See bug [90d555e088]. As a workaround
+ * we ask the font manager to remove any unrequested traits.
+ */
+
+ if (nsFont) {
+ nsFont = [fm convertFont:nsFont toNotHaveTrait:~traits];
+ }
if (!nsFont) {
NSArray *availableFamilies = [fm availableFontFamilies];
NSString *caseFamily = nil;
@@ -395,12 +407,15 @@ TkpFontPkgInit(
}
TkInitFontAttributes(&fa);
#if 0
+
/*
- * In macOS 10.15.1 Apple introduced a bug which caused the call below to
- * return a font with the invalid familyName ".SF NSMono" instead of the
- * valid familyName "NSMono". Calling [NSFont userFixedPitchFontOfSize:11]
- * returns a font in the "Menlo" family which has a valid familyName.
+ * In macOS 10.15.1 Apple introduced a bug in NSFontManager which caused
+ * it to not recognize the familyName ".SF NSMono" which is the familyName
+ * of the default fixed pitch system fault on that system. See bug [855049e799].
+ * As a workaround we call [NSFont userFixedPitchFontOfSize:11] instead.
+ * This returns a user font in the "Menlo" family.
*/
+
nsFont = (NSFont*) CTFontCreateUIFontForLanguage(fixedPitch, 11, NULL);
#else
nsFont = [NSFont userFixedPitchFontOfSize:11];