Skip to content

Commit 1b430ec

Browse files
committed
🎨 Remove font scaling and fix text line heights
* 🎨 Remove custom font scaling logic. The system font scaling will now be used. * 🐛 Fix multiple share cards where text was being cut off due to `lineHeight = 0`. The `lineHeight` has been set to the respective `fontSize`.
1 parent 674d4dd commit 1b430ec

File tree

11 files changed

+34
-123
lines changed

11 files changed

+34
-123
lines changed

app/src/main/java/com/shub39/rush/presentation/components/RushBranding.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fun RushBranding(
4242
).fromPx(
4343
fontSize = 36,
4444
letterSpacing = 0,
45-
lineHeight = 0,
45+
lineHeight = 36,
4646
fontWeight = FontWeight.Bold
4747
)
4848
)

app/src/main/java/com/shub39/rush/presentation/components/RushTheme.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import com.shub39.rush.presentation.toMPaletteStyle
1717
@Composable
1818
fun RushTheme(
1919
theme: Theme,
20-
fontScale: Float = 1f,
2120
content: @Composable () -> Unit
2221
) {
2322
DynamicMaterialTheme(
@@ -35,7 +34,6 @@ fun RushTheme(
3534
style = theme.style.toMPaletteStyle(),
3635
typography = provideTypography(
3736
font = theme.font.toFontRes(),
38-
scale = fontScale
3937
),
4038
content = content
4139
)

app/src/main/java/com/shub39/rush/presentation/provideTypography.kt

Lines changed: 17 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -2,119 +2,33 @@ package com.shub39.rush.presentation
22

33
import androidx.compose.material3.Typography
44
import androidx.compose.runtime.Composable
5-
import androidx.compose.ui.text.TextStyle
65
import androidx.compose.ui.text.font.Font
76
import androidx.compose.ui.text.font.FontFamily
8-
import androidx.compose.ui.text.font.FontWeight
9-
import androidx.compose.ui.unit.sp
107
import com.shub39.rush.R
118

9+
val TYPOGRAPHY = Typography()
10+
1211
@Composable
1312
fun provideTypography(
14-
scale: Float = 1f,
1513
font: Int = R.font.poppins_regular
1614
): Typography {
1715
val selectedFont = FontFamily(Font(font))
1816

1917
return Typography(
20-
displayLarge = TextStyle(
21-
fontFamily = selectedFont,
22-
fontWeight = FontWeight.Black,
23-
fontSize = 57.sp * scale,
24-
lineHeight = 64.sp * scale,
25-
letterSpacing = -(0.25).sp,
26-
),
27-
displayMedium = TextStyle(
28-
fontFamily = selectedFont,
29-
fontWeight = FontWeight.Black,
30-
fontSize = 45.sp * scale,
31-
lineHeight = 52.sp * scale
32-
),
33-
displaySmall = TextStyle(
34-
fontFamily = selectedFont,
35-
fontWeight = FontWeight.Black,
36-
fontSize = 36.sp * scale,
37-
lineHeight = 44.sp * scale
38-
),
39-
headlineLarge = TextStyle(
40-
fontFamily = selectedFont,
41-
fontWeight = FontWeight.Bold,
42-
fontSize = 32.sp * scale,
43-
lineHeight = 40.sp * scale
44-
),
45-
headlineMedium = TextStyle(
46-
fontFamily = selectedFont,
47-
fontWeight = FontWeight.Bold,
48-
fontSize = 28.sp * scale,
49-
lineHeight = 36.sp * scale
50-
),
51-
headlineSmall = TextStyle(
52-
fontFamily = selectedFont,
53-
fontWeight = FontWeight.Bold,
54-
fontSize = 24.sp * scale,
55-
lineHeight = 32.sp * scale
56-
),
57-
titleLarge = TextStyle(
58-
fontFamily = selectedFont,
59-
fontWeight = FontWeight.Medium,
60-
fontSize = 22.sp * scale,
61-
lineHeight = 28.sp * scale
62-
),
63-
titleMedium = TextStyle(
64-
fontFamily = selectedFont,
65-
fontWeight = FontWeight.Medium,
66-
fontSize = 16.sp * scale,
67-
lineHeight = 24.sp * scale,
68-
letterSpacing = 0.15.sp
69-
),
70-
titleSmall = TextStyle(
71-
fontFamily = selectedFont,
72-
fontWeight = FontWeight.Medium,
73-
fontSize = 14.sp * scale,
74-
lineHeight = 20.sp * scale,
75-
letterSpacing = 0.1.sp
76-
),
77-
labelLarge = TextStyle(
78-
fontFamily = selectedFont,
79-
fontWeight = FontWeight.Bold,
80-
fontSize = 16.sp * scale,
81-
lineHeight = 16.sp * scale,
82-
letterSpacing = 0.1.sp
83-
),
84-
labelMedium = TextStyle(
85-
fontFamily = selectedFont,
86-
fontWeight = FontWeight.Bold,
87-
fontSize = 14.sp * scale,
88-
lineHeight = 14.sp * scale,
89-
letterSpacing = 0.5.sp
90-
),
91-
labelSmall = TextStyle(
92-
fontFamily = selectedFont,
93-
fontWeight = FontWeight.Medium,
94-
fontSize = 12.sp * scale,
95-
lineHeight = 12.sp * scale,
96-
letterSpacing = 0.5.sp
97-
),
98-
bodyLarge = TextStyle(
99-
fontFamily = selectedFont,
100-
fontWeight = FontWeight.Normal,
101-
fontSize = 16.sp * scale,
102-
lineHeight = 24.sp * scale,
103-
letterSpacing = 0.5.sp
104-
),
105-
bodyMedium = TextStyle(
106-
fontFamily = selectedFont,
107-
fontWeight = FontWeight.Normal,
108-
fontSize = 14.sp * scale,
109-
lineHeight = 20.sp * scale,
110-
letterSpacing = 0.25.sp
111-
),
112-
bodySmall = TextStyle(
113-
fontFamily = selectedFont,
114-
fontWeight = FontWeight.Normal,
115-
fontSize = 12.sp * scale,
116-
lineHeight = 16.sp * scale,
117-
letterSpacing = 0.4.sp
118-
)
18+
displayLarge = TYPOGRAPHY.displayLarge.copy(fontFamily = selectedFont),
19+
displayMedium = TYPOGRAPHY.displayMedium.copy(fontFamily = selectedFont),
20+
displaySmall = TYPOGRAPHY.displaySmall.copy(fontFamily = selectedFont),
21+
headlineLarge = TYPOGRAPHY.headlineLarge.copy(fontFamily = selectedFont),
22+
headlineMedium = TYPOGRAPHY.headlineMedium.copy(fontFamily = selectedFont),
23+
headlineSmall = TYPOGRAPHY.headlineSmall.copy(fontFamily = selectedFont),
24+
titleLarge = TYPOGRAPHY.titleLarge.copy(fontFamily = selectedFont),
25+
titleMedium = TYPOGRAPHY.titleMedium.copy(fontFamily = selectedFont),
26+
titleSmall = TYPOGRAPHY.titleSmall.copy(fontFamily = selectedFont),
27+
bodyLarge = TYPOGRAPHY.bodyLarge.copy(fontFamily = selectedFont),
28+
bodyMedium = TYPOGRAPHY.bodyMedium.copy(fontFamily = selectedFont),
29+
bodySmall = TYPOGRAPHY.bodySmall.copy(fontFamily = selectedFont),
30+
labelLarge = TYPOGRAPHY.labelLarge.copy(fontFamily = selectedFont),
31+
labelMedium = TYPOGRAPHY.labelMedium.copy(fontFamily = selectedFont),
32+
labelSmall = TYPOGRAPHY.labelSmall.copy(fontFamily = selectedFont),
11933
)
12034
}

app/src/main/java/com/shub39/rush/presentation/share/component/cards/AlbumArt.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ fun AlbumArt(
9696
style = MaterialTheme.typography.headlineLarge.fromPx(
9797
fontSize = 30,
9898
letterSpacing = 0,
99-
lineHeight = 0
99+
lineHeight = 30
100100
).copy(textAlign = TextAlign.Center),
101101
maxLines = 1,
102102
overflow = TextOverflow.Ellipsis
@@ -132,7 +132,7 @@ private fun Preview() {
132132
song = SongDetails(
133133
title = "Test Song",
134134
artist = "Eminem",
135-
null, ""
135+
null, "as"
136136
),
137137
cardColors = CardDefaults.cardColors(
138138
contentColor = MaterialTheme.colorScheme.onPrimary,

app/src/main/java/com/shub39/rush/presentation/share/component/cards/ChatCard.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fun ChatCard(
9090
fontWeight = FontWeight.ExtraBold,
9191
fontSize = 28,
9292
letterSpacing = 0,
93-
lineHeight = 0,
93+
lineHeight = 28,
9494
),
9595
maxLines = 1,
9696
overflow = TextOverflow.Ellipsis
@@ -101,7 +101,7 @@ fun ChatCard(
101101
style = MaterialTheme.typography.bodySmall.fromPx(
102102
fontSize = 24,
103103
letterSpacing = 0,
104-
lineHeight = 0,
104+
lineHeight = 24,
105105
),
106106
maxLines = 1,
107107
overflow = TextOverflow.Ellipsis

app/src/main/java/com/shub39/rush/presentation/share/component/cards/CoupletShareCard.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ fun CoupletShareCard(
129129
fontWeight = FontWeight.ExtraBold,
130130
fontSize = 28,
131131
letterSpacing = 0,
132-
lineHeight = 0,
132+
lineHeight = 28,
133133
),
134134
maxLines = 1,
135135
overflow = TextOverflow.Ellipsis
@@ -140,7 +140,7 @@ fun CoupletShareCard(
140140
style = MaterialTheme.typography.bodySmall.fromPx(
141141
fontSize = 24,
142142
letterSpacing = 0,
143-
lineHeight = 0,
143+
lineHeight = 24,
144144
),
145145
maxLines = 1,
146146
overflow = TextOverflow.Ellipsis

app/src/main/java/com/shub39/rush/presentation/share/component/cards/MessyCard.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ fun MessyCard(
138138
fontWeight = FontWeight.ExtraBold,
139139
fontSize = 28,
140140
letterSpacing = 0,
141-
lineHeight = 0,
141+
lineHeight = 28,
142142
),
143143
maxLines = 1,
144144
overflow = TextOverflow.Ellipsis
@@ -149,7 +149,7 @@ fun MessyCard(
149149
style = MaterialTheme.typography.bodySmall.fromPx(
150150
fontSize = 26,
151151
letterSpacing = 0,
152-
lineHeight = 0,
152+
lineHeight = 26,
153153
),
154154
maxLines = 1,
155155
overflow = TextOverflow.Ellipsis

app/src/main/java/com/shub39/rush/presentation/share/component/cards/QuoteShareCard.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fun QuoteShareCard(
117117
fontWeight = FontWeight.ExtraBold,
118118
fontSize = 28,
119119
letterSpacing = 0,
120-
lineHeight = 0,
120+
lineHeight = 28,
121121
),
122122
maxLines = 1,
123123
overflow = TextOverflow.Ellipsis
@@ -128,7 +128,7 @@ fun QuoteShareCard(
128128
style = MaterialTheme.typography.bodySmall.fromPx(
129129
fontSize = 26,
130130
letterSpacing = 0,
131-
lineHeight = 0,
131+
lineHeight = 26,
132132
),
133133
maxLines = 1,
134134
overflow = TextOverflow.Ellipsis

app/src/main/java/com/shub39/rush/presentation/share/component/cards/RushedShareCard.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ fun RushedShareCard(
124124
style = MaterialTheme.typography.titleMedium.fromPx(
125125
fontSize = 32,
126126
letterSpacing = 0,
127-
lineHeight = 0,
127+
lineHeight = 32,
128128
fontWeight = FontWeight.Bold
129129
),
130130
overflow = TextOverflow.Ellipsis
@@ -134,7 +134,7 @@ fun RushedShareCard(
134134
style = MaterialTheme.typography.bodySmall.fromPx(
135135
fontSize = 24,
136136
letterSpacing = 0,
137-
lineHeight = 0
137+
lineHeight = 24
138138
),
139139
color = cardColors.contentColor,
140140
maxLines = 1,

app/src/main/java/com/shub39/rush/presentation/share/component/cards/SpotifyShareCard.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fun SpotifyShareCard(
8484
fontWeight = FontWeight.ExtraBold,
8585
fontSize = 28,
8686
letterSpacing = 0,
87-
lineHeight = 0,
87+
lineHeight = 28,
8888
),
8989
maxLines = 1,
9090
overflow = TextOverflow.Ellipsis
@@ -93,10 +93,9 @@ fun SpotifyShareCard(
9393
Text(
9494
text = song.artist,
9595
style = MaterialTheme.typography.bodySmall.fromPx(
96-
fontWeight = FontWeight.Bold,
9796
fontSize = 26,
9897
letterSpacing = 0,
99-
lineHeight = 0,
98+
lineHeight = 26,
10099
),
101100
maxLines = 1,
102101
overflow = TextOverflow.Ellipsis

0 commit comments

Comments
 (0)