text,widget: test and fix minWidth alignment

This commit unifies and fixes the shaper's handling of the alignment
minimum width. Previously it was only considered when the text was
a single line, but in hindsight that was clearly a mistake. Now the
maximum width of all shaped lines and the minimum width is used to
set the text alignment.

This commit also fixes an index test in package widget that was
relying on the old (incorrect) alignment behavior.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
Chris Waldon
2022-12-19 10:49:57 -05:00
committed by Elias Naur
parent fe5878bc63
commit c455f0f342
3 changed files with 73 additions and 7 deletions
+2 -2
View File
@@ -36,11 +36,11 @@ func makePosTestText(fontSize, lineWidth int, alignOpposite bool) (bidiLTR, bidi
ltrParams.Alignment = text.End
rtlParams.Alignment = text.Start
}
shaper.LayoutString(ltrParams, 0, lineWidth, english, bidiSource)
shaper.LayoutString(ltrParams, lineWidth, lineWidth, english, bidiSource)
for g, ok := shaper.NextGlyph(); ok; g, ok = shaper.NextGlyph() {
bidiLTR = append(bidiLTR, g)
}
shaper.LayoutString(rtlParams, 0, lineWidth, arabic, bidiSource)
shaper.LayoutString(rtlParams, lineWidth, lineWidth, arabic, bidiSource)
for g, ok := shaper.NextGlyph(); ok; g, ok = shaper.NextGlyph() {
bidiRTL = append(bidiRTL, g)
}