Skip to content

Commit f394713

Browse files
committed
Add logs to see what's going on with the stroke span
1 parent 0b55ab3 commit f394713

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,29 @@ protected void onDraw(Canvas canvas) {
371371
CharSequence text = getText();
372372
StrokeStyleSpan strokeSpan =
373373
text instanceof Spanned ? StrokeStyleSpan.getStrokeSpan((Spanned) text) : null;
374-
if (strokeSpan == null || !strokeSpan.draw(getPaint(), () -> super.onDraw(canvas))) {
374+
375+
// Debug logging
376+
Layout layout = getLayout();
377+
if (strokeSpan != null && layout != null) {
378+
android.util.Log.d("ReactTextView", "===== ReactTextView.onDraw =====");
379+
android.util.Log.d("ReactTextView", "Layout lineCount: " + layout.getLineCount());
380+
android.util.Log.d("ReactTextView", "View size: " + getWidth() + "x" + getHeight());
381+
android.util.Log.d("ReactTextView", "Canvas clip bounds: " + canvas.getClipBounds());
382+
android.util.Log.d("ReactTextView", "Overflow mode: " + mOverflow);
383+
for (int i = 0; i < layout.getLineCount(); i++) {
384+
android.util.Log.d("ReactTextView", "Line " + i + " - top: " + layout.getLineTop(i) +
385+
", bottom: " + layout.getLineBottom(i) +
386+
", baseline: " + layout.getLineBaseline(i));
387+
}
388+
android.util.Log.d("ReactTextView", "Text: " + text);
389+
android.util.Log.d("ReactTextView", "About to call strokeSpan.draw()");
390+
}
391+
392+
if (strokeSpan == null || !strokeSpan.draw(getPaint(), () -> {
393+
android.util.Log.d("ReactTextView", ">>> Calling super.onDraw() - canvas clip: " + canvas.getClipBounds());
394+
super.onDraw(canvas);
395+
android.util.Log.d("ReactTextView", "<<< super.onDraw() complete");
396+
})) {
375397
super.onDraw(canvas);
376398
}
377399

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/internal/span/StrokeStyleSpan.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import android.graphics.PorterDuffColorFilter
1313
import android.text.Spanned
1414
import android.text.TextPaint
1515
import android.text.style.CharacterStyle
16+
import android.util.Log
1617

1718
public class StrokeStyleSpan(
1819
public val width: Float,
@@ -32,27 +33,36 @@ public class StrokeStyleSpan(
3233
return false
3334
}
3435

36+
Log.d("StrokeStyleSpan", "===== STROKE DRAW START =====")
37+
Log.d("StrokeStyleSpan", "Stroke width: $width, color: ${Integer.toHexString(color)}")
38+
3539
val originalStyle = paint.style
3640
val originalStrokeWidth = paint.strokeWidth
3741
val originalStrokeJoin = paint.strokeJoin
3842
val originalStrokeCap = paint.strokeCap
3943
val originalColor = paint.color
4044
val originalColorFilter = paint.colorFilter
4145

46+
Log.d("StrokeStyleSpan", "Original paint - style: $originalStyle, strokeWidth: $originalStrokeWidth, color: ${Integer.toHexString(originalColor)}")
47+
4248
// Stroke pass
4349
paint.style = Paint.Style.STROKE
4450
paint.strokeWidth = width
4551
paint.strokeJoin = Paint.Join.ROUND
4652
paint.strokeCap = Paint.Cap.ROUND
4753
paint.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)
54+
Log.d("StrokeStyleSpan", ">>> STROKE PASS - style: ${paint.style}, strokeWidth: ${paint.strokeWidth}, colorFilter: ${paint.colorFilter}")
4855
drawCallback.run()
56+
Log.d("StrokeStyleSpan", "<<< STROKE PASS COMPLETE")
4957

5058
// Fill pass
5159
paint.style = Paint.Style.FILL
5260
paint.strokeWidth = 0f
5361
paint.color = originalColor
5462
paint.colorFilter = originalColorFilter
63+
Log.d("StrokeStyleSpan", ">>> FILL PASS - style: ${paint.style}, strokeWidth: ${paint.strokeWidth}, color: ${Integer.toHexString(paint.color)}")
5564
drawCallback.run()
65+
Log.d("StrokeStyleSpan", "<<< FILL PASS COMPLETE")
5666

5767
// Restore
5868
paint.style = originalStyle
@@ -62,6 +72,9 @@ public class StrokeStyleSpan(
6272
paint.color = originalColor
6373
paint.colorFilter = originalColorFilter
6474

75+
Log.d("StrokeStyleSpan", "Paint restored to original state")
76+
Log.d("StrokeStyleSpan", "===== STROKE DRAW END =====")
77+
6578
return true
6679
}
6780

0 commit comments

Comments
 (0)