Skip to content

Commit bd08842

Browse files
committed
[text shaping] Overflowing glyph gets clipped
https://bugs.webkit.org/show_bug.cgi?id=299818 Reviewed by Antti Koivisto. m_paintRect does not include ink overflow (e.g glyph overflow) so let's only clip the content in inline direction (regular text paint does not clip at all). Test: fast/text/clipped-glyph-across-inline-boxes.html * LayoutTests/fast/text/clipped-glyph-across-inline-boxes-expected.html: Added. * LayoutTests/fast/text/clipped-glyph-across-inline-boxes.html: Added. * Source/WebCore/rendering/TextBoxPainter.cpp: (WebCore::TextBoxPainter::paintForegroundForShapeRange): Canonical link: https://commits.webkit.org/300823@main
1 parent ce64d4a commit bd08842

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<meta charset=utf-8>
2+
<style>
3+
div {
4+
font-size: 50px;
5+
font-family: Monospace;
6+
}
7+
</style>
8+
PASS if these glyphs don't get clipped.
9+
<div>ممم</div>
10+
<div>ممم</div>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<meta charset=utf-8>
2+
<meta name="fuzzy" content="maxDifference=0-2; totalPixels=0-3" />
3+
<style>
4+
div {
5+
font-size: 50px;
6+
font-family: Monospace;
7+
}
8+
</style>
9+
PASS if these glyphs don't get clipped.
10+
<div><span>م</span><span>مم</span></div>
11+
<div>ممم</div>

Source/WebCore/rendering/TextBoxPainter.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,9 +663,20 @@ bool TextBoxPainter::paintForegroundForShapeRange(TextPainter& textPainter)
663663

664664
auto& context = m_paintInfo.context();
665665

666+
auto clipRect = [&] {
667+
// We could also just use ink overflow here but since non-range painting
668+
// sets up no clipping, we should not do that either here.
669+
auto rect = FloatRect::infiniteRect();
670+
rect.setX(m_paintRect.x());
671+
// Note that this is RTL direction.
672+
auto& textContent = m_textBox.box().text();
673+
if (!textContent.isAtShapingBoundaryStart())
674+
rect.setWidth(m_paintRect.width());
675+
// FIXME: Setup a semi-inifite rect for the (visually) first box where x is -inifite with fixed maxX.
676+
return rect;
677+
};
666678
context.save();
667-
context.clip(m_paintRect);
668-
679+
context.clip(clipRect());
669680
auto shapedContent = ShapedContent { };
670681
buildTextForShaping(shapedContent, m_textBox);
671682

0 commit comments

Comments
 (0)