diff --git a/GITHUB_CHANGELOG.md b/GITHUB_CHANGELOG.md index 95ed4d2b0f..39e6498fb1 100644 --- a/GITHUB_CHANGELOG.md +++ b/GITHUB_CHANGELOG.md @@ -15,6 +15,7 @@ This is a developer-focused change log: * Fix allapps navigation * Fix folder navigation (TODO) * Enable Material Expressive Folder Expansion animation flag +* Move to Google Sans Flex font (TODO) ### 🥞 Snapshot 9 (Development 4 Release 1) diff --git a/lawnchair/res/font/googlesansflex_variable.ttf b/lawnchair/res/font/googlesansflex_variable.ttf new file mode 100644 index 0000000000..83f272d227 Binary files /dev/null and b/lawnchair/res/font/googlesansflex_variable.ttf differ diff --git a/lawnchair/src/app/lawnchair/font/FontCache.kt b/lawnchair/src/app/lawnchair/font/FontCache.kt index ca60a9c1b0..1ce1b42a2b 100644 --- a/lawnchair/src/app/lawnchair/font/FontCache.kt +++ b/lawnchair/src/app/lawnchair/font/FontCache.kt @@ -75,10 +75,10 @@ class FontCache @Inject constructor( .toList() } - val uiRegular = ResourceFont(context, R.font.inter_regular, "Inter v3 " + context.getString(R.string.font_weight_regular)) - val uiMedium = ResourceFont(context, R.font.inter_medium, "Inter v3 " + context.getString(R.string.font_weight_medium)) - val uiText = ResourceFont(context, R.font.inter_regular, "Inter v3 " + context.getString(R.string.font_weight_regular)) - val uiTextMedium = ResourceFont(context, R.font.inter_medium, "Inter v3 " + context.getString(R.string.font_weight_medium)) + val uiRegular = ResourceFont(context, R.font.googlesansflex_variable, "Google Sans Flex " + context.getString(R.string.font_weight_regular)) + val uiMedium = ResourceFont(context, R.font.googlesansflex_variable, "Google Sans Flex " + context.getString(R.string.font_weight_medium)) + val uiText = ResourceFont(context, R.font.googlesansflex_variable, "Google Sans Flex " + context.getString(R.string.font_weight_regular)) + val uiTextMedium = ResourceFont(context, R.font.googlesansflex_variable, "Google Sans Flex " + context.getString(R.string.font_weight_medium)) suspend fun getTypeface(font: Font): Typeface? { return loadFontAsync(font).await()?.typeface diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/FontSelectionPreference.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/FontSelectionPreference.kt index 41e4240980..f023e04984 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/FontSelectionPreference.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/FontSelectionPreference.kt @@ -76,12 +76,12 @@ fun FontSelection( list.add(FontCache.Family(FontCache.SystemFont("sans-serif"))) list.add(FontCache.Family(FontCache.SystemFont("sans-serif-medium"))) list.add(FontCache.Family(FontCache.SystemFont("sans-serif-condensed"))) - val interVariants = HashMap() - interVariants["regular"] = FontCache.ResourceFont(context, R.font.inter_regular, "Inter v3 " + context.getString(R.string.font_weight_regular)) - interVariants["500"] = FontCache.ResourceFont(context, R.font.inter_medium, "Inter v3 " + context.getString(R.string.font_weight_medium)) - interVariants["600"] = FontCache.ResourceFont(context, R.font.inter_semi_bold, "Inter v3 " + context.getString(R.string.font_weight_semi_bold)) - interVariants["700"] = FontCache.ResourceFont(context, R.font.inter_bold, "Inter v3 " + context.getString(R.string.font_weight_bold)) - list.add(FontCache.Family("Inter v3", interVariants)) + val googleSansFlexVariants = HashMap() + googleSansFlexVariants["regular"] = FontCache.ResourceFont(context, R.font.googlesansflex_variable, "Google Sans Flex " + context.getString(R.string.font_weight_regular)) + googleSansFlexVariants["500"] = FontCache.ResourceFont(context, R.font.googlesansflex_variable, "Google Sans Flex " + context.getString(R.string.font_weight_medium)) + googleSansFlexVariants["600"] = FontCache.ResourceFont(context, R.font.googlesansflex_variable, "Google Sans Flex " + context.getString(R.string.font_weight_semi_bold)) + googleSansFlexVariants["700"] = FontCache.ResourceFont(context, R.font.googlesansflex_variable, "Google Sans Flex " + context.getString(R.string.font_weight_bold)) + list.add(FontCache.Family("Google Sans Flex", googleSansFlexVariants)) GoogleFontsListing.INSTANCE.get(context).getFonts().mapTo(list) { font -> val variantsMap = HashMap() val variants = font.variants.toTypedArray() diff --git a/lawnchair/src/app/lawnchair/ui/theme/Type.kt b/lawnchair/src/app/lawnchair/ui/theme/Type.kt index 63d450ce94..3f5008599a 100644 --- a/lawnchair/src/app/lawnchair/ui/theme/Type.kt +++ b/lawnchair/src/app/lawnchair/ui/theme/Type.kt @@ -17,34 +17,58 @@ package app.lawnchair.ui.theme import androidx.compose.material3.Typography +import androidx.compose.ui.text.ExperimentalTextApi import androidx.compose.ui.text.font.Font import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontVariation import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.sp import com.android.launcher3.R +import kotlin.require -private val InterFontFamily = FontFamily( - Font(R.font.inter_regular, FontWeight.Normal), - Font(R.font.inter_medium, FontWeight.Medium), - Font(R.font.inter_semi_bold, FontWeight.SemiBold), - Font(R.font.inter_bold, FontWeight.Bold), +@OptIn(ExperimentalTextApi::class) +private val GoogleSansFlexNormal = FontFamily( + Font(R.font.googlesansflex_variable, variationSettings = FontVariation.Settings( + FontVariation.weight(FontWeight.Normal.weight), + round(100) + )), ) +@OptIn(ExperimentalTextApi::class) +private val GoogleSansFlexMedium = FontFamily( + Font(R.font.googlesansflex_variable, variationSettings = FontVariation.Settings( + FontVariation.weight(FontWeight.Medium.weight), + round(100) + )), +) + +/** + * Typographic feature axis for round (ROND) variations, Integer form only as ROND only go up by 1 step + * + * [OpenType Variable Axes Definition](https://fonts.google.com/variablefonts#axis-definitions) + **/ +private fun round(ROND: Int): FontVariation.Setting { + val featureTagType = "ROND" + + require(ROND in 0..100) { "'Round' must be in 0..100" } + return FontVariation.Setting(featureTagType, ROND.toFloat()) +} + private val base = Typography() val Typography = Typography( - displayLarge = base.displayLarge.copy(fontFamily = InterFontFamily), - displayMedium = base.displayMedium.copy(fontFamily = InterFontFamily), - displaySmall = base.displaySmall.copy(fontFamily = InterFontFamily), - headlineLarge = base.headlineLarge.copy(fontFamily = InterFontFamily), - headlineMedium = base.headlineMedium.copy(fontFamily = InterFontFamily), - headlineSmall = base.headlineSmall.copy(fontFamily = InterFontFamily), - titleLarge = base.titleLarge.copy(fontFamily = InterFontFamily), - titleMedium = base.titleMedium.copy(fontFamily = InterFontFamily), - titleSmall = base.titleSmall.copy(fontFamily = InterFontFamily), - bodyLarge = base.bodyLarge.copy(fontFamily = InterFontFamily, letterSpacing = 0.sp), - bodyMedium = base.bodyMedium.copy(fontFamily = InterFontFamily, letterSpacing = 0.1.sp), - bodySmall = base.bodySmall.copy(fontFamily = InterFontFamily), - labelLarge = base.labelLarge.copy(fontFamily = InterFontFamily), - labelMedium = base.labelMedium.copy(fontFamily = InterFontFamily), - labelSmall = base.labelSmall.copy(fontFamily = InterFontFamily), + displayLarge = base.displayLarge.copy(fontFamily = GoogleSansFlexNormal), + displayMedium = base.displayMedium.copy(fontFamily = GoogleSansFlexNormal), + displaySmall = base.displaySmall.copy(fontFamily = GoogleSansFlexNormal), + headlineLarge = base.headlineLarge.copy(fontFamily = GoogleSansFlexNormal), + headlineMedium = base.headlineMedium.copy(fontFamily = GoogleSansFlexNormal), + headlineSmall = base.headlineSmall.copy(fontFamily = GoogleSansFlexNormal), + titleLarge = base.titleLarge.copy(fontFamily = GoogleSansFlexNormal), + titleMedium = base.titleMedium.copy(fontFamily = GoogleSansFlexMedium), + titleSmall = base.titleSmall.copy(fontFamily = GoogleSansFlexMedium), + bodyLarge = base.bodyLarge.copy(fontFamily = GoogleSansFlexNormal, letterSpacing = 0.sp), + bodyMedium = base.bodyMedium.copy(fontFamily = GoogleSansFlexNormal, letterSpacing = 0.1.sp), + bodySmall = base.bodySmall.copy(fontFamily = GoogleSansFlexNormal), + labelLarge = base.labelLarge.copy(fontFamily = GoogleSansFlexMedium), + labelMedium = base.labelMedium.copy(fontFamily = GoogleSansFlexMedium), + labelSmall = base.labelSmall.copy(fontFamily = GoogleSansFlexMedium), ) diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 5931295c84..0952ca5cc6 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -707,7 +707,7 @@ public class DeviceProfile { // Load the default font to use on notification dots Typeface typeface = null; if (showNotificationCount) { - typeface = ResourcesCompat.getFont(context, R.font.inter_regular); + typeface = ResourcesCompat.getFont(context, R.font.googlesansflex_variable); } // Load dot color @@ -720,7 +720,6 @@ public class DeviceProfile { int countColor = counterColorOption.getColorPreferenceEntry().getLightColor().invoke(context); // This is done last, after iconSizePx is calculated above. - // Lawnchair-TODO: dotRendererCache? mDotRendererWorkSpace = createDotRenderer(themeManager, iconSizePx, dotRendererCache, showNotificationCount, typeface, dotColor, countColor); mDotRendererAllApps = createDotRenderer(themeManager, getAllAppsProfile().getIconSizePx(), dotRendererCache, showNotificationCount, typeface, dotColor, countColor);