Tighten label tracking so the grids fit more text (#190)
This commit is contained in:
@@ -1,10 +1,24 @@
|
|||||||
package de.jeanlucmakiola.calendula.ui.theme
|
package de.jeanlucmakiola.calendula.ui.theme
|
||||||
|
|
||||||
import androidx.compose.material3.Typography
|
import androidx.compose.material3.Typography
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Material 3 Expressive typography. Custom font + tuned scale will
|
* Tracking the two label roles the calendar grids are set in. Material gives
|
||||||
* land in a later UI-design iteration; the defaults are intentional for V1
|
* both 0.5sp, tuned for isolated UI labels with room around them; a month chip
|
||||||
* scaffolding to keep the foundation lean.
|
* 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),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package de.jeanlucmakiola.calendula.ui.theme
|
package de.jeanlucmakiola.calendula.ui.theme
|
||||||
|
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
@@ -48,6 +49,19 @@ class FontsTest {
|
|||||||
assertThat(typography.labelSmall.fontFamily).isEqualTo(plain)
|
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
|
@Test
|
||||||
fun `a null role keeps that role's default family while the other is applied`() {
|
fun `a null role keeps that role's default family while the other is applied`() {
|
||||||
val plain = BundledFont.Lora.family
|
val plain = BundledFont.Lora.family
|
||||||
|
|||||||
Reference in New Issue
Block a user