Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Commit

Permalink
Use Source Serif Pro font for greek
Browse files Browse the repository at this point in the history
Signed-off-by: Lucchetto <[email protected]>
  • Loading branch information
Lucchetto committed Feb 24, 2023
1 parent 66e0267 commit bf13bc1
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 99 deletions.
213 changes: 114 additions & 99 deletions app/src/main/java/com/zhenxiang/superimage/ui/theme/Type.kt
Original file line number Diff line number Diff line change
@@ -1,109 +1,124 @@
package com.zhenxiang.superimage.ui.theme

import androidx.compose.material3.Typography
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
import com.zhenxiang.superimage.R

private val CrimsonText = FontFamily(
Font(R.font.crimson_text_regular),
Font(R.font.crimson_text_semibold, FontWeight.W600),
Font(R.font.crimson_text_bold, FontWeight.Bold)
)

val Typography = Typography(
displayMedium = TextStyle(
fontWeight = FontWeight.Normal,
fontFamily = CrimsonText,
fontSize = 42.sp,
lineHeight = 48.sp,
letterSpacing = 0.sp
),
headlineLarge = TextStyle(
fontWeight = FontWeight.SemiBold,
fontFamily = CrimsonText,
fontSize = 32.sp,
lineHeight = 40.sp,
letterSpacing = 0.sp
),
headlineMedium = TextStyle(
fontWeight = FontWeight.SemiBold,
fontFamily = CrimsonText,
fontSize = 28.sp,
lineHeight = 36.sp,
letterSpacing = 0.sp
),
headlineSmall = TextStyle(
fontWeight = FontWeight.Normal,
fontFamily = CrimsonText,
fontSize = 22.sp,
lineHeight = 30.sp,
letterSpacing = 0.sp
),
titleLarge = TextStyle(
fontWeight = FontWeight.SemiBold,
fontFamily = CrimsonText,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp
),
titleMedium = TextStyle(
fontWeight = FontWeight.SemiBold,
fontFamily = CrimsonText,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.15.sp
),
titleSmall = TextStyle(
fontWeight = FontWeight.Bold,
fontFamily = CrimsonText,
fontSize = 14.sp,
lineHeight = 20.sp,
letterSpacing = 0.1.sp
),
bodyLarge = TextStyle(
fontWeight = FontWeight.Normal,
fontFamily = CrimsonText,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.15.sp
),
bodyMedium = TextStyle(
fontWeight = FontWeight.Normal,
fontFamily = CrimsonText,
fontSize = 14.sp,
lineHeight = 20.sp,
letterSpacing = 0.5.sp
),
bodySmall = TextStyle(
fontWeight = FontWeight.Normal,
fontFamily = CrimsonText,
fontSize = 12.sp,
lineHeight = 16.sp,
letterSpacing = 0.15.sp
),
labelLarge = TextStyle(
fontWeight = FontWeight.Normal,
fontFamily = CrimsonText,
fontSize = 18.sp,
lineHeight = 24.sp,
letterSpacing = 0.1.sp
),
labelMedium = TextStyle(
fontWeight = FontWeight.SemiBold,
fontFamily = CrimsonText,
fontSize = 12.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp
),
labelSmall = TextStyle(
fontWeight = FontWeight.SemiBold,
fontFamily = CrimsonText,
fontSize = 11.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
)
val Typography: Typography
@Composable get() {
val fontFamily = stringResource(R.string.font_family).let {
when (it) {
"source" -> FontFamily(
Font(R.font.source_serif_pro_regular),
Font(R.font.source_serif_pro_semibold, FontWeight.W600),
Font(R.font.source_serif_pro_bold, FontWeight.Bold)
)
"crimson" -> FontFamily(
Font(R.font.crimson_text_regular),
Font(R.font.crimson_text_semibold, FontWeight.W600),
Font(R.font.crimson_text_bold, FontWeight.Bold)
)
else -> throw IllegalStateException("Invalid font family for locale")
}
}

return Typography(
displayMedium = TextStyle(
fontWeight = FontWeight.Normal,
fontFamily = fontFamily,
fontSize = 42.sp,
lineHeight = 48.sp,
letterSpacing = 0.sp
),
headlineLarge = TextStyle(
fontWeight = FontWeight.SemiBold,
fontFamily = fontFamily,
fontSize = 32.sp,
lineHeight = 40.sp,
letterSpacing = 0.sp
),
headlineMedium = TextStyle(
fontWeight = FontWeight.SemiBold,
fontFamily = fontFamily,
fontSize = 28.sp,
lineHeight = 36.sp,
letterSpacing = 0.sp
),
headlineSmall = TextStyle(
fontWeight = FontWeight.Normal,
fontFamily = fontFamily,
fontSize = 22.sp,
lineHeight = 30.sp,
letterSpacing = 0.sp
),
titleLarge = TextStyle(
fontWeight = FontWeight.SemiBold,
fontFamily = fontFamily,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp
),
titleMedium = TextStyle(
fontWeight = FontWeight.SemiBold,
fontFamily = fontFamily,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.15.sp
),
titleSmall = TextStyle(
fontWeight = FontWeight.Bold,
fontFamily = fontFamily,
fontSize = 14.sp,
lineHeight = 20.sp,
letterSpacing = 0.1.sp
),
bodyLarge = TextStyle(
fontWeight = FontWeight.Normal,
fontFamily = fontFamily,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.15.sp
),
bodyMedium = TextStyle(
fontWeight = FontWeight.Normal,
fontFamily = fontFamily,
fontSize = 14.sp,
lineHeight = 20.sp,
letterSpacing = 0.5.sp
),
bodySmall = TextStyle(
fontWeight = FontWeight.Normal,
fontFamily = fontFamily,
fontSize = 12.sp,
lineHeight = 16.sp,
letterSpacing = 0.15.sp
),
labelLarge = TextStyle(
fontWeight = FontWeight.Normal,
fontFamily = fontFamily,
fontSize = 18.sp,
lineHeight = 24.sp,
letterSpacing = 0.1.sp
),
labelMedium = TextStyle(
fontWeight = FontWeight.SemiBold,
fontFamily = fontFamily,
fontSize = 12.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp
),
labelSmall = TextStyle(
fontWeight = FontWeight.SemiBold,
fontFamily = fontFamily,
fontSize = 11.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
)
}
Binary file added app/src/main/res/font/source_serif_pro_bold.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<resources>
<string name="font_family">@string/source_serif_pro_font</string>

<string name="app_name">SuperImage</string>

<string name="time_unit_space">\u0020</string>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<resources>
<!-- Indicates the font to use for the locale -->
<string name="font_family">@string/default_font</string>

<string name="app_name">SuperImage</string>

<string name="time_unit_space">\u0020</string>
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/strings_no_translate.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="default_font" translatable="false">crimson</string>
<string name="source_serif_pro_font" translatable="false">source</string>
</resources>

0 comments on commit bf13bc1

Please sign in to comment.