Skip to content

Commit e71870f

Browse files
committed
fix: use FontStyle weight bounds
1 parent 1c47c10 commit e71870f

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTypefaceUtils.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
package com.facebook.react.views.text
99

1010
import android.content.Context
11-
import android.content.res.Configuration
1211
import android.content.res.AssetManager
12+
import android.content.res.Configuration
1313
import android.graphics.Typeface
14+
import android.graphics.fonts.FontStyle
1415
import android.os.Build
1516
import com.facebook.react.bridge.ReadableArray
1617
import com.facebook.react.common.ReactConstants
@@ -20,9 +21,6 @@ import kotlin.math.min
2021

2122
public object ReactTypefaceUtils {
2223

23-
private const val FONT_WEIGHT_MIN = 1
24-
private const val FONT_WEIGHT_MAX = 1000
25-
2624
@JvmStatic
2725
public fun parseFontWeight(fontWeightString: String?): Int =
2826
when (fontWeightString) {
@@ -142,7 +140,10 @@ public object ReactTypefaceUtils {
142140

143141
val baseTypeface = typeface ?: Typeface.DEFAULT
144142
val adjustedWeight =
145-
min(max(baseTypeface.weight + fontWeightAdjustment, FONT_WEIGHT_MIN), FONT_WEIGHT_MAX)
143+
min(
144+
max(baseTypeface.weight + fontWeightAdjustment, FontStyle.FONT_WEIGHT_MIN),
145+
FontStyle.FONT_WEIGHT_MAX,
146+
)
146147
val italic = baseTypeface.style and Typeface.ITALIC != 0
147148

148149
return Typeface.create(baseTypeface, adjustedWeight, italic)

0 commit comments

Comments
 (0)