diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/theme/Type.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/theme/Type.kt index 239374b..cc3e18e 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/theme/Type.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/theme/Type.kt @@ -1,10 +1,24 @@ package de.jeanlucmakiola.calendula.ui.theme import androidx.compose.material3.Typography +import androidx.compose.ui.unit.sp /** - * Default Material 3 Expressive typography. Custom font + tuned scale will - * land in a later UI-design iteration; the defaults are intentional for V1 - * scaffolding to keep the foundation lean. + * Tracking the two label roles the calendar grids are set in. Material gives + * both 0.5sp, tuned for isolated UI labels with room around them; a month chip + * is a text box some 37dp wide, where 0.5sp on an 11sp glyph spends most of a + * character on spacing alone. 0.1sp is what Material itself sets labelLarge to, + * so the label family stays coherent (#190). */ -val CalendulaTypography = Typography() +private val LabelTracking = 0.1.sp + +/** + * Material 3 Expressive typography with the label roles' tracking tightened. + * Everything else is the default scale. + */ +val CalendulaTypography: Typography = Typography().let { base -> + base.copy( + labelMedium = base.labelMedium.copy(letterSpacing = LabelTracking), + labelSmall = base.labelSmall.copy(letterSpacing = LabelTracking), + ) +} diff --git a/app/src/test/java/de/jeanlucmakiola/calendula/ui/theme/FontsTest.kt b/app/src/test/java/de/jeanlucmakiola/calendula/ui/theme/FontsTest.kt index ab84941..8b0766f 100644 --- a/app/src/test/java/de/jeanlucmakiola/calendula/ui/theme/FontsTest.kt +++ b/app/src/test/java/de/jeanlucmakiola/calendula/ui/theme/FontsTest.kt @@ -1,5 +1,6 @@ package de.jeanlucmakiola.calendula.ui.theme +import androidx.compose.ui.unit.sp import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test @@ -48,6 +49,19 @@ class FontsTest { assertThat(typography.labelSmall.fontFamily).isEqualTo(plain) } + @Test + fun `picking a font keeps the tightened label tracking`() { + // The font picker only swaps the family; the tracking the grids are laid + // out against has to survive it (#190). + val typography = calendulaTypography( + brand = BundledFont.Lora.family, + plain = BundledFont.AtkinsonHyperlegible.family, + ) + + assertThat(typography.labelSmall.letterSpacing).isEqualTo(0.1.sp) + assertThat(typography.labelMedium.letterSpacing).isEqualTo(0.1.sp) + } + @Test fun `a null role keeps that role's default family while the other is applied`() { val plain = BundledFont.Lora.family