Implement the Custom font in Jetpack Compose
Add the font into res/font
folder
Create a font family and start using that Font family
@RequiresApi(Build.VERSION_CODES.Q)
val CustomFontFamily = FontFamily(
Font(R.font.opensans_regular, FontWeight.Normal),
Font(R.font.opensans_bold, FontWeight.Bold)
)
val Typography = Typography(
displaySmall = TextStyle(
fontFamily = CustomFontFamily,
fontWeight = FontWeight.Bold,
fontSize = 36.sp
),
@Composable
fun HeaderText(text: String) {
Text(
text = text,
modifier = Modifier
.fillMaxWidth(),
style = MaterialTheme.typography.displaySmall
)
}