Subject: [PATCH] Fix #15244 : Correct underline & StrikeLine alignment in GlyphBox::render --- Index: scribus/text/boxes.cpp IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/scribus/text/boxes.cpp b/scribus/text/boxes.cpp --- a/scribus/text/boxes.cpp (revision 27550) +++ b/scribus/text/boxes.cpp (date 1778349222213) @@ -655,16 +655,25 @@ p->setStrokeWidth(lw); double xoffs(0.0), yoffs(0.0); + // Find the visual start of the character by taking the minimum x_offset + // among all glyphs in the cluster. This handles composed characters like + // Arabic "ظ" where a dot glyph may have a larger x_offset than the base glyph. if (m_glyphRun.glyphs().count() > 0) { - const GlyphLayout& gl = m_glyphRun.glyphs().first(); - xoffs = gl.xoffset; - yoffs = gl.yoffset; + xoffs = m_glyphRun.glyphs().first().xoffset; + yoffs = m_glyphRun.glyphs().first().yoffset; + for (const GlyphLayout& gl : m_glyphRun.glyphs()) + { + if (gl.xoffset < xoffs) + xoffs = gl.xoffset; + if (gl.yoffset < yoffs) + yoffs = gl.yoffset; + } } if (charStyle.effects() & ScStyle_Subscript) - p->drawLine(QPointF(xoffs, yoffs - st), QPointF(xoffs + m_glyphRun.width(), yoffs - st)); + p->drawLine(QPointF(0, yoffs - st), QPointF( m_glyphRun.width(), yoffs - st)); else - p->drawLine(QPointF(xoffs, -st), QPointF(xoffs + m_glyphRun.width(), -st)); + p->drawLine(QPointF(0, -st), QPointF( m_glyphRun.width(), -st)); p->setStrokeWidth(sw); p->setStrokeColor(sc); @@ -741,13 +750,24 @@ p->setStrokeWidth(lw); double xoffs(0.0), yoffs(0.0); + // Fix strikethrough position for glyphs composed of multiple parts + // (e.g., Arabic characters with separate dots like "ظ"). + // Find the minimum x_offset to start at the visual beginning of the + // character, and the maximum y_offset to position the line correctly + // through the dot which sits above the base glyph. if (m_glyphRun.glyphs().count() > 0) { - const GlyphLayout& gl = m_glyphRun.glyphs().first(); - xoffs = gl.xoffset; - yoffs = gl.yoffset; + xoffs = m_glyphRun.glyphs().first().xoffset; + yoffs = m_glyphRun.glyphs().first().yoffset; + for (const GlyphLayout& gl : m_glyphRun.glyphs()) + { + if (gl.xoffset < xoffs) + xoffs = gl.xoffset; + if (gl.yoffset > yoffs) + yoffs = gl.yoffset; + } } - p->drawLine(QPointF(xoffs, yoffs - st), QPointF(xoffs + m_glyphRun.width(), yoffs - st)); + p->drawLine(QPointF(0, yoffs - st), QPointF(m_glyphRun.width(), yoffs - st)); p->setStrokeWidth(sw); p->setStrokeColor(sc);