File tree Expand file tree Collapse file tree
Sources/OpenSwiftUICore/Shape/ShapeStyle Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -300,6 +300,24 @@ package struct _ShapeStyle_RenderedShape {
300300 name : ShapeStyle . Name ,
301301 layers : inout ShapeStyle . RenderedLayers
302302 ) {
303+ #if os( macOS )
304+ // Font smoothing on macOS depends on the fill color, even in an alpha-only context.
305+ // See https://developer.apple.com/documentation/coregraphics/cgcontext/setshouldsmoothfonts(_:)
306+ let maskColor : ORBColor
307+ switch style . fill {
308+ case let . color ( color ) :
309+ maskColor = ORBColor (
310+ red : color . linearRed ,
311+ green : color . linearGreen ,
312+ blue : color . linearBlue ,
313+ alpha : 1
314+ )
315+ default :
316+ maskColor = environment . colorScheme == . dark ? . white : . black
317+ }
318+ #else
319+ let maskColor = ORBColor . white
320+ #endif
303321 let resolved = text . text
304322 let textLayers = resolved . layers (
305323 for : frame . size ,
@@ -327,7 +345,7 @@ package struct _ShapeStyle_RenderedShape {
327345 keyColor : ORBColor
328346 ) {
329347 transform . removeAll ( )
330- transform . addColorReplacement ( from : keyColor , to : . white , colorSpace : . linearSRGB )
348+ transform . addColorReplacement ( from : keyColor , to : maskColor , colorSpace : . linearSRGB )
331349 let mask = transform . copyApplying ( toDisplayList : list )
332350 let drawing = makeDrawingItem ( from : mask , offset : offset , flags : flags . union ( . alphaOnly ) )
333351 layers . beginLayer ( id : id , style : style , shape : & self )
You can’t perform that action at this time.
0 commit comments