Skip to content

Commit 6b26bae

Browse files
committed
Use New Drawing Settings
1 parent acfe377 commit 6b26bae

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Sources/CodeEditTextView/TextLine/LineFragment.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,18 @@ public final class LineFragment: Identifiable, Equatable {
5252
public func draw(in context: CGContext, yPos: CGFloat) {
5353
context.saveGState()
5454

55+
// Removes jagged edges
5556
context.setAllowsAntialiasing(true)
5657
context.setShouldAntialias(true)
57-
context.setAllowsFontSmoothing(false)
58-
context.setShouldSmoothFonts(false)
58+
59+
// Effectively increases the screen resolution by drawing text in each LED color pixel (R, G, or B), rather than
60+
// the triplet of pixels (RGB) for a regular pixel. This can increase text clarity, but loses effectiveness
61+
// in low-contrast settings.
5962
context.setAllowsFontSubpixelPositioning(true)
6063
context.setShouldSubpixelPositionFonts(true)
64+
65+
// Quantizes the position of each glyph, resulting in slightly less accurate positioning, and gaining higher
66+
// quality bitmaps and performance.
6167
context.setAllowsFontSubpixelQuantization(true)
6268
context.setShouldSubpixelQuantizeFonts(true)
6369

@@ -66,7 +72,7 @@ public final class LineFragment: Identifiable, Equatable {
6672
context.textMatrix = .init(scaleX: 1, y: -1)
6773
context.textPosition = CGPoint(
6874
x: 0,
69-
y: yPos + (height - descent + (heightDifference/2))
75+
y: height - descent + (heightDifference/2)
7076
).pixelAligned
7177

7278
CTLineDraw(ctLine, context)

0 commit comments

Comments
 (0)