Skip to content
TypeScript

fix(mobile): keep source text bold for numeric font weights (#23688)

Victor Vogelceb06de3bb4d
diff --git a/apps/mobile/modules/t3-source-text/src/util.test.ts b/apps/mobile/modules/t3-source-text/src/util.test.ts
new file mode 100644
index 00000000000..c3af9a1f8ff
--- /dev/null
+++ b/apps/mobile/modules/t3-source-text/src/util.test.ts
@@ -0,0 +1,15 @@
+import { expect, it, vi } from "vite-plus/test";
+
+import { flattenStyles } from "./util";
+
+vi.mock("react-native", () => ({
+ I18nManager: { isRTL: false },
+ StyleSheet: {
+ flatten: (styles: ReadonlyArray<object | undefined>) => Object.assign({}, ...styles),
+ },
+}));
+
+it("encodes numeric bold weights as bold source-text runs", () => {
+ expect(flattenStyles({ fontWeight: 700 }, undefined).fontWeight).toBe("bold");
+ expect(flattenStyles({ fontWeight: "400" }, { fontWeight: "700" }).fontWeight).toBe("bold");
+});
diff --git a/apps/mobile/modules/t3-source-text/src/util.ts b/apps/mobile/modules/t3-source-text/src/util.ts
index 461fc7684b4..47f219bd3aa 100644
--- a/apps/mobile/modules/t3-source-text/src/util.ts
+++ b/apps/mobile/modules/t3-source-text/src/util.ts
@@ -64,7 +64,7 @@ function fontWeightToNativeProp(fontWeight: TextStyle["fontWeight"]): NativeFont
return "semibold";
case 700:
case "700":
- return "semibold";
+ return "bold";
case 800:
case "800":
return "bold";