Sitemap

Member-only story

Use Custom Fonts In Jetpack Compose

2 min readSep 10, 2024
Photo by CHUTTERSNAP on Unsplash

Link For Non-Members

In this article we will see how to use custom fonts in Jetpack Compose.

Add Custom Fonts in Font Folder

Well our first task is to add all the required fonts in the res/font folder.

If the font folder is not exists then create one by right click on res folder → New → folder → Font Folder.

Custom fonts

Here we paste all the required fonts.

Bind Custom fonts with respective Font Weights

open type.kt file and paste the below code there.

val customFont = FontFamily(
Font(R.font.montserrat_regular, weight = FontWeight.Normal),
Font(R.font.montserrat_thin, weight = FontWeight.Thin),
Font(R.font.montserrat_light, weight = FontWeight.Light),
Font(R.font.montserrat_extra_light, weight = FontWeight.ExtraLight),
Font(R.font.montserrat_medium, weight = FontWeight.Medium),
Font(R.font.montserrat_semi_bold, weight = FontWeight.SemiBold),
Font(R.font.montserrat_bold, weight = FontWeight.Bold),
Font(R.font.montserrat_extra_bold, weight = FontWeight.ExtraBold)…

--

--

Jayant Kumar🇮🇳
Jayant Kumar🇮🇳

Written by Jayant Kumar🇮🇳

My name is Jayant Kumar, I am a Lead Software Engineer @Antino from India 🇮🇳. I write blogs and make youtube videos on Kotlin , Android & Jetpack Compose

Responses (1)