Its looks like android following web standards for font management and sizing for android app.
The “font-weight” property is used to define the weight of a font, such as regular or bold.
But for all other weights a numerical range from 100 to 900 is used. One of the challenges with web fonts is that most web browsers do not properly support font weights other than normal & bold. The following chart describes the possible mappings of weights to the numeric definitions:
100 Extra Light or Ultra Light
200 Light or Thin
300 Book or Demi
400 Normal or Regular
500 Medium
600 Semibold, Demibold
700 Bold
800 Black, Extra Bold or Heavy
900 Extra Black, Fat, Poster or Ultra Black
You can read more about font weight here
cc_montserrat_bold.xml
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<font
android:font="@font/montserrat_bold"
android:fontStyle="normal"
android:fontWeight="700"
app:font="@font/montserrat_bold"
app:fontStyle="normal"
app:fontWeight="700" />
<font
android:font="@font/montserrat_bolditalic"
android:fontStyle="italic"
android:fontWeight="700"
app:font="@font/montserrat_bolditalic"
app:fontStyle="italic"
app:fontWeight="700" />
</font-family>
cc_montserrat_regular.xml
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<font
android:font="@font/montserrat_regular"
android:fontStyle="normal"
android:fontWeight="400"
app:font="@font/montserrat_regular"
app:fontStyle="normal"
app:fontWeight="400" />
<font
android:font="@font/montserrat_italic"
android:fontStyle="italic"
android:fontWeight="400"
app:font="@font/montserrat_italic"
app:fontStyle="italic"
app:fontWeight="400" />
</font-family>
Kotlin Usage:
val textView = dialog.findViewById<TextView>(android.R.id.message) as TextView
val typeface = ResourcesCompat.getFont(context,R.font.cc_montserrat_regular)
textView.typeface = typeface
Android Project Screenshot:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…