Search code examples
androidandroid-fontsandroid-downloadable-fonts

'Expected EOQ but found &' when setting custom font weight


I'm trying to use a downloadable font Montserrat with custom weight. This is a Google font and is available via Google Play Services.

In some tutorials I found they set custom weight by adding &weight=900 to the query, in my case resulting in

<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="Montserrat&amp;weight=900"
    app:fontProviderCerts="@array/com_google_android_gms_fonts_certs">
</font-family>

My Android Studio 3.0.1 complains that

Expected EOQ but found &

Any ideas why Android Studio doesn't let me set custom weight?


Solution

  • I was missing name= in front of the font name in the query.

    Correct query with custom font weight looks like

    app:fontProviderQuery="name=Montserrat&amp;weight=900"