Respect font scale on iOS and Android

In Defold, is there a built-in way to respect the user’s preference with regards to font scale on iOS and Android?

In React Native, I’m used to relying on fontScale (e.g. useWindowDimensions · React Native):

No, there is nothing in the current set of APIs which lets you get the font scale.

It is possible to read these values in a native extension and return them to Lua where the values could be used to scale labels and text nodes. It could perhaps be something that is baked into DefOS, since there are similar font/UI scaling concepts also on desktop and in the browser.

2 Likes

I ended up creating a separate extension, cause DefOS seems very focused on desktop environments. If @Pkeod thinks it’s better to merge, we can always do that.

3 Likes

DefOS can have features for any platform. What happened is that Defold was more mobile focused and there were many desktop features that were crucial for commercial desktop releases so the community made DefOS. Eventually all of the important features in DefOS should become a part of core Defold. It’s fine to have extension that do specific useful things.

1 Like

Yeah, DefOS adds a lot of desktop specific utility functions, but I would say that getting the font scale of the OS or user prefs is something that would fit right in with the theme of the extension, regardless if it is for mobile or desktop.

That’s fair. It’d have been the first mobile feature on DefOS, so I was a bit intimidated… The code is MIT, so anyone should feel free to merge it into DefOS.

I’ve only done the work for Android and iOS. For other platforms:

gsettings get org.gnome.desktop.interface text-scaling-factor
3 Likes

Ah, I thought there was mobile support in DefOS already. I remember wrong! Anyway, good job on the extension, and thanks for submitting it to the asset portal!