@whetware/react-native-stroke-text 0.0.7 → 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
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whetware/react-native-stroke-text",
|
|
3
|
-
"version": "0.0.
|
|
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",
|
|
@@ -121,4 +121,4 @@
|
|
|
121
121
|
"useTabs": false,
|
|
122
122
|
"semi": false
|
|
123
123
|
}
|
|
124
|
-
}
|
|
124
|
+
}
|