summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorculler <culler>2019-11-04 16:23:49 (GMT)
committerculler <culler>2019-11-04 16:23:49 (GMT)
commit88207e0a1c915abc93fe6ee004db7f447b0731c5 (patch)
treebae8ebcbbcdbef1c10ba1dc5ecec06a6c2d16a9b
parent9e8b3fb6cf87185b0d226e01a4d7540aa2bdee5f (diff)
parent36766607d76fdb1ffc103c4f6e0f0527a7e840bd (diff)
downloadtk-88207e0a1c915abc93fe6ee004db7f447b0731c5.zip
tk-88207e0a1c915abc93fe6ee004db7f447b0731c5.tar.gz
tk-88207e0a1c915abc93fe6ee004db7f447b0731c5.tar.bz2
Merge 8.6
-rw-r--r--macosx/tkMacOSXDraw.c23
-rw-r--r--macosx/tkMacOSXFont.c14
2 files changed, 30 insertions, 7 deletions
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c
index 314ca35..5714bf4 100644
--- a/macosx/tkMacOSXDraw.c
+++ b/macosx/tkMacOSXDraw.c
@@ -1632,16 +1632,27 @@ TkMacOSXSetupDrawingContext(
* a view's drawRect or setFrame methods. The isDrawing attribute
* tells us whether we are being called from one of those methods.
*
- * If the CGContext is not valid, or belongs to a different View, then
- * we mark our view as needing display and return failure. It should
- * get drawn in a later call to drawRect.
+ * If the CGContext is not valid then we mark our view as needing
+ * display in the bounding rectangle of the clipping region and
+ * return failure. That rectangle should get drawn in a later call
+ * to drawRect.
*/
-
- if (view != [NSView focusView]) {
- [view setNeedsDisplay:YES];
+
+ if (![NSApp isDrawing] || view != [NSView focusView]) {
+ NSRect bounds = [view bounds];
+ NSRect dirtyNS = bounds;
+ CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0,
+ .ty = dirtyNS.size.height};
+ if (dc.clipRgn) {
+ CGRect dirtyCG = NSRectToCGRect(dirtyNS);
+ HIShapeGetBounds(dc.clipRgn, &dirtyCG);
+ dirtyNS = NSRectToCGRect(CGRectApplyAffineTransform(dirtyCG, t));
+ }
+ [view setNeedsDisplayInRect:dirtyNS];
canDraw = false;
goto end;
}
+
dc.view = view;
dc.context = GET_CGCONTEXT;
dc.portBounds = NSRectToCGRect([view bounds]);
diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c
index e68b09f..d6429ed 100644
--- a/macosx/tkMacOSXFont.c
+++ b/macosx/tkMacOSXFont.c
@@ -128,11 +128,11 @@ GetTkFontAttributesForNSFont(
{
NSFontTraitMask traits = [[NSFontManager sharedFontManager]
traitsOfFont:nsFont];
-
faPtr->family = Tk_GetUid([[nsFont familyName] UTF8String]);
faPtr->size = [nsFont pointSize];
faPtr->weight = (traits & NSBoldFontMask ? TK_FW_BOLD : TK_FW_NORMAL);
faPtr->slant = (traits & NSItalicFontMask ? TK_FS_ITALIC : TK_FS_ROMAN);
+
}
/*
@@ -394,10 +394,22 @@ TkpFontPkgInit(
systemFont++;
}
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.
+ */
nsFont = (NSFont*) CTFontCreateUIFontForLanguage(fixedPitch, 11, NULL);
+#else
+ nsFont = [NSFont userFixedPitchFontOfSize:11];
+#endif
if (nsFont) {
GetTkFontAttributesForNSFont(nsFont, &fa);
+#if 0
CFRelease(nsFont);
+#endif
} else {
fa.family = Tk_GetUid("Monaco");
fa.size = 11;