-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(android/text-base): remove extra font padding for custom fonts gl… #10771
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
base: main
Are you sure you want to change the base?
fix(android/text-base): remove extra font padding for custom fonts gl… #10771
Conversation
…obally Apply setIncludeFontPadding(false) in TextBase.initNativeView for all Android text-based views. This fixes the issue where custom and icon fonts appeared taller than expected due to Android's default font padding. The fix is global and backward compatible, so no manual workaround is needed in app code.\n\nCloses #<issue-number-if-applicable>
|
||
// Fix for custom font over-height issue on Android | ||
// Disable font padding to prevent extra spacing around text | ||
nativeView.setIncludeFontPadding(false); |
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.
I'm curious @CatchABus do you see any issue with this fix?
@ahmedsalman74 Could you post screenshots of the problem from both platforms? According to android docs, this method:
The extra padding for accents might be necessary and there's also a possibility that the widget itself has a native padding that's not removed using |
@CatchABus Here is what I get with this font icon: https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@3.34.1/dist/fonts/tabler-icons-300.ttf ![]() I tried different fonts in the hello world project and some of them were rendered correctly and some not. In the screenshot the height for "font 1" is terrible and for "font 3" is slightly more than normal. It might be due to the wrong metrics set for this specific font? I'm not a font expert, I wonder why the height is correct on the web for all of these fonts but not on Android. If the problem is related only to this specific font and not others; then a generic fix might not be needed in the nativescript core? or we may need a property in styles or somewhere to enable or disable it per use case? |
Thank you for this @ahmedsalman74 we'll discuss what may be best in this case to include any adjustments for 9.0. |
Apply setIncludeFontPadding(false) in TextBase.initNativeView for all Android text-based views. This fixes the issue where custom and icon fonts appeared taller than expected due to Android's default font padding. The fix is global and backward compatible, so no manual workaround is needed in app code.\n\nCloses #
PR Checklist
Fixes/Implements/Closes #10769 .