Skip to content

Instantly share code, notes, and snippets.

@Nike2406
Created December 18, 2024 10:42
Show Gist options
  • Save Nike2406/3ef5bd726ee4d47447d13155a0b36eab to your computer and use it in GitHub Desktop.
Save Nike2406/3ef5bd726ee4d47447d13155a0b36eab to your computer and use it in GitHub Desktop.
Preventing Font Scaling
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.sp
val TextUnit.nonScaledSp
@Composable
get() = (this.value / LocalDensity.current.fontScale).sp
// Example:
// appTypography.c11M.fontSize.nonScaledSp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment