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, 03:37 UTC
| 1 | diff --git a/android/src/main/java/com/horcrux/svg/MarkerView.java b/android/src/main/java/com/horcrux/svg/MarkerView.java |
| 2 | index 8c796236f9f4b58717ac3fbab65e33d11ba032f2..d886e13d2cd1390a396716ecf4a379205e6a8aeb 100644 |
| 3 | --- a/android/src/main/java/com/horcrux/svg/MarkerView.java |
| 4 | +++ b/android/src/main/java/com/horcrux/svg/MarkerView.java |
| 5 | @@ -114,6 +114,17 @@ class MarkerView extends GroupView { |
| 6 | } |
| 7 | } |
| 8 | |
| 9 | + private static double parseOrientAngle(String orient) { |
| 10 | + if (orient == null) { |
| 11 | + return 0; |
| 12 | + } |
| 13 | + try { |
| 14 | + return Double.parseDouble(orient); |
| 15 | + } catch (NumberFormatException e) { |
| 16 | + return 0; |
| 17 | + } |
| 18 | + } |
| 19 | + |
| 20 | void renderMarker( |
| 21 | Canvas canvas, Paint paint, float opacity, RNSVGMarkerPosition position, float strokeWidth) { |
| 22 | int count = saveAndSetupCanvas(canvas, mCTM); |
| 23 | @@ -122,8 +133,15 @@ class MarkerView extends GroupView { |
| 24 | Point origin = position.origin; |
| 25 | markerTransform.setTranslate((float) origin.x, (float) origin.y); |
| 26 | |
| 27 | - double markerAngle = "auto".equals(mOrient) ? -1 : Double.parseDouble(mOrient); |
| 28 | - float degrees = 180 + (float) (markerAngle == -1 ? position.angle : markerAngle); |
| 29 | + double markerAngle = position.angle; |
| 30 | + if ("auto-start-reverse".equals(mOrient)) { |
| 31 | + if (position.type == RNSVGMarkerType.kStartMarker) { |
| 32 | + markerAngle += 180; |
| 33 | + } |
| 34 | + } else if (!"auto".equals(mOrient)) { |
| 35 | + markerAngle = parseOrientAngle(mOrient); |
| 36 | + } |
| 37 | + float degrees = 180 + (float) markerAngle; |
| 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(); |