@devries-cameron20 / t3code Mirror · read-only / commits / 2c2191789a
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

fix(mobile): SVG text with font-variation-settings no longer crashes Android (#39334)

Julius Marminge committed Nov 19, 2026 at 13:43 UTC 2c2191789ae7f07b8b2d485f138b4dc7fefce9da
2 files changed +88 -6
patches/react-native-svg@15.16.1.patch
+82
@@ -38,3 +38,85 @@ index 8c796236f9f4b58717ac3fbab65e33d11ba032f2..d886e13d2cd1390a396716ecf4a37920
38 markerTransform.preRotate(degrees);
39
40 boolean useStrokeWidth = "strokeWidth".equals(mMarkerUnits);
41 +diff --git a/android/src/main/java/com/horcrux/svg/TSpanView.java b/android/src/main/java/com/horcrux/svg/TSpanView.java
42 +index b6e0a3892eb5416b1badf447d4f8c4e4baef828c..4660fb4b7b49ec44e78fb413a543dd5f9f93ed6a 100644
43 +--- a/android/src/main/java/com/horcrux/svg/TSpanView.java
44 ++++ b/android/src/main/java/com/horcrux/svg/TSpanView.java
45 +@@ -21,6 +21,7 @@ import static com.horcrux.svg.TextProperties.TextPathMidLine;
46 + import static com.horcrux.svg.TextProperties.TextPathSide;
47 +
48 + import android.annotation.SuppressLint;
49 ++import android.annotation.TargetApi;
50 + import android.content.res.AssetManager;
51 + import android.graphics.Canvas;
52 + import android.graphics.Matrix;
53 +@@ -290,6 +291,33 @@ class TSpanView extends TextView {
54 + static final String additionalLigatures = "'hlig', 'cala', ";
55 + static final String fontWeightTag = "'wght' ";
56 +
57 ++ static String fontVariationSettings(int weight, String extra) {
58 ++ String weightAxis = fontWeightTag + weight;
59 ++ return extra == null || extra.trim().isEmpty() ? weightAxis : weightAxis + ", " + extra;
60 ++ }
61 ++
62 ++ // Android throws IllegalArgumentException on settings it cannot parse, which would crash the
63 ++ // draw; fall back to the weight axis alone.
64 ++ @TargetApi(Build.VERSION_CODES.O)
65 ++ private static void setPaintFontVariationSettings(Paint paint, FontData font) {
66 ++ try {
67 ++ paint.setFontVariationSettings(
68 ++ fontVariationSettings(font.absoluteFontWeight, font.fontVariationSettings));
69 ++ } catch (IllegalArgumentException e) {
70 ++ paint.setFontVariationSettings(fontWeightTag + font.absoluteFontWeight);
71 ++ }
72 ++ }
73 ++
74 ++ @TargetApi(Build.VERSION_CODES.O)
75 ++ private static void setBuilderFontVariationSettings(
76 ++ Typeface.Builder builder, int weight, String extra) {
77 ++ try {
78 ++ builder.setFontVariationSettings(fontVariationSettings(weight, extra));
79 ++ } catch (IllegalArgumentException e) {
80 ++ builder.setFontVariationSettings(fontWeightTag + weight);
81 ++ }
82 ++ }
83 ++
84 + private void applySpacingAndFeatures(Paint paint, FontData font) {
85 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
86 + double letterSpacing = font.letterSpacing;
87 +@@ -307,8 +335,7 @@ class TSpanView extends TextView {
88 + }
89 +
90 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
91 +- paint.setFontVariationSettings(
92 +- fontWeightTag + font.absoluteFontWeight + font.fontVariationSettings);
93 ++ setPaintFontVariationSettings(paint, font);
94 + }
95 + }
96 + }
97 +@@ -487,8 +514,7 @@ class TSpanView extends TextView {
98 + }
99 +
100 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
101 +- paint.setFontVariationSettings(
102 +- fontWeightTag + font.absoluteFontWeight + font.fontVariationSettings);
103 ++ setPaintFontVariationSettings(paint, font);
104 + }
105 + }
106 + // OpenType.js font data
107 +@@ -1147,13 +1173,13 @@ class TSpanView extends TextView {
108 + String ttfpath = FONTS + fontFamily + TTF;
109 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
110 + Typeface.Builder builder = new Typeface.Builder(assets, otfpath);
111 +- builder.setFontVariationSettings("'wght' " + weight + font.fontVariationSettings);
112 ++ setBuilderFontVariationSettings(builder, weight, font.fontVariationSettings);
113 + builder.setWeight(weight);
114 + builder.setItalic(isItalic);
115 + typeface = builder.build();
116 + if (typeface == null) {
117 + builder = new Typeface.Builder(assets, ttfpath);
118 +- builder.setFontVariationSettings("'wght' " + weight + font.fontVariationSettings);
119 ++ setBuilderFontVariationSettings(builder, weight, font.fontVariationSettings);
120 + builder.setWeight(weight);
121 + builder.setItalic(isItalic);
122 + typeface = builder.build();
pnpm-lock.yaml
+6 -6
@@ -396,7 +396,7 @@ patchedDependencies:
396 react-native-keyboard-controller@1.23.0: 1c7c80317ef050e08d4aabe034a0813d03b497dff2dc8b37fb5f4a6e3b20fddb
397 react-native-pdf-jsi@6.1.0: d29e6b69813548de641a09db705dd94823d3f96832821ae9c3f6a196dd15cb68
398 react-native-reanimated@4.7.1: 95ee26e5fcab5f50bc4b4c47b3f7e6278a0b20850205efb9f6ee7e70a22d2b59
399 - react-native-svg@15.16.1: 110f9243ffad03654ce40dd1cdb09f01af16b8fa2ccb2b2cd3d62e682c180399
399 + react-native-svg@15.16.1: 7f94d240fc19418233c96f9a637dfd248846446657476c204f3614fd2847900e
400 react-native-webview@14.0.1: 71009983c76818bd5e73d4ca597f76efd04101600c84cd4b4c5d920781c048ae
401
402 importers:
@@ -623,7 +623,7 @@ importers:
623 version: link:../../packages/shared
624 '@tabler/icons-react-native':
625 specifier: ^3.44.0
626 - version: 3.44.0(react-native-svg@15.16.1(patch_hash=110f9243ffad03654ce40dd1cdb09f01af16b8fa2ccb2b2cd3d62e682c180399)(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0))(react@19.3.0)
626 + version: 3.44.0(react-native-svg@15.16.1(patch_hash=7f94d240fc19418233c96f9a637dfd248846446657476c204f3614fd2847900e)(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0))(react@19.3.0)
627 clsx:
628 specifier: ^2.1.1
629 version: 2.1.1
@@ -791,7 +791,7 @@ importers:
791 version: file:apps/mobile/deps/react-native-screens-5.0.0-t3.61.tgz(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
792 react-native-svg:
793 specifier: 15.16.1
794 - version: 15.16.1(patch_hash=110f9243ffad03654ce40dd1cdb09f01af16b8fa2ccb2b2cd3d62e682c180399)(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
794 + version: 15.16.1(patch_hash=7f94d240fc19418233c96f9a637dfd248846446657476c204f3614fd2847900e)(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
795 react-native-webview:
796 specifier: 14.0.1
797 version: 14.0.1(patch_hash=71009983c76818bd5e73d4ca597f76efd04101600c84cd4b4c5d920781c048ae)(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
@@ -16972,11 +16972,11 @@ snapshots:
16972
16973 '@t3tools/mobile-terminal-native@file:apps/mobile/modules/t3-terminal': {}
16974
16975 - '@tabler/icons-react-native@3.44.0(react-native-svg@15.16.1(patch_hash=110f9243ffad03654ce40dd1cdb09f01af16b8fa2ccb2b2cd3d62e682c180399)(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0))(react@19.3.0)':
16975 + '@tabler/icons-react-native@3.44.0(react-native-svg@15.16.1(patch_hash=7f94d240fc19418233c96f9a637dfd248846446657476c204f3614fd2847900e)(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0))(react@19.3.0)':
16976 dependencies:
16977 '@tabler/icons': 3.44.0
16978 react: 19.3.0
16979 - react-native-svg: 15.16.1(patch_hash=110f9243ffad03654ce40dd1cdb09f01af16b8fa2ccb2b2cd3d62e682c180399)(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
16979 + react-native-svg: 15.16.1(patch_hash=7f94d240fc19418233c96f9a637dfd248846446657476c204f3614fd2847900e)(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
16980
16981 '@tabler/icons@3.44.0': {}
16982
@@ -22604,7 +22604,7 @@ snapshots:
22604 react-native: 0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6)
22605 warn-once: 0.1.1
22606
22607 - react-native-svg@15.16.1(patch_hash=110f9243ffad03654ce40dd1cdb09f01af16b8fa2ccb2b2cd3d62e682c180399)(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0):
22607 + react-native-svg@15.16.1(patch_hash=7f94d240fc19418233c96f9a637dfd248846446657476c204f3614fd2847900e)(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0):
22608 dependencies:
22609 css-select: 5.2.2
22610 css-tree: 1.1.3