@whetware/react-native-stroke-text 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -58,6 +58,10 @@ internal class StrokeTextView(context: ThemedReactContext) : TextView(context) {
58
58
  init {
59
59
  gravity = Gravity.TOP or Gravity.START
60
60
  includeFontPadding = true
61
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
62
+ breakStrategy = Layout.BREAK_STRATEGY_HIGH_QUALITY
63
+ hyphenationFrequency = Layout.HYPHENATION_FREQUENCY_NONE
64
+ }
61
65
  }
62
66
 
63
67
  fun invalidateTextLayout() {
@@ -70,20 +74,22 @@ internal class StrokeTextView(context: ThemedReactContext) : TextView(context) {
70
74
  // Draw stroke behind fill, using TextView's layout so metrics match RN <Text/> as closely as
71
75
  // possible (especially for bold fonts).
72
76
  val layout = layout
73
- if (layout != null && strokeWidthPx > 0f && strokeColor != Color.TRANSPARENT) {
74
- val textPaint = paint
75
- val prevStyle = textPaint.style
76
- val prevStrokeWidth = textPaint.strokeWidth
77
- val prevStrokeJoin = textPaint.strokeJoin
78
- val prevStrokeCap = textPaint.strokeCap
79
- val prevColor = textPaint.color
80
- val prevUnderline = textPaint.isUnderlineText
81
- val prevStrike = textPaint.isStrikeThruText
82
-
83
- val saveCount = canvas.save()
84
- val compoundPaddingLeft = compoundPaddingLeft
85
- val extendedPaddingTop = extendedPaddingTop
77
+ if (layout == null || strokeWidthPx <= 0f || strokeColor == Color.TRANSPARENT) {
78
+ super.onDraw(canvas)
79
+ return
80
+ }
86
81
 
82
+ val textPaint = paint
83
+ val prevStyle = textPaint.style
84
+ val prevStrokeWidth = textPaint.strokeWidth
85
+ val prevStrokeJoin = textPaint.strokeJoin
86
+ val prevStrokeCap = textPaint.strokeCap
87
+ val prevColor = textPaint.color
88
+ val prevUnderline = textPaint.isUnderlineText
89
+ val prevStrike = textPaint.isStrikeThruText
90
+
91
+ val saveCount = canvas.save()
92
+ try {
87
93
  canvas.translate(compoundPaddingLeft.toFloat(), extendedPaddingTop.toFloat())
88
94
  canvas.translate(-scrollX.toFloat(), -scrollY.toFloat())
89
95
 
@@ -98,6 +104,12 @@ internal class StrokeTextView(context: ThemedReactContext) : TextView(context) {
98
104
  textPaint.color = strokeColor
99
105
  layout.draw(canvas)
100
106
 
107
+ textPaint.style = Paint.Style.FILL
108
+ textPaint.color = prevColor
109
+ textPaint.isUnderlineText = prevUnderline
110
+ textPaint.isStrikeThruText = prevStrike
111
+ layout.draw(canvas)
112
+ } finally {
101
113
  canvas.restoreToCount(saveCount)
102
114
 
103
115
  textPaint.style = prevStyle
@@ -108,8 +120,6 @@ internal class StrokeTextView(context: ThemedReactContext) : TextView(context) {
108
120
  textPaint.isUnderlineText = prevUnderline
109
121
  textPaint.isStrikeThruText = prevStrike
110
122
  }
111
-
112
- super.onDraw(canvas)
113
123
  }
114
124
 
115
125
  private fun applyProps() {
package/lib/StrokeText.js CHANGED
@@ -148,7 +148,7 @@ export function StrokeText({ text, children, style, hybridRef, ...rest }) {
148
148
  const styles = StyleSheet.create({
149
149
  container: {},
150
150
  overlay: {
151
- ...StyleSheet.absoluteFillObject,
151
+ ...StyleSheet.absoluteFill,
152
152
  },
153
153
  hiddenText: {
154
154
  opacity: 0,
@@ -92,7 +92,7 @@ export function StrokeText({ text, children, style, ...rest }) {
92
92
  const styles = StyleSheet.create({
93
93
  container: {},
94
94
  overlay: {
95
- ...StyleSheet.absoluteFillObject,
95
+ ...StyleSheet.absoluteFill,
96
96
  },
97
97
  hiddenText: {
98
98
  opacity: 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whetware/react-native-stroke-text",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Stroke/outline text for React Native (New Architecture) on iOS, Android, and Web.",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -28,6 +28,19 @@
28
28
  "CHANGELOG.md",
29
29
  "README.md"
30
30
  ],
31
+ "scripts": {
32
+ "typecheck": "tsc --noEmit",
33
+ "clean": "rm -rf android/build node_modules/**/android/build lib",
34
+ "lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
35
+ "lint-ci": "eslint \"**/*.{js,ts,tsx}\"",
36
+ "typescript": "tsc",
37
+ "prepare": "npm run prepack",
38
+ "prepack": "tsc",
39
+ "changeset": "changeset",
40
+ "version-packages": "changeset version",
41
+ "release": "changeset publish",
42
+ "specs": "tsc --noEmit false && nitrogen --logLevel=\"debug\""
43
+ },
31
44
  "keywords": [
32
45
  "react-native",
33
46
  "nitro",
@@ -107,16 +120,5 @@
107
120
  "trailingComma": "es5",
108
121
  "useTabs": false,
109
122
  "semi": false
110
- },
111
- "scripts": {
112
- "typecheck": "tsc --noEmit",
113
- "clean": "rm -rf android/build node_modules/**/android/build lib",
114
- "lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
115
- "lint-ci": "eslint \"**/*.{js,ts,tsx}\"",
116
- "typescript": "tsc",
117
- "changeset": "changeset",
118
- "version-packages": "changeset version",
119
- "release": "changeset publish",
120
- "specs": "tsc --noEmit false && nitrogen --logLevel=\"debug\""
121
123
  }
122
- }
124
+ }