Skip to content

Commit 940d506

Browse files
committed
fix(typography): update demi OTF to fix corrupt font metrics
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 88a52d7 commit 940d506

5 files changed

Lines changed: 15371 additions & 5 deletions

File tree

app/src/main/java/com/getcode/theme/Theme.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,5 +180,4 @@ fun inputColors() = TextFieldDefaults.textFieldColors(
180180
focusedIndicatorColor = Color.Transparent,
181181
unfocusedIndicatorColor = Color.Transparent,
182182
cursorColor = Color.White,
183-
184183
)

app/src/main/java/com/getcode/theme/Type.kt

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,31 @@ package com.getcode.theme
22

33
import androidx.compose.material.Typography
44
import androidx.compose.runtime.Composable
5+
import androidx.compose.ui.text.ExperimentalTextApi
6+
import androidx.compose.ui.text.PlatformTextStyle
57
import androidx.compose.ui.text.TextStyle
68
import androidx.compose.ui.text.font.Font
79
import androidx.compose.ui.text.font.FontFamily
10+
import androidx.compose.ui.text.font.FontVariation
811
import androidx.compose.ui.text.font.FontWeight
912
import androidx.compose.ui.text.style.TextAlign
1013
import androidx.compose.ui.unit.sp
1114
import com.getcode.R
1215

16+
@OptIn(ExperimentalTextApi::class)
1317
private val Avenir = FontFamily(
18+
Font(R.font.avenir_next_regular, FontWeight.Thin),
19+
Font(R.font.avenir_next_regular, FontWeight.ExtraLight),
1420
Font(R.font.avenir_next_regular, FontWeight.Light),
1521
Font(R.font.avenir_next_regular, FontWeight.Normal),
16-
Font(R.font.avenir_next_demi, FontWeight.Medium),
17-
Font(R.font.avenir_next_demi, FontWeight.SemiBold)
22+
Font(R.font.avenir_next_medium, FontWeight.Medium),
23+
Font(
24+
resId = R.font.avenir_next_demi,
25+
weight = FontWeight.SemiBold,
26+
),
27+
Font(R.font.avenir_next_demi, FontWeight.Bold),
28+
Font(R.font.avenir_next_demi, FontWeight.ExtraBold),
29+
Font(R.font.avenir_next_demi, FontWeight.Black)
1830
)
1931

2032
private val RobotoMono = FontFamily(
@@ -65,7 +77,7 @@ internal val typography = Typography(
6577
fontFamily = Avenir,
6678
fontSize = 20.sp,
6779
fontWeight = FontWeight.SemiBold,
68-
lineHeight = 26.sp
80+
lineHeight = 26.sp,
6981
),
7082
subtitle2 = TextStyle( //Screen Title
7183
fontFamily = Avenir,
@@ -119,4 +131,14 @@ val Typography.displayLarge: TextStyle
119131
@Composable get() = h1.copy(fontSize = 55.sp)
120132

121133
fun TextStyle.withRobotoMono(weight: FontWeight? = this.fontWeight) = with(RobotoMono, weight)
122-
fun TextStyle.with(fontFamily: FontFamily, weight: FontWeight? = this.fontWeight): TextStyle = copy(fontFamily = fontFamily, fontWeight = weight)
134+
fun TextStyle.with(fontFamily: FontFamily, weight: FontWeight? = this.fontWeight): TextStyle = copy(fontFamily = fontFamily, fontWeight = weight)
135+
136+
fun ascenderHeight(ascenderHeight: Float): FontVariation.Setting {
137+
require(ascenderHeight in 649f..854f) { "'Ascender Height' must be in 649f..854f" }
138+
return FontVariation.Setting("YTAS", ascenderHeight)
139+
}
140+
141+
fun counterWidth(counterWidth: Int): FontVariation.Setting {
142+
require(counterWidth in 323..603) { "'Counter width' must be in 323..603" }
143+
return FontVariation.Setting("XTRA", counterWidth.toFloat())
144+
}
141 KB
Binary file not shown.
63.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)