Attachment "89354dae31.diff" to
ticket [89354dae]
added by
chrstphrchvz
2020-04-13 19:57:49.
diff --git macosx/tkMacOSXFont.c macosx/tkMacOSXFont.c
index c3b0b667d..e19e757f8 100644
--- macosx/tkMacOSXFont.c
+++ macosx/tkMacOSXFont.c
@@ -1271,8 +1271,35 @@ DrawCharsInContext(
[nsFont setInContext:[NSGraphicsContext graphicsContextWithGraphicsPort:
context flipped:NO]];
CGContextSetTextMatrix(context, CGAffineTransformIdentity);
- attributedString = [[NSAttributedString alloc] initWithString:string
- attributes:attributes];
+ start = Tcl_NumUtfChars(source, rangeStart);
+ len = Tcl_NumUtfChars(source, rangeStart + rangeLength);
+ if (start > 0) {
+ /*
+ * Fix for 89354dae31:
+ * Prevent the current foreground from being applied to edge of
+ * text prior to start by setting transparent foreground for text
+ * prior to start, since startBounds might not perfectly cover glyphs
+ * prior to start (leaving behind 1-pixel-wide artifacts).
+ */
+ NSMutableAttributedString *mutableAttributedString =
+ [[NSMutableAttributedString alloc]
+ initWithString:string
+ attributes:attributes];
+ fg = TkMacOSXCreateCGColor(gc, TRANSPARENT_PIXEL << 24);
+ [mutableAttributedString beginEditing];
+ [mutableAttributedString
+ addAttribute:(id)kCTForegroundColorAttributeName
+ value:(id)fg
+ range:NSMakeRange(0, start)];
+ CFRelease(fg);
+ [mutableAttributedString endEditing];
+ attributedString = [mutableAttributedString copy];
+ [mutableAttributedString release];
+ } else {
+ attributedString = [[NSAttributedString alloc]
+ initWithString:string
+ attributes:attributes];
+ }
typesetter = CTTypesetterCreateWithAttributedString(
(CFAttributedStringRef)attributedString);
x += macWin->xOff;
@@ -1286,8 +1313,6 @@ DrawCharsInContext(
}
CGContextConcatCTM(context, t);
CGContextSetTextPosition(context, x, y);
- start = Tcl_NumUtfChars(source, rangeStart);
- len = Tcl_NumUtfChars(source, rangeStart + rangeLength);
if (start > 0) {
CGRect clipRect = CGRectInfinite, startBounds;