Skip to content

Commit d6a479e

Browse files
committed
Update the stroke style span order
1 parent c0d8f18 commit d6a479e

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -173,24 +173,6 @@ private static void buildSpannedFromShadowNode(
173173
}
174174
int end = sb.length();
175175
if (end >= start) {
176-
// Add StrokeStyleSpan FIRST so it has highest priority and gets applied LAST during drawing,
177-
// ensuring our color overwrites any ForegroundColorSpan
178-
if (!Float.isNaN(textShadowNode.mTextStrokeWidth)
179-
&& textShadowNode.mTextStrokeWidth > 0
180-
&& textShadowNode.mIsTextStrokeColorSet) {
181-
String debugText = sb.subSequence(start, end).toString();
182-
android.util.Log.d("TextDebug", "=== ReactBaseTextShadowNode adding StrokeStyleSpan (FIRST) ===");
183-
android.util.Log.d("TextDebug", "strokeWidth: " + textShadowNode.mTextStrokeWidth + ", start: " + start + ", end: " + end + ", text: '" + debugText + "', strokeColor: " + textShadowNode.mTextStrokeColor + " (hex: " + Integer.toHexString(textShadowNode.mTextStrokeColor) + ")");
184-
ops.add(
185-
new SetSpanOperation(
186-
start,
187-
end,
188-
new StrokeStyleSpan(
189-
textShadowNode.mTextStrokeWidth,
190-
textShadowNode.mTextStrokeColor,
191-
debugText)));
192-
}
193-
194176
if (textShadowNode.mIsColorSet) {
195177
ops.add(new SetSpanOperation(start, end, new ReactForegroundColorSpan(textShadowNode.mColor)));
196178
}
@@ -260,14 +242,31 @@ private static void buildSpannedFromShadowNode(
260242
textShadowNode.mTextShadowRadius,
261243
textShadowNode.mTextShadowColor)));
262244
}
263-
// StrokeStyleSpan is added at the beginning of this block for correct priority
264245
float effectiveLineHeight = textAttributes.getEffectiveLineHeight();
265246
if (!Float.isNaN(effectiveLineHeight)
266247
&& (parentTextAttributes == null
267248
|| parentTextAttributes.getEffectiveLineHeight() != effectiveLineHeight)) {
268249
ops.add(new SetSpanOperation(start, end, new CustomLineHeightSpan(effectiveLineHeight)));
269250
}
270251
ops.add(new SetSpanOperation(start, end, new ReactTagSpan(textShadowNode.getReactTag())));
252+
253+
// Add StrokeStyleSpan LAST so it has lowest priority index, which means highest priority,
254+
// and gets applied LAST during drawing, ensuring our color overwrites any ForegroundColorSpan
255+
if (!Float.isNaN(textShadowNode.mTextStrokeWidth)
256+
&& textShadowNode.mTextStrokeWidth > 0
257+
&& textShadowNode.mIsTextStrokeColorSet) {
258+
String debugText = sb.subSequence(start, end).toString();
259+
android.util.Log.d("TextDebug", "=== ReactBaseTextShadowNode adding StrokeStyleSpan (LAST) ===");
260+
android.util.Log.d("TextDebug", "strokeWidth: " + textShadowNode.mTextStrokeWidth + ", start: " + start + ", end: " + end + ", text: '" + debugText + "', strokeColor: " + textShadowNode.mTextStrokeColor + " (hex: " + Integer.toHexString(textShadowNode.mTextStrokeColor) + ")");
261+
ops.add(
262+
new SetSpanOperation(
263+
start,
264+
end,
265+
new StrokeStyleSpan(
266+
textShadowNode.mTextStrokeWidth,
267+
textShadowNode.mTextStrokeColor,
268+
debugText)));
269+
}
271270
}
272271
}
273272

0 commit comments

Comments
 (0)