Skip to content

Commit

Permalink
Added NotoSansUI as chinese font
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanOltmann committed Oct 22, 2024
1 parent 2c2d79a commit 0c60546
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
36 changes: 34 additions & 2 deletions app/src/commonMain/kotlin/ui/theme/Typhography.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.intl.Locale
import oni_seed_browser.app.generated.resources.Res
import oni_seed_browser.app.generated.resources.economica_bold
import oni_seed_browser.app.generated.resources.economica_bold_italic
import oni_seed_browser.app.generated.resources.economica_italic
import oni_seed_browser.app.generated.resources.economica_regular
import oni_seed_browser.app.generated.resources.noto_sans_bold
import oni_seed_browser.app.generated.resources.noto_sans_italic
import oni_seed_browser.app.generated.resources.noto_sans_regular
import org.jetbrains.compose.resources.Font

@Composable
Expand All @@ -55,11 +59,39 @@ fun EconomicaFontFamily(): FontFamily = FontFamily(
)
)

/** Font containing chinese symbols. */
@Composable
fun NotoSansFamily(): FontFamily = FontFamily(
Font(
resource = Res.font.noto_sans_regular,
weight = FontWeight.Normal,
style = FontStyle.Normal
),
Font(
resource = Res.font.noto_sans_bold,
weight = FontWeight.Bold,
style = FontStyle.Normal
),
Font(
resource = Res.font.noto_sans_italic,
weight = FontWeight.Normal,
style = FontStyle.Italic
),
Font(
resource = Res.font.noto_sans_bold_italic,
weight = FontWeight.Bold,
style = FontStyle.Italic
)
)

@Composable
fun AppTypography(): Typography =
Typography().defaultFontFamily(EconomicaFontFamily())
if (Locale.current.language != "zh")
Typography().defaultFontFamily(EconomicaFontFamily())
else
Typography().defaultFontFamily(NotoSansFamily())

fun Typography.defaultFontFamily(fontFamily: FontFamily): Typography {
private fun Typography.defaultFontFamily(fontFamily: FontFamily): Typography {
return this.copy(
displayLarge = this.displayLarge.copy(fontFamily = fontFamily),
displayMedium = this.displayMedium.copy(fontFamily = fontFamily),
Expand Down

0 comments on commit 0c60546

Please sign in to comment.