From d5220549b677c04a849e76f7a422b7a0da08bab1 Mon Sep 17 00:00:00 2001 From: Han Yin Date: Tue, 9 Sep 2025 13:55:42 -0700 Subject: [PATCH] UI: fix the font size auto scaling for ArmFeaturesVisualizer --- .../example/llama/ui/components/ArmFeaturesVisualizer.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/llama.android/app/src/main/java/com/example/llama/ui/components/ArmFeaturesVisualizer.kt b/examples/llama.android/app/src/main/java/com/example/llama/ui/components/ArmFeaturesVisualizer.kt index 584e653f6e..b9e227c7df 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/ui/components/ArmFeaturesVisualizer.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/ui/components/ArmFeaturesVisualizer.kt @@ -3,6 +3,7 @@ package com.example.llama.ui.components import android.llama.cpp.ArmFeature import android.llama.cpp.ArmFeaturesMapper.DisplayItem import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.text.TextAutoSize import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MultiChoiceSegmentedButtonRow import androidx.compose.material3.SegmentedButton @@ -19,6 +20,7 @@ import kotlin.math.sqrt @Composable fun ArmFeaturesVisualizer( supportedFeatures: List, + autoSizeMinScaling: Float = 0.5f, onFeatureClick: ((ArmFeature) -> Unit)? = null ) { // Segmented Button Row for Features @@ -40,7 +42,12 @@ fun ArmFeaturesVisualizer( ) { Text( text = item.feature.displayName, + autoSize = TextAutoSize.StepBased( + minFontSize = MaterialTheme.typography.labelSmall.fontSize * autoSizeMinScaling, + maxFontSize = MaterialTheme.typography.labelSmall.fontSize + ), style = MaterialTheme.typography.labelSmall, + maxLines = 1, fontWeight = if (item.isSupported) { FontWeight.Medium } else {