Use Google Sans Flex as the default font

This commit is contained in:
MM20
2026-01-30 15:33:07 +01:00
parent 02cd17312f
commit 8ba55f8345
27 changed files with 98 additions and 132 deletions

View File

@@ -3,7 +3,6 @@ package de.mm20.launcher2.ui.settings.appearance
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import de.mm20.launcher2.preferences.ColorScheme
import de.mm20.launcher2.preferences.Font
import de.mm20.launcher2.preferences.ui.UiSettings
import de.mm20.launcher2.themes.ThemeRepository
import kotlinx.coroutines.flow.SharingStarted
@@ -59,11 +58,4 @@ class AppearanceSettingsScreenVM : ViewModel(), KoinComponent {
fun setCompatModeColors(enabled: Boolean) {
uiSettings.setCompatModeColors(enabled)
}
val font = uiSettings.font
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
fun setFont(font: Font) {
uiSettings.setFont(font)
}
}

View File

@@ -859,7 +859,8 @@ private fun FontPickerCategory(
private fun getFontName(context: Context, fontFamily: ThemeFontFamily?): String {
return when (fontFamily) {
is ThemeFontFamily.LauncherDefault -> "Outfit"
is ThemeFontFamily.LauncherDefault -> "Google Sans Flex"
is ThemeFontFamily.LauncherDefaultRound -> "Google Sans Flex (Rounded)"
is ThemeFontFamily.DeviceHeadline -> context.getString(R.string.font_name_device_headline)
is ThemeFontFamily.DeviceBody -> context.getString(R.string.font_name_device_body)
is ThemeFontFamily.System -> fontFamily.name

View File

@@ -1,20 +1,20 @@
package de.mm20.launcher2.ui.theme
import android.content.Context
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.platform.LocalContext
import de.mm20.launcher2.preferences.Font
import androidx.compose.material3.MaterialExpressiveTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import de.mm20.launcher2.preferences.ui.UiSettings
import de.mm20.launcher2.themes.ThemeRepository
import de.mm20.launcher2.ui.locals.LocalDarkTheme
import de.mm20.launcher2.ui.theme.colorscheme.*
import de.mm20.launcher2.ui.theme.colorscheme.darkColorSchemeOf
import de.mm20.launcher2.ui.theme.colorscheme.lightColorSchemeOf
import de.mm20.launcher2.ui.theme.shapes.shapesOf
import de.mm20.launcher2.ui.theme.transparency.LocalTransparencyScheme
import de.mm20.launcher2.ui.theme.transparency.transparencySchemeOf
import de.mm20.launcher2.ui.theme.typography.DefaultTypography
import de.mm20.launcher2.ui.theme.typography.getDeviceDefaultTypography
import de.mm20.launcher2.ui.theme.typography.typographyOf
import kotlinx.coroutines.flow.flatMapLatest
import org.koin.compose.koinInject
@@ -74,10 +74,6 @@ fun LauncherTheme(
val transparencyScheme = transparencySchemeOf(themeTransparencies!!)
val font by remember { uiSettings.font }.collectAsState(
Font.Outfit
)
CompositionLocalProvider(
LocalDarkTheme provides darkTheme,
LocalTransparencyScheme provides transparencyScheme,
@@ -91,9 +87,3 @@ fun LauncherTheme(
}
}
fun getTypography(context: Context, font: Font?): Typography {
return when (font) {
Font.System -> getDeviceDefaultTypography(context)
else -> DefaultTypography
}
}

View File

@@ -1,43 +0,0 @@
package de.mm20.launcher2.ui.theme.typography
import androidx.compose.material3.Typography
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
fun makeTypography(
headlineFamily: FontFamily? = null,
bodyFamily: FontFamily? = null): Typography {
val baseTypography = Typography()
return Typography(
displayLarge = baseTypography.displayLarge.copy(fontFamily = headlineFamily, fontWeight = FontWeight.Medium),
displayLargeEmphasized = baseTypography.displayLarge.copy(fontFamily = headlineFamily, fontWeight = FontWeight.SemiBold),
displayMedium = baseTypography.displayMedium.copy(fontFamily = headlineFamily, fontWeight = FontWeight.Medium),
displayMediumEmphasized = baseTypography.displayMedium.copy(fontFamily = headlineFamily, fontWeight = FontWeight.SemiBold),
displaySmall = baseTypography.displaySmall.copy(fontFamily = headlineFamily, fontWeight = FontWeight.Medium),
displaySmallEmphasized = baseTypography.displaySmall.copy(fontFamily = headlineFamily, fontWeight = FontWeight.SemiBold),
headlineLarge = baseTypography.headlineLarge.copy(fontFamily = headlineFamily, fontWeight = FontWeight.SemiBold),
headlineLargeEmphasized = baseTypography.headlineLarge.copy(fontFamily = headlineFamily, fontWeight = FontWeight.Bold),
headlineMedium = baseTypography.headlineMedium.copy(fontFamily = headlineFamily, fontWeight = FontWeight.SemiBold),
headlineMediumEmphasized = baseTypography.headlineMedium.copy(fontFamily = headlineFamily, fontWeight = FontWeight.Bold),
headlineSmall = baseTypography.headlineSmall.copy(fontFamily = headlineFamily, fontWeight = FontWeight.SemiBold),
headlineSmallEmphasized = baseTypography.headlineSmall.copy(fontFamily = headlineFamily, fontWeight = FontWeight.Bold),
titleLarge = baseTypography.titleLarge.copy(fontFamily = headlineFamily, fontWeight = FontWeight.SemiBold),
titleLargeEmphasized = baseTypography.titleLargeEmphasized.copy(fontFamily = headlineFamily, fontWeight = FontWeight.Bold),
titleMedium = baseTypography.titleMedium.copy(fontFamily = headlineFamily, fontWeight = FontWeight.SemiBold),
titleMediumEmphasized = baseTypography.titleMediumEmphasized.copy(fontFamily = headlineFamily),
titleSmall = baseTypography.titleSmall.copy(fontFamily = headlineFamily, fontWeight = FontWeight.SemiBold),
titleSmallEmphasized = baseTypography.titleSmallEmphasized.copy(fontFamily = headlineFamily, fontWeight = FontWeight.Bold),
bodyLarge = baseTypography.bodyLarge.copy(fontFamily = bodyFamily),
bodyLargeEmphasized = baseTypography.bodyLargeEmphasized.copy(fontFamily = bodyFamily, fontWeight = FontWeight.Medium),
bodyMedium = baseTypography.bodyMedium.copy(fontFamily = bodyFamily),
bodyMediumEmphasized = baseTypography.bodyMediumEmphasized.copy(fontFamily = bodyFamily, fontWeight = FontWeight.Medium),
bodySmall = baseTypography.bodySmall.copy(fontFamily = bodyFamily),
bodySmallEmphasized = baseTypography.bodySmallEmphasized.copy(fontFamily = bodyFamily, fontWeight = FontWeight.Medium),
labelLarge = baseTypography.labelLarge.copy(fontFamily = headlineFamily, fontWeight = FontWeight.Medium),
labelLargeEmphasized = baseTypography.labelLargeEmphasized.copy(fontFamily = headlineFamily, fontWeight = FontWeight.SemiBold),
labelMedium = baseTypography.labelMedium.copy(fontFamily = headlineFamily, fontWeight = FontWeight.Medium),
labelMediumEmphasized = baseTypography.labelMediumEmphasized.copy(fontFamily = headlineFamily, fontWeight = FontWeight.SemiBold),
labelSmall = baseTypography.labelSmall.copy(fontFamily = headlineFamily, fontWeight = FontWeight.Medium),
labelSmallEmphasized = baseTypography.labelSmallEmphasized.copy(fontFamily = headlineFamily, fontWeight = FontWeight.SemiBold),
)
}

View File

@@ -1,5 +0,0 @@
package de.mm20.launcher2.ui.theme.typography
import de.mm20.launcher2.ui.theme.typography.fontfamily.Outfit
val DefaultTypography = makeTypography(headlineFamily = Outfit)

View File

@@ -1,10 +0,0 @@
package de.mm20.launcher2.ui.theme.typography
import android.content.Context
import androidx.compose.material3.Typography
import androidx.compose.ui.text.font.*
import de.mm20.launcher2.ui.theme.typography.fontfamily.getDeviceHeadlineFontFamily
fun getDeviceDefaultTypography(context: Context): Typography {
return makeTypography(headlineFamily = getDeviceHeadlineFontFamily(context))
}

View File

@@ -12,7 +12,8 @@ import androidx.compose.ui.unit.em
import androidx.compose.ui.unit.sp
import de.mm20.launcher2.themes.typography.DefaultEmphasizedTextStyles
import de.mm20.launcher2.themes.typography.DefaultTextStyles
import de.mm20.launcher2.ui.theme.typography.fontfamily.Outfit
import de.mm20.launcher2.ui.theme.typography.fontfamily.GoogleSansFlex
import de.mm20.launcher2.ui.theme.typography.fontfamily.GoogleSansFlexRound
import de.mm20.launcher2.ui.theme.typography.fontfamily.getDeviceBodyFontFamily
import de.mm20.launcher2.ui.theme.typography.fontfamily.getDeviceHeadlineFontFamily
import de.mm20.launcher2.themes.typography.FontFamily as ThemeFontFamily
@@ -316,7 +317,8 @@ fun fontFamilyOf(
fontFamily: ThemeFontFamily?
): FontFamily {
return when (fontFamily) {
is ThemeFontFamily.LauncherDefault -> Outfit
is ThemeFontFamily.LauncherDefault -> GoogleSansFlex
is ThemeFontFamily.LauncherDefaultRound -> GoogleSansFlexRound
is ThemeFontFamily.DeviceHeadline -> getDeviceHeadlineFontFamily(context)
is ThemeFontFamily.DeviceBody -> getDeviceBodyFontFamily(context)
is ThemeFontFamily.SansSerif -> FontFamily.SansSerif

View File

@@ -0,0 +1,16 @@
package de.mm20.launcher2.ui.theme.typography.fontfamily
import androidx.compose.ui.text.font.FontVariation
import de.mm20.launcher2.ui.R
val GoogleSansFlex = createVariableFontFamily(
R.font.google_sans_flex,
FontVariation.roundness(0f)
)
val GoogleSansFlexRound = createVariableFontFamily(
R.font.google_sans_flex,
FontVariation.roundness( 100f)
)

View File

@@ -1,19 +0,0 @@
package de.mm20.launcher2.ui.theme.typography.fontfamily
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import de.mm20.launcher2.ui.R
val Outfit = FontFamily(
Font(R.font.outfit_100, weight = FontWeight.Thin, style = FontStyle.Normal),
Font(R.font.outfit_200, weight = FontWeight.ExtraLight, style = FontStyle.Normal),
Font(R.font.outfit_300, weight = FontWeight.Light, style = FontStyle.Normal),
Font(R.font.outfit_400, weight = FontWeight.Normal, style = FontStyle.Normal),
Font(R.font.outfit_500, weight = FontWeight.Medium, style = FontStyle.Normal),
Font(R.font.outfit_600, weight = FontWeight.SemiBold, style = FontStyle.Normal),
Font(R.font.outfit_700, weight = FontWeight.Bold, style = FontStyle.Normal),
Font(R.font.outfit_800, weight = FontWeight.ExtraBold, style = FontStyle.Normal),
Font(R.font.outfit_900, weight = FontWeight.Black, style = FontStyle.Normal),
)

View File

@@ -0,0 +1,41 @@
package de.mm20.launcher2.ui.theme.typography.fontfamily
import androidx.annotation.FontRes
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontVariation
import androidx.compose.ui.text.font.FontWeight
internal fun FontVariation.roundness(roundness: Float): FontVariation.Setting {
return Setting("ROND", roundness)
}
internal fun createVariableFontFamily(@FontRes resId: Int, vararg settings: FontVariation.Setting): FontFamily {
val fonts = mutableListOf<Font>()
for (weight in 100..900 step 100) {
fonts += Font(
resId = resId,
weight = FontWeight(weight),
style = FontStyle.Normal,
variationSettings =
FontVariation.Settings(
weight = FontWeight(weight),
style = FontStyle.Normal,
*settings
)
)
fonts += Font(
resId = resId,
weight = FontWeight(weight),
style = FontStyle.Italic,
variationSettings =
FontVariation.Settings(
weight = FontWeight(weight),
style = FontStyle.Italic,
*settings
)
)
}
return FontFamily(fonts)
}