Skip to content

Commit 3966140

Browse files
odmirKarthikRIyer
authored andcommitted
bfix: Explicitly set font smoothing to true in Quartz (#63)
* bfix: Explicitly set font smoothing to true in Quartz * [rfac][feat] Set font smoothing in initializer instead of text draw method, add `fontSmoothing` property to `QuartzRenderer` and update all Quartz reference images Font smoothing is turned off by default. * Set `setAllowsFontSmoothing` to true and change `fontSmoothing` initializer to be a property observer instad
1 parent 176924a commit 3966140

30 files changed

+8
-0
lines changed

Sources/QuartzRenderer/QuartzRenderer.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ public class QuartzRenderer: Renderer {
2121
var fontPath = ""
2222
public var offset = zeroPoint
2323

24+
public var fontSmoothing: Bool = false {
25+
didSet { context.setShouldSmoothFonts(fontSmoothing) }
26+
}
27+
2428
public var imageSize: Size {
2529
didSet {
2630
guard !isExternalContext else { return }
@@ -31,6 +35,8 @@ public class QuartzRenderer: Renderer {
3135
bytesPerRow: 0,
3236
space: Self.colorSpace,
3337
bitmapInfo: Self.bitmapInfo)!
38+
context.setAllowsFontSmoothing(true)
39+
context.setShouldSmoothFonts(fontSmoothing)
3440
let rect = CGRect(x: 0,
3541
y: 0,
3642
width: Int(imageSize.width),
@@ -55,6 +61,8 @@ public class QuartzRenderer: Renderer {
5561
bytesPerRow: 0,
5662
space: Self.colorSpace,
5763
bitmapInfo: Self.bitmapInfo)!
64+
self.context.setAllowsFontSmoothing(true)
65+
self.context.setShouldSmoothFonts(fontSmoothing)
5866
self.isExternalContext = false
5967
}
6068

-642 Bytes
Loading
-578 Bytes
Loading
-447 Bytes
Loading
-1.5 KB
Loading
-631 Bytes
Loading
-747 Bytes
Loading
-596 Bytes
Loading
-652 Bytes
Loading
-437 Bytes
Loading

0 commit comments

Comments
 (0)