Starting with Android O, variable fonts were supported for Android. To this day, they continue to be. With no way to change font weight besides download separate files, it gets overwhelming. So overwhelming that your application can’t hold your font files anymore, you have too many!
As of June 2023, using Font Variation v2.0.0 is preferred. The likeliness of an out–of–memory error occurring is slim.
What’s needed
* Scroll down a bit to see an exmple!
A fallback font that is static, not variable. Read more about why!
Others were not considered or don’t work with Android
Will this work with older Android versions
No, however, no minimum Android version is needed to use Font Variation. This was taken into consideration considering only about 61% of the Android population is running Android O. There is a check in place to make sure it only works on API 26 and onwards, the fallback font will be used otherwise or not at all if one isn’t specified.
It will work with dynamic labels that is created by Dynamic Components extension as label(generated by extension) is a instance of a simple label. So it is same as a simple label component. However it would not work with in built dynamic label as the extension accepts Label datatype as a parameter(can’t say about this one), however in built dynamic label doesn’t return Label instance. Therefore if you use in built dynamic label then you’ll probably face an argument error by the extension.
Before I begin, I want to thank you all for the amazing support given for this extension! It felt great doing something new and knowing that I’m helping people do what they like most.
ADDED
A new property named “Font” was added. Testing showed that this completely resolved OOMEs and greatly improved performance, however, it may vary by device.
A new function named “SetFontSettings.” Read more below.
CHANGED
Memory management has been revised to include checking if the applications allocated memory heap is low. As with the OOMEs, when allocated memory is running low, nothing will happen.
DEPRECATED
“SetFontVariationSettings” has been deprecated and will no longer work as a result of the newly added property and revised memory management. Use “SetFontSettings” instead.
Files
I apologize to everyone who this may have been an inconvenience to.
Added a new parameter to SetFontVariationSettings named fallback. Here’s how this parameter will handle use cases:
Font Variation will first check if the font file exists in the applications external directory, then fallback to assets. It’s important to note that font files will only be retrieved from the “files” directory, no parent directory or sub-directory of "files."
This parameter will not be consumed if it’s empty.
There are two cases by which this parameter will be consumed:
This decision was based on Font Variation 0.2.0 which featured the removal of the font parameter from SetFontSettings due to performance issues when using the slider component to change the font variation settings frequently.
This has improved performance compared to Font Variation 0.1.0, which didn’t include font caching, however it was only tested with one variable font and performance may vary by device.
Added FontVariationSettings as a new method for setting the font variation settings for supported components.
This change includes the addition of the font parameter, but comes with the removal of the width parameter due to its uselessness.
Deprecated
Deprecated SetFontVariationSettings, use FontVariationSettings instead.
The Font property will continue to be supported until this is removed. Additionally, SetFontVariationSettings will continue working properly, however the width parameter will be ignored.
Removed
Removed SetFontSettings, use FontVariationSettings instead.