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

Support isBoldTextEnabled for Android #477

Open
bmamouri opened this issue Apr 29, 2022 · 0 comments
Open

Support isBoldTextEnabled for Android #477

bmamouri opened this issue Apr 29, 2022 · 0 comments

Comments

@bmamouri
Copy link

bmamouri commented Apr 29, 2022

Introduction

AccessibilityInfo provides isBoldTextEnabled to determine if the bold font is enabled in accessibility settings. Currently, this option is limited to iOS. But on Android on API level 31 (Android 12) it is possible to determine its value by using fontWeightAdjustment in the Configuration class.

Details

On Pixel 5 device, for example, this option can be changed from "Settings > Accessibility > Text and Display"
image

Its value can be obtained by the Configuration class:

Configuration config = this.getResources().getConfiguration();
int fontWeight = config.fontWeightAdjustment;

Finding this value has practical applications. First, it allows developers to work around a current bug in text rendering of elements: Text component cuts part of the text if fontWeight bold is used. The issue is closed, but the problem still exists, as indicated by the sheer amount of user reports. Furthermore, the current workaround of adding spaces at the end of the text is no silver bullet because, depending on the text, the number of spaces that should be added to display the text correctly is variable.

Even if this issue gets fixed one day, this option provides a level of precision in text rendering that would not be possible without a way to detect this configuration.

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

1 participant