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)
}

View File

@@ -121,12 +121,11 @@ val OpenSourceLicenses = arrayOf(
url = "https://insert-koin.io/"
),
OpenSourceLibrary(
name = "Outfit",
name = "Google Sans Flex",
description = "A geometric sans serif typeface",
copyrightNote = "Copyright 2021 The Outfit Project Authors",
licenseName = R.string.open_font_license_name,
licenseText = R.raw.license_ofl,
url = "https://github.com/Outfitio/Outfit-Fonts"
url = "https://fonts.google.com/specimen/Google+Sans+Flex"
),
OpenSourceLibrary(
name = "Coil",

Binary file not shown.

View File

@@ -24,7 +24,6 @@ data class LauncherSettingsData internal constructor(
val uiTypographyId: UUID = UUID(0L, 0L),
val uiCompatModeColors: Boolean = false,
val uiFont: Font = Font.Outfit,
@Deprecated("No longer in use, only used for migration")
val uiBaseLayout: BaseLayout = BaseLayout.PullDown,
val uiOrientation: ScreenOrientation = ScreenOrientation.Auto,
@@ -220,12 +219,6 @@ enum class ColorScheme {
System,
}
@Serializable
enum class Font {
Outfit,
System,
}
internal enum class ClockWidgetStyleEnum {
Digital1,
Digital2,

View File

@@ -1,7 +1,6 @@
package de.mm20.launcher2.preferences.ui
import de.mm20.launcher2.preferences.ColorScheme
import de.mm20.launcher2.preferences.Font
import de.mm20.launcher2.preferences.IconShape
import de.mm20.launcher2.preferences.LauncherDataStore
import de.mm20.launcher2.preferences.ScreenOrientation
@@ -329,17 +328,6 @@ class UiSettings internal constructor(
}
}
val font
get() = launcherDataStore.data.map {
it.uiFont
}.distinctUntilChanged()
fun setFont(font: Font) {
launcherDataStore.update {
it.copy(uiFont = font)
}
}
fun setColorScheme(colorScheme: ColorScheme) {
launcherDataStore.update {
it.copy(uiColorScheme = colorScheme)

View File

@@ -16,4 +16,5 @@ val SemiTransparentId = UUID(0L, 1L)
val SystemFontId = UUID(0L, 1L)
val MonospaceId = UUID(0L, 2L)
val SerifId = UUID(0L, 3L)
val SerifId = UUID(0L, 3L)
val RoundedTypographyId = UUID(0L, 4L)

View File

@@ -29,7 +29,7 @@ class FontManager(
val deviceBodyExists = deviceBodyResId != 0 &&
context.resources.getString(deviceBodyResId).isNotBlank()
return FontList(
builtIn = listOf(FontFamily.LauncherDefault),
builtIn = listOf(FontFamily.LauncherDefault, FontFamily.LauncherDefaultRound),
generic = listOf(
FontFamily.SansSerif,
FontFamily.Serif,

View File

@@ -185,6 +185,10 @@ sealed interface FontFamily {
@SerialName("launcher_default")
data object LauncherDefault : FontFamily
@Serializable
@SerialName("launcher_default_round")
data object LauncherDefaultRound : FontFamily
@Serializable
@SerialName("device_headline")
data object DeviceHeadline : FontFamily

View File

@@ -5,6 +5,7 @@ import de.mm20.launcher2.database.AppDatabase
import de.mm20.launcher2.themes.DefaultThemeId
import de.mm20.launcher2.themes.MonospaceId
import de.mm20.launcher2.themes.R
import de.mm20.launcher2.themes.RoundedTypographyId
import de.mm20.launcher2.themes.SerifId
import de.mm20.launcher2.themes.SystemFontId
import kotlinx.coroutines.CoroutineScope
@@ -30,6 +31,7 @@ class TypographyRepository(
fun get(id: UUID): Flow<Typography?> {
if (id == DefaultThemeId) return flowOf(default)
if (id == RoundedTypographyId) return flowOf(defaultRound)
if (id == SystemFontId) return flowOf(systemFont)
if (id == SerifId) return flowOf(serif)
if (id == MonospaceId) return flowOf(monospace)
@@ -63,6 +65,7 @@ class TypographyRepository(
private fun getBuiltIn(): List<Typography> {
return listOf(
default,
defaultRound,
systemFont,
serif,
monospace,
@@ -73,10 +76,23 @@ class TypographyRepository(
get() = Typography(
id = DefaultThemeId,
builtIn = true,
name = "Outfit",
name = "Google Sans",
fonts = mapOf(
"brand" to FontFamily.LauncherDefault,
"plain" to null,
"plain" to FontFamily.LauncherDefault,
),
styles = DefaultTextStyles,
emphasizedStyles = DefaultEmphasizedTextStyles,
)
private val defaultRound: Typography
get() = Typography(
id = RoundedTypographyId,
builtIn = true,
name = "Google Sans (Rounded)",
fonts = mapOf(
"brand" to FontFamily.LauncherDefaultRound,
"plain" to FontFamily.LauncherDefaultRound,
),
styles = DefaultTextStyles,
emphasizedStyles = DefaultEmphasizedTextStyles,