How to use non-Latin languages for Android downloadable fonts?

356 Views Asked by At

After reading the documentation for Google Fonts API for Android, I've successfully added different font weights beside regular and bold. But, the downloaded font isn't displaying for non-Latin characters. The difference can be seen between non-Latin letters (i.e. Cyrillic) and properly displayed Latin (like numbers and punctuation).

I even tried copying the web version of the API, something like this:

<?xml version="1.0" encoding="utf-8"?>
<font-family
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:fontProviderAuthority="com.google.android.gms.fonts"
    app:fontProviderPackage="com.google.android.gms"
    app:fontProviderQuery="name=Montserrat&amp;subset=cyrillic"
    app:fontProviderCerts="@array/com_google_android_gms_fonts_certs">
</font-family>

but nothing happened, because subset is not a valid keyword.

Is there any way to specify which scripts should be included, like with the web version?

2

There are 2 best solutions below

0
Vukašin Manojlović On BEST ANSWER

Now, Google Fonts API supports non-Latin characters for downloadable fonts by default. I have tested this on this sample project with the 29.0.0 build tools.

0
kovac777 On

It's not supported yet. You must use custom fonts that support cyrillic symbols for apply cyrillic. Put their it 'font' folder and get with ResourcesCompat.getFont(context, R.font.myfont) .