Use small font & min letterspacing when syllabes overlaps

This commit is contained in:
Hasinjato 2026-07-10 13:39:19 +03:00
parent 7b205f5390
commit f32147f24d
2 changed files with 27 additions and 3 deletions

View file

@ -28,7 +28,6 @@ import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.input.pointer.pointerInput
@ -690,6 +689,31 @@ fun LazyVerticalGridTUO(
val totalSyllables = sharedScreenModel.synchronizedSyllables.value.size
//println("Sync complète effectuée SUR stz: ${sharedScreenModel.stanza.value}! Total colonnes : $totalSyllables")
}
val textMeasurer = rememberTextMeasurer()
val containerWidthDp = gridWidthDp / gridColumnCount
val REGEX_CLEAN_PREFIX = Regex("(\\d+\\.)+")
val isAnySyllableTooLong = remember(currentStanza, gridWidthDp, gridColumnCount) {
val allMeasuresSyllables = tuoList.drop(1).chunked(gridColumnCount).map { measureTUOss ->
measureTUOss.map { it.getSingleSyllable(currentStanza) }.map { column ->
column.map { syllable -> syllable.replace(REGEX_CLEAN_PREFIX, "").trim() }
}
}
allMeasuresSyllables.any { measure ->
measure.any { column ->
column.any { syl ->
val textLayoutResult = textMeasurer.measure(
text = syl,
maxLines = 1,
softWrap = false
)
val textWidthDp = with(density) { textLayoutResult.size.width.toDp() }
textWidthDp > containerWidthDp
}
}
}
}
if (!isLayoutReady) {
Box(
modifier = Modifier
@ -1095,7 +1119,7 @@ fun LazyVerticalGridTUO(
(index == 0) -> MaterialTheme.colorScheme.onBackground
else -> MaterialTheme.colorScheme.onBackground
},
fontSize = MaterialTheme.typography.titleMedium.fontSize,
fontSize = if(isAnySyllableTooLong) MaterialTheme.typography.labelLarge.fontSize else MaterialTheme.typography.titleMedium.fontSize
),
onTextLayout = { txtLayoutRes ->
textWidth = with(density) { txtLayoutRes.size.width.toDp() }

View file

@ -172,7 +172,7 @@ fun FeufaroTheme(
labelLarge = TextStyle(
fontSize = (baseSize - 0.5f).sp,
letterSpacing = 0.1.sp
letterSpacing = 0.03.sp
),
labelMedium = TextStyle(
fontSize = (baseSize - 2.5f).sp,