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!
* Scroll down a bit to see an exmple!
- A fallback font that is static, not variable. Read more about why!
- A variable font, you can get one from fonts.google.com
- Find your favorite font and use the Download family button in the top-right corner.
- Unzip the downloaded file.
- Find <𝚢𝚘𝚞𝚛-𝚏𝚘𝚗𝚝>-𝚅𝚊𝚛𝚒𝚊𝚋𝚕𝚎𝙵𝚘𝚗𝚝, it should appear in the root directory. Rename it if you’d like.
- Upload it to your Kodular project!
- Set the chosen font as the
- A component from those listed
- The font weight you’d like your font to be displayed in
This value is normally between 100 and 900.
What font types are supported
- An OTF file wasn’t tested
- Most fonts from fonts.google.com only offer TTF variants.
- OTF files are expected to work.
- A TTF file was tested and worked fine
- 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.
This is going to be amazing for font lover like me. Good work!
Nice Work @Squishy… , Oh Sorry @hammerhai
Awesome Work, Can’t Believe On My Eyes
@hammerhai Nice job but there is some query that can it work with Dynamic label’s also
It should work with labels created dynamically. In fact, extensions don’t have to add support for dynamic components.
great extension, that will help us a lot.
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.
Thanks @Sumit1334 I got the full confirmation now
Font Variation 0.2.0
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.
- 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.
- 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.
- “SetFontVariationSettings” has been deprecated and will no longer work as a result of the newly added property and revised memory management. Use “SetFontSettings” instead.
I apologize to everyone who this may have been an inconvenience to.
Font Variation 1.0.0
This release includes major and minor changes.
- Added a new parameter to
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:
- The device isn’t at least API 26.
Font property is not set.
- Added back
SetFontVariationSettings after a long vacation! Read more about why below.
- Added the ability to use
SetFontVariationSettings with more components!
The allowed, and tested, component types are as follows:
- Due to the acceptance of more component types, the
labelComponent parameter is now named
SetFontSettings, please use
SetFontVariationSettings instead. It will continue to work properly, however without a fallback font.
- Removed the old
SetFontVariationSettings from Font Variation 0.2.0. Use the new
Font Variation doesn’t work in the companion.
Font Variation 2.0.0
This release includes major and minor changes.
- Added caching for fonts.
- 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.
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.
Font property will continue to be supported until this is removed. Additionally,
SetFontVariationSettings will continue working properly, however the
width parameter will be ignored.