Skip to content

Commit

Permalink
#114 add IranYekan font for persian language
Browse files Browse the repository at this point in the history
  • Loading branch information
javadjafari1 committed Dec 17, 2023
1 parent 46b85f8 commit 6e154b7
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 2 deletions.
12 changes: 11 additions & 1 deletion app/src/main/kotlin/ir/thatsmejavad/backgroundable/ui/Theme.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package ir.thatsmejavad.backgroundable.ui

import android.os.Build
import androidx.appcompat.app.AppCompatDelegate
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Shapes
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import ir.thatsmejavad.backgroundable.core.sealeds.ThemeColor
Expand Down Expand Up @@ -68,9 +70,17 @@ fun BackgroundableTheme(
}
}

val isPersianSelected = remember {
AppCompatDelegate.getApplicationLocales().get(0)?.language == "fa"
}

MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
typography = if (isPersianSelected) {
PersianTypography
} else {
EnglishTypography
},
shapes = shapes,
content = content
)
Expand Down
91 changes: 90 additions & 1 deletion app/src/main/kotlin/ir/thatsmejavad/backgroundable/ui/Type.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@ val Poppins = FontFamily(
)
)

val Typography = Typography(
val IranYekan = FontFamily(
Font(
resId = R.font.iran_yekan_bold,
weight = FontWeight.Medium,
),
Font(
resId = R.font.iran_yekan_regular,
weight = FontWeight.Normal,
)
)

val EnglishTypography = Typography(
displayLarge = TextStyle(
fontFamily = Poppins,
fontWeight = FontWeight.Normal,
Expand Down Expand Up @@ -96,3 +107,81 @@ val Typography = Typography(
fontSize = 11.sp
),
)

val PersianTypography = Typography(
displayLarge = TextStyle(
fontFamily = IranYekan,
fontWeight = FontWeight.Normal,
fontSize = 57.sp
),
displayMedium = TextStyle(
fontFamily = IranYekan,
fontWeight = FontWeight.Normal,
fontSize = 45.sp
),
displaySmall = TextStyle(
fontFamily = IranYekan,
fontWeight = FontWeight.Normal,
fontSize = 36.sp
),
headlineLarge = TextStyle(
fontFamily = IranYekan,
fontWeight = FontWeight.Normal,
fontSize = 32.sp
),
headlineMedium = TextStyle(
fontFamily = IranYekan,
fontWeight = FontWeight.Normal,
fontSize = 28.sp
),
headlineSmall = TextStyle(
fontFamily = IranYekan,
fontWeight = FontWeight.Normal,
fontSize = 24.sp
),
titleLarge = TextStyle(
fontFamily = IranYekan,
fontWeight = FontWeight.Normal,
fontSize = 22.sp
),
titleMedium = TextStyle(
fontFamily = IranYekan,
fontWeight = FontWeight.Medium,
fontSize = 16.sp
),
titleSmall = TextStyle(
fontFamily = IranYekan,
fontWeight = FontWeight.Medium,
fontSize = 14.sp
),
bodyLarge = TextStyle(
fontFamily = IranYekan,
fontWeight = FontWeight.Normal,
fontSize = 16.sp
),
bodyMedium = TextStyle(
fontFamily = IranYekan,
fontWeight = FontWeight.Normal,
fontSize = 14.sp
),
bodySmall = TextStyle(
fontFamily = IranYekan,
fontWeight = FontWeight.Normal,
fontSize = 12.sp
),
labelLarge = TextStyle(
fontFamily = IranYekan,
fontWeight = FontWeight.Medium,
fontSize = 14.sp
),
labelMedium = TextStyle(
fontFamily = IranYekan,
fontWeight = FontWeight.Medium,
fontSize = 12.sp
),
labelSmall = TextStyle(
fontFamily = IranYekan,
fontWeight = FontWeight.Medium,
fontSize = 11.sp
),
)
Binary file added app/src/main/res/font/iran_yekan_bold.ttf
Binary file not shown.
Binary file added app/src/main/res/font/iran_yekan_regular.ttf
Binary file not shown.

0 comments on commit 6e154b7

Please sign in to comment.