Skip to content

Commit 3915c0f

Browse files
dulmandakhfacebook-github-bot
authored andcommitted
custom fontWeight numeric values for Text on Android (facebook#25341)
Summary: I found that on Android we only support 2 fontWeight options, either **normal** or **bold**, even developer can set any numeric value. But iOS supports all possible numeric values. This PR tries to add support for all possible numeric values on Android, even if it's supported only on Android P(28) and above. This change might break texts where fontWeight use improperly, because this PR removes conversion of values above 500 to BOLD and below 500 to normal. FYI, also moved **mCustomTypefaceCache** usage up because it was working after unnecessary mFontCache usage. ## Changelog [Android] [Changed] - add custom font weight support to Text component on Android, only on P(API 28) and above versions. Pull Request resolved: facebook#25341 Test Plan: RNTester app's Text examples will show Rubik Regular, Rubik Light, Rubik Bold, Rubik Medium and Rubik Medium Italic texts in corresponding font family, style and weights. Differential Revision: D15956350 Pulled By: mdvacca fbshipit-source-id: 61079d953c65fb34ab4497d44c22317912a5a616
1 parent 9ed6dc7 commit 3915c0f

File tree

14 files changed

+70
-31
lines changed

14 files changed

+70
-31
lines changed

RNTester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public List<ReactPackage> getPackages() {
4747

4848
@Override
4949
public void onCreate() {
50-
ReactFontManager.getInstance().addCustomFont(this, "Srisakdi", R.font.srisakdi);
50+
ReactFontManager.getInstance().addCustomFont(this, "Rubik", R.font.rubik);
5151
super.onCreate();
5252
}
5353

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<font-family xmlns:app="http://schemas.android.com/apk/res-auto">
3+
<font app:fontStyle="normal" app:fontWeight="300" app:font="@font/rubik_light"/>
4+
<font app:fontStyle="normal" app:fontWeight="400" app:font="@font/rubik_regular"/>
5+
<font app:fontStyle="normal" app:fontWeight="500" app:font="@font/rubik_medium" />
6+
<font app:fontStyle="normal" app:fontWeight="700" app:font="@font/rubik_bold" />
7+
<font app:fontStyle="italic" app:fontWeight="500" app:font="@font/rubik_medium_italic" />
8+
</font-family>
132 KB
Binary file not shown.
127 KB
Binary file not shown.
133 KB
Binary file not shown.
134 KB
Binary file not shown.
130 KB
Binary file not shown.

RNTester/android/app/src/main/res/font/srisakdi.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.
-94.6 KB
Binary file not shown.
-94.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)