Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font size issues between iOS and macOS #229

Open
brendand opened this issue Feb 13, 2025 · 4 comments
Open

Font size issues between iOS and macOS #229

brendand opened this issue Feb 13, 2025 · 4 comments

Comments

@brendand
Copy link

How do you get the text in a RichTextEditor look approximately the same size as text with the same content on macOS?

I've been looking into the UITextView's usesStandardTextScaling property to try and figure this out. Apple states:

When the value of this property is true, UIKit automatically adjusts the rendering of the text in the text view to match the standard text scaling.
When using the standard text scaling, font sizes in the text view appear visually similar to how they would render in macOS and non-Apple platforms, and copying the contents of the text view to the pasteboard preserves the original font point sizes. This effectively changes the display size of the text without changing the actual font point size. For example, text using a 13-point font in iOS looks like text using a 13-point font in macOS.
If your app is built with Mac Catalyst, or if your text view’s contents save to a document that a user can view in macOS or other platforms, set this property to true.
The default value of this property is false.

but when I enable that on the RichTextView, it messes up the insertion pointer and doesn't display the text across the entire width of the UITextView like it should. Plus worse of all, the insertion pointer and selection blocks go all wonky.

I don't have a Mac Catalyst app. It's AppKit. I also have an iOS version. They display the same NSAttributedString data, but on iOS, the text renders too small. But if you change the text size on iOS to be more readable, then on macOS it's too large.

Basically how do you use RichTextKit to display the same size text on both macOS and iOS?

Here's two screenshots. Both showing the same paragraph selected.

The first one where the selection looks proper and matches the text is with usesStandardTextScaling = false. But the text is small and should render larger (without changing the point size of the text) so it visually matches what's seen on the Mac.

The second one is with usesStandardTextScaling = true and you can see the text isn't rendering larger as it should AND the selection area is offset from the content. It seems like the text needs to be shifted to the right and zoomed in a bit to make it fit the blue selection area.

Image

Image

How do other people handle text size issues between macOS and iOS apps?

@danielsaidi
Copy link
Owner

Hi @brendand

Keeping a standard font size has been problematic, and it should be improved.

I'm struggling with finding time for this project at the moment, but will hopefully have time later in H1. Until then, I'm happy to take a look at anything the community comes up with.

@brendand
Copy link
Author

So it's not just me holding it wrong? I'm pretty sure that Apple handles this sort of thing properly in apps like Notes and Pages between platforms. Would be great to know what tricks they use. I thought the usesStandardTextScaling = true was going to be the holy grail to solve this issue.

@danielsaidi
Copy link
Owner

I'm not sure. I agree that usesStandardTextScaling sounds like the thing to use. Could it be something in how SwiftUI wraps the native view that causes this?

@brendand
Copy link
Author

It happens with a regular UITextView. Not just RichTextKit. I filed a feedback on it in 2022 with a sample app, but never heard back from Apple on that. It was feedback FB11274733. You can try it out yourself. Attaching sample app.

TextViewCursorBug.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants