From 6bb91c480b9247a81d425cadc9430fb94caf557a Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Wed, 23 Sep 2026 14:13:46 +0200 Subject: [PATCH] Pack wrapped lines onto the font's own extent (#190) --- .../calendula/ui/common/CalendarText.kt | 16 ++++++++++++++++ .../calendula/ui/month/MonthScreen.kt | 7 +------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/CalendarText.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/CalendarText.kt index 125c492..cec1580 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/CalendarText.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/CalendarText.kt @@ -30,6 +30,22 @@ private const val LINE_SAMPLE = "Ag" /** [this] with Material's outer leading trimmed — see [TrimmedLines]. */ fun TextStyle.trimmedLines(): TextStyle = copy(lineHeightStyle = TrimmedLines) +/** + * [style] with its wrapped lines packed onto the face's own extent instead of + * Material's line box. + * + * [trimmedLines] takes the leading off the outer edges of a run of text; this + * takes it from between the lines as well, which is the half a wrapped event + * title pays for twice over. The line height is *measured* from the font rather + * than picked, so it lands exactly on the face's ascent-plus-descent and can + * never be short enough to overlap — whatever the font picker has loaded (#190). + */ +@Composable +fun rememberPackedLines(style: TextStyle): TextStyle { + val line = rememberTrimmedLineHeight(style) + return with(LocalDensity.current) { style.trimmedLines().copy(lineHeight = line.toSp()) } +} + /** What one trimmed line of [style] actually draws in. */ @Composable fun rememberTrimmedLineHeight(style: TextStyle): Dp { diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/month/MonthScreen.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/month/MonthScreen.kt index 9634943..20f94e0 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/month/MonthScreen.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/month/MonthScreen.kt @@ -761,12 +761,7 @@ internal fun WeekdayHeader(weekStart: DayOfWeek, showWeekNumbers: Boolean) { } } -/** - * One lane of a day cell. Sized to a trimmed chip line rather than to Material's - * line box, so the three lanes a cell can draw cost it nine dp less and a - * six-row month keeps its third chip instead of demoting it to a dot (#190). - */ -private val EVENT_ROW_HEIGHT = 17.dp +private val EVENT_ROW_HEIGHT = 20.dp private val DAY_NUMBER_HEIGHT = 22.dp /** Width of the optional left calendar-week gutter (#25); narrow, since it only * seats a one- or two-digit week number in a full-height tonal pill. */