I know that ho sets up a custom font programmatically inside an Android application. Is there a way to download a font for a custom font (assets) and the Android framework will use the correct file based on bold, italic and so on?
For example, now I'm trying to set the Roboto font for some TextView
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/Roboto/Roboto-Regular.ttf"); textView.setTypeface(typeface);
It is working fine. But since I am installing the TextView inside the bold bold xml layout, the text is not bold
<TextView android:id="@+id/my_id" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_marginTop="50dp" android:textStyle="bold" android:gravity="center" android:text="@string/my_text" android:textColor="@color/my_foreground" android:textSize="24dp" />
How to load a font from assets that will work?
textView.setTypeface(typeface, Typeface.BOLD);
There is only one "font family" inside my resource
Roboto-Black.ttf Roboto-BlackItalic.ttf Roboto-Bold.ttf Roboto-BoldCondensed.ttf Roboto-BoldCondensedItalic.ttf Roboto-BoldItalic.ttf Roboto-Condensed.ttf Roboto-CondensedItalic.ttf Roboto-Italic.ttf Roboto-Light.ttf Roboto-LightItalic.ttf Roboto-Medium.ttf Roboto-MediumItalic.ttf Roboto-Regular.ttf Roboto-Thin.ttf Roboto-ThinItalic.ttf
How to load all these fonts within one font / family?
source share