Attachment "tk-windows-uniscribe-measure.patch" to
ticket [f3d96411]
added by
Arnault01
2026-10-30 01:42:55.
Also attachment "tk-windows-uniscribe-measure.patch" to
ticket [59d6d5f6]
added by
Arnault01
2026-10-28 03:07:42.
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -8840,6 +8840,19 @@
fit = MeasureChars(tkfont, chars, charsLen, 0, bend,
ciPtr->baseChunkPtr->x + xDisplacement, maxX, flags, nextXPtr);
+ /*
+ * The Windows backend (Uniscribe) can return a non-monotonic
+ * position when the measured range ends with a control character
+ * such as '\n': the returned right edge may be to the left of the
+ * span start, producing chunks with negative width (e.g. the
+ * newline chunk), which corrupts DLine length and justification.
+ * Clamp to the span start so such characters get zero width.
+ */
+
+ if (*nextXPtr < startX) {
+ *nextXPtr = startX;
+ }
+
if (fit < bstart) {
return 0;
} else {