neworld / spanner

Simple and fluent spannable builder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Font is not being applied

jrcacd opened this issue · comments

commented

Kotlin:

val texto = Spanner()
texto.append(text, font("Roboto Slab"))

It must be my mistake.

Probably, Android doesn't support this font family. This lib is a just simple wrapper for android spans. This font(...) is using TypefaceSpan. I don't think there are a solution through spans. You could try to apply this font directly to the TextView, or try this lib: https://github.com/johnkil/Android-RobotoTextView

Kotlin:

val texto = Spanner()
texto.append(text, font("Roboto Slab"))

It must be my mistake.

You can define your Font Family in package Font and it will work.

Example:
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto">
//Regular
<font
app:font="@font/Roboto Slab"
app:fontStyle="normal"
app:fontWeight="400" />
//Bold
<font
app:font="@font/Roboto Slab"
app:fontStyle="normal"
app:fontWeight="700" />

Then:
//It will use Roboto Slab with font weight 700
texto.append(text, font("Roboto Slab"), bold())