[Catalyst][Text] Fix Catalyst text rendering by disabling inappropriate subpixel-antialiasing#29609
[Catalyst][Text] Fix Catalyst text rendering by disabling inappropriate subpixel-antialiasing#29609andymatuschak wants to merge 3 commits into
Conversation
|
Changed category to "iOS" from "Catalyst" per @pull-bot. |
Base commit: 79f305e |
Base commit: b7d6b32 |
Hello @andymatuschak, the code you have refactored will stay in place until Fabric is completely rolled out. Fabric on iOS is a complete rewrite. You have found the corresponding place in Fabric :).
If you define |
|
Thanks for that, @sammy-SC! I've just spent a while trying to get Fabric up and running (with iOS in general, not even on Catalyst). I faced immediate configuration issues which suggested to me that I was able to make some progress by making the changes: But even after these patches, the React-graphics pod appears to have some misconfiguration issues. It fails to build with this error: … which led me to notice that the React-graphics Pod's Xcode project is missing most of its source files, including the At this point, I stopped, because these problems don't appear to be local to my machine—it looks to me more like I'm simply not running known-good sources for Fabric. I've updated the test plan in the pull request description to include the steps for running RNTester on macOS/Catalyst, and I've pushed a commit to my branch which implements my change for Fabric. If you'd be willing to test the change yourself or to point me to where I've gone wrong in my attempt above, I'd be grateful. |
|
Hello @andymatuschak, Re Fabric: Thank you |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@sammy-SC has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
This pull request was successfully merged by @andymatuschak in 694e22d. When will my fix make it into a release? | Upcoming Releases |
|
Thank you for testing and landing this! |
|
@andymatuschak thank you for working on this :) |

Summary
I noticed when porting my iOS app to macOS via Catalyst that the text rendering was somewhat different on the two platforms. Text looked blurry and over-weight on macOS, even when disabling the Catalyst scaling transform.
I hazily remembered that I'd seen this problem before in my old Cocoa development days: this kind of blurring occurs when rendering text with sub-pixel anti-aliasing into an offscreen buffer which will then be traditionally composited, because when the SPAA algorithm attempts to blend with the underlying content (i.e. in the offscreen buffer), there isn't any. SPAA is disabled on iOS, so the issue wouldn't appear there. On macOS, typical approachs to displaying text (e.g.
CATextLayer) normally disable SPAA, since it's been incompatible with the platform's compositing strategy since the transition to layer-backed views some years ago. But React Native usesNSLayoutManagerto rasterize text (rather than relying on the system render server viaCATextLayer), and that class doesn't touch the context's font smoothing bit before drawing.This change makes macOS/Catalyst text rendering consistent with iOS text rendering by disabling SPAA.
It appears that the code I've modified is in the process of being refactored (for Fabric?). It looks like this is the corresponding place in the new code (@sammy-SC, is that right?). I'm happy to include a change to the new renderer in this patch if someone can point me at how to test that change.
Changelog
[iOS] [Fixed] - Improved text rendering on macOS Catalyst
Test Plan
RNTestertarget's configuration, and check the "Mac" checkbox under "Deployment Info.use_flipper!andflipper_post_installin the Podfile, then runningpod install; and b) removing theFB_SONARKIT_ENABLEDpreprocessor flags in the Xcode project.RNTestertarget configuration pane. Unfortunately, you must also do this in thePodsproject for theReact-Core-AccessibilityResourcestarget (this is an issue which CocoaPods must fix).