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
[Issue/605][Android]Apply OS font size scale change in editor #795
Conversation
… change on JS layer. Basically React Native has a mechanism to scale font automatically but GM is rendered on top of fragment of which retain flag is true. Hence we deal with fontScale change manually on our side. ref: #605
@@ -16,7 +16,7 @@ | |||
<activity | |||
android:name=".MainActivity" | |||
android:label="@string/app_name" | |||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize" | |||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|fontScale" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not directly related to the issue but to align condition with wordpress-android added fontScale
to prevent activity recreation by fontScale change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 @hotchemi , does this change make the demo app differ in behavior between Android and iOS?
I'm thinking that making the demo app behave closer to WPAndroid might not be a desirable goal. Instead, the demo app should be as simple as possible and ideally not hide any "mistakes" or "hacks" WPAndroid implements. Also, ideally the Android and iOS implementations of the demo app should be as identical as possible.
// Basically React Native has a mechanism to scale font size automatically. | ||
// But GM is rendered on top of fragment of which retain flag is true. | ||
// Hence we deal with fontScale change manually on our side. | ||
export function getScaledFontSize( fontSize, fontScale ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently there's no dependency of unit test in react-native-aztec
but if ok I'd like to install jest and write an unit test for the function🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's hold on a bit while we're still assessing the solution in this PR.
While at it though, what do you have in mind for how such a unit test would be run? Will it become part of the Jest testsuite already in place in gutenberg-mobile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @hotchemi !
I tried this with WPAndroid (develop at commit fc1ea5c4d8) and I don't see the editor's fonts updating on my Pixel 2XL (Android 9). Should it? Have you tried it with WPAndroid and works for you perhaps?
Also, it seems that the solution here would only update the Aztec based components only, right? What should we do with components based on React Native's TextInput component or other text RN text components? Will those get size-adjusted automatically maybe?
if ( Platform.OS === 'ios' ) { | ||
return fontSize ? fontSize : undefined; // to not to affect to iOS | ||
} | ||
const baseFontSize = 18; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use the default value set in RN for this? https://github.com/facebook/react-native/blob/1151c096dab17e5d9a6ac05b61aacecd4305f3db/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewDefaults.java#L15
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daniloercoli @hypest Thank you for your review🙇 After opening PR I'm kind of wondering this is too workaround to merge to upstream..🤔Yes we can mimic plausible behavior with this change but I'm kind of skeptical this change is maintainable enough for team. To resolve the issue fundamentally I think we should remove |
Seems like this PR is not a fundamental solution to address the issue, let me close for the time being 👋 |
Issue
Overview
This PR fixes GM editor to apply system level font scale change immediately.
Honestly this change is a bit tricky as React Native has a mechanism that allows
<Text>
component to scale font size according to system setting. But the point is we're using GM component on top of fragment of which retain flag is true, we can't rely on RN font scaling system.After several investigations, I've noticed we can detect fontScale change on RN side by observing
Dimensions
change and added a function to calculate new font size to deal with the issue.Note
This PR doesn't affect to iOS side since the situation I explained above is a different on each platform.
Links
Screenshots
Test
Use Block Editor
from app setting