Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

[PS-191] Improve support for larger fonts Android#2053

Merged
aj-rosado merged 2 commits intomasterfrom
feature/PS-191-Add-support-larger-fonts-android
Aug 31, 2022
Merged

[PS-191] Improve support for larger fonts Android#2053
aj-rosado merged 2 commits intomasterfrom
feature/PS-191-Add-support-larger-fonts-android

Conversation

@aj-rosado
Copy link
Copy Markdown
Contributor

Type of change

  • Bug fix
  • New feature development
  • Tech debt (refactoring, code cleanup, dependency upgrades, etc)
  • Build/deploy pipeline (DevOps)
  • Other

Objective

The fonts on Android are too big on some devices. Removed Android native scaling as xamarin NamedSize is already scaling the fonts.

Code changes

  • MainActivity.cs: Set the native Android font scaling to 1. So that it doesn't scale as the Xamarin NamedSize is already scaling the text

Screenshots

Max font size with Android scaling:
scaling

Max font size without Android scaling:
no-scaling

Before you submit

  • I have checked for formatting errors (dotnet tool run dotnet-format --check) (required)
  • I have added unit tests where it makes sense to do so (encouraged but not required)
  • This change requires a documentation update (notify the documentation team)
  • This change has particular deployment requirements (notify the DevOps team)

@djsmith85 djsmith85 linked an issue Aug 29, 2022 that may be closed by this pull request
Comment thread src/Android/MainActivity.cs
@fedemkr fedemkr added the Accessibility General UI/UX Accessibility, assistive technology, WCAG and Section 508 compliance items label Aug 29, 2022
Comment on lines +408 to +413
private void DisableAndroidFontScale()
{
//As we are using NamedSizes the xamarin will change the font size. So we are disabling the Android scaling.
Resources.Configuration.FontScale = 1f;
BaseContext.Resources.DisplayMetrics.ScaledDensity = Resources.Configuration.FontScale * (float)DeviceDisplay.MainDisplayInfo.Density;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% sure if this is safe enough that doesn't throw exception at some case or device specifics. Just in case, could you wrap this in a try...catch that logs the exception to AppCenter? So that if something happens the app doesn't crash and the users can use the app nonetheless given that you're calling it from OnCreate

@aj-rosado aj-rosado requested a review from fedemkr August 30, 2022 10:57
@aj-rosado aj-rosado merged commit b628c19 into master Aug 31, 2022
@aj-rosado aj-rosado deleted the feature/PS-191-Add-support-larger-fonts-android branch August 31, 2022 11:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Accessibility General UI/UX Accessibility, assistive technology, WCAG and Section 508 compliance items android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android: Larger than "default" font sizes are too large

2 participants