Skip to content

Commit 63dcea1

Browse files
Update Gutter Drawing Code (#234)
1 parent 5e83a75 commit 63dcea1

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

Sources/CodeEditSourceEditor/Gutter/GutterView.swift

+13-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import AppKit
99
import CodeEditTextView
10+
import CodeEditTextViewObjC
1011

1112
public protocol GutterViewDelegate: AnyObject {
1213
func gutterViewWidthDidUpdate(newWidth: CGFloat)
@@ -55,10 +56,6 @@ public class GutterView: NSView {
5556
true
5657
}
5758

58-
override public var wantsDefaultClipping: Bool {
59-
false
60-
}
61-
6259
public init(
6360
font: NSFont,
6461
textColor: NSColor,
@@ -71,11 +68,11 @@ public class GutterView: NSView {
7168
self.delegate = delegate
7269

7370
super.init(frame: .zero)
74-
clipsToBounds = false
71+
clipsToBounds = true
7572
wantsLayer = true
7673
layerContentsRedrawPolicy = .onSetNeedsDisplay
7774
translatesAutoresizingMaskIntoConstraints = false
78-
layer?.masksToBounds = false
75+
layer?.masksToBounds = true
7976

8077
NotificationCenter.default.addObserver(
8178
forName: TextSelectionManager.selectionChangedNotification,
@@ -165,6 +162,16 @@ public class GutterView: NSView {
165162
}
166163

167164
context.saveGState()
165+
166+
context.setAllowsAntialiasing(true)
167+
context.setShouldAntialias(true)
168+
context.setAllowsFontSmoothing(false)
169+
context.setAllowsFontSubpixelPositioning(true)
170+
context.setShouldSubpixelPositionFonts(true)
171+
context.setAllowsFontSubpixelQuantization(true)
172+
context.setShouldSubpixelQuantizeFonts(true)
173+
ContextSetHiddenSmoothingStyle(context, 16)
174+
168175
context.textMatrix = CGAffineTransform(scaleX: 1, y: -1)
169176
for linePosition in textView.layoutManager.visibleLines() {
170177
if selectionRangeMap.intersects(integersIn: linePosition.range) {

0 commit comments

Comments
 (0)