Skip to content

Commit

Permalink
fix: handle invalid example with fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
matinzd committed May 25, 2024
1 parent 21394d2 commit e63e994
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class CustomStyleSpan(
}

public companion object {
private val TAG = CustomStyleSpan::class.simpleName
private fun apply(
paint: Paint,
style: Int,
Expand All @@ -76,7 +77,11 @@ public class CustomStyleSpan(
fontFeatureSettings = fontFeatureSettingsParam
setTypeface(typeface)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
fontVariationSettings = fontVariationSettingsParam
try {
fontVariationSettings = fontVariationSettingsParam
} catch (e: Exception) {
// Do nothing
}
}
isSubpixelText = true
}
Expand Down
12 changes: 11 additions & 1 deletion packages/rn-tester/js/examples/Text/TextExample.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,17 @@ function FontVariationSettingsExample(props: {}): React.Node {
</Text>
))}

<View style={{marginVertical: 12}} />
<View style={{marginVertical: 6}} />

<Text
style={{
fontFamily: 'inter',
fontVariationSettings: "'wght' 800, slnt -10",
}}>
{'Invalid font variation settings - should fallback to default font'}
</Text>

<View style={{marginVertical: 6}} />

{/* Font Icons with custom axes */}
<Text>Material Symbols Sharp - 'wght' 400, 'FILL' 0</Text>
Expand Down

0 comments on commit e63e994

Please sign in to comment.