Skip to content

Commit

Permalink
Android: force em values to use the X.em format
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartinesp committed Jul 31, 2024
1 parent 465d232 commit 02cb61f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
16 changes: 8 additions & 8 deletions assets/android/src/TypographyTokens.kt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ object TypographyTokens {
fontWeight = FontWeight.W700,
lineHeight = 34.sp,
fontSize = 28.sp,
letterSpacing = 0em,
letterSpacing = 0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -121,7 +121,7 @@ object TypographyTokens {
fontWeight = FontWeight.W400,
lineHeight = 34.sp,
fontSize = 28.sp,
letterSpacing = 0em,
letterSpacing = 0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -130,7 +130,7 @@ object TypographyTokens {
fontWeight = FontWeight.W700,
lineHeight = 27.sp,
fontSize = 22.sp,
letterSpacing = 0em,
letterSpacing = 0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -139,7 +139,7 @@ object TypographyTokens {
fontWeight = FontWeight.W400,
lineHeight = 27.sp,
fontSize = 22.sp,
letterSpacing = 0em,
letterSpacing = 0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -148,7 +148,7 @@ object TypographyTokens {
fontWeight = FontWeight.W500,
lineHeight = 25.sp,
fontSize = 20.sp,
letterSpacing = 0em,
letterSpacing = 0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -157,7 +157,7 @@ object TypographyTokens {
fontWeight = FontWeight.W400,
lineHeight = 25.sp,
fontSize = 20.sp,
letterSpacing = 0em,
letterSpacing = 0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -166,7 +166,7 @@ object TypographyTokens {
fontWeight = FontWeight.W700,
lineHeight = 41.sp,
fontSize = 34.sp,
letterSpacing = 0em,
letterSpacing = 0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -175,7 +175,7 @@ object TypographyTokens {
fontWeight = FontWeight.W400,
lineHeight = 41.sp,
fontSize = 34.sp,
letterSpacing = 0em,
letterSpacing = 0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand Down
7 changes: 6 additions & 1 deletion src/transforms/kotlin/typography.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ export default {
if (propName === "fontFamily") {
output += "FontFamily.Default";
} else {
output += val;
const fixEmMatches = (val as string).match(/(\d+)em/);
if (fixEmMatches && fixEmMatches.length > 1) {
output += `${fixEmMatches[1]}.em`;
} else {
output += val;
}
}
output += ",\n";
}
Expand Down

0 comments on commit 02cb61f

Please sign in to comment.