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

Add change font size #94

Open
Kisty opened this issue Sep 12, 2019 · 3 comments
Open

Add change font size #94

Kisty opened this issue Sep 12, 2019 · 3 comments

Comments

@Kisty
Copy link
Contributor

Kisty commented Sep 12, 2019

Being able to change font size would be super helpful especially for testing large fonts on screens. Would this be possible?

@drewhannay
Copy link
Contributor

Sorry for the delay in responding. At a glance, that sounds like a reasonable idea. It would be useful to see what changes are required to change the font size and if that's something we'd need to do at the system level or if we could get away with just modifying the base Context or using a ContextThemeWrapper.

I don't currently have the bandwidth to look into this myself, but anyone who's interested is welcome to do some investigation and share their findings!

@Kisty
Copy link
Contributor Author

Kisty commented Sep 25, 2019

No problem, Drew. Yeah, perhaps doing it in a ContextThemeWrapper would be a good idea however I wouldn't know how to inject ContextThemeWrapper in to the app. I think you could apply different scaling by overriding the getResources().getConfiguration() call to override fontScale or something?

@sergio-sastre
Copy link

sergio-sastre commented Mar 27, 2020

Hi there!
I created a TestRule by using getResources().getConfiguration() which actually serves the purpose of "simulating" the fontsize change, so I can confirm that approach works.
I guess this option might not be optimal for book-reader apps and the like that have in-app options to configure the font size, since they likely use this approach as well, and might interfere with it.

Keep in mind that such an approach is just a simulation, since the font scale in the device settings stays the same.
In order to actually change the font size in the device settings, I found out that novoda has already implemented a TestRule that does it. For more info:
https://proandroiddev.com/testing-views-in-isolation-at-romobos-d288e76fe10e
https://github.com/novoda/espresso-support

However, while using Novoda's FontScaleTestRule I experienced some problems on some old Samsung devices, on which the font size change fails randomly... that's why I decided to create my own based on modifying getResources().getConfiguration() what serves for most of the apps and works reliably... so far.

Just my two cents ;)

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

No branches or pull requests

3 participants