mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
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:
+8
-5
@@ -480,18 +480,21 @@ func (s *shaperImpl) LayoutRunes(params Parameters, minWidth, maxWidth int, lc s
|
||||
}
|
||||
textLines[i] = otLine
|
||||
}
|
||||
alignWidth := maxWidth
|
||||
if len(textLines) == 1 {
|
||||
alignWidth = max(minWidth, textLines[0].width.Ceil())
|
||||
}
|
||||
calculateYOffsets(textLines)
|
||||
return document{
|
||||
lines: textLines,
|
||||
alignment: params.Alignment,
|
||||
alignWidth: alignWidth,
|
||||
alignWidth: alignWidth(minWidth, textLines),
|
||||
}
|
||||
}
|
||||
|
||||
func alignWidth(minWidth int, lines []line) int {
|
||||
for _, l := range lines {
|
||||
minWidth = max(minWidth, l.width.Ceil())
|
||||
}
|
||||
return minWidth
|
||||
}
|
||||
|
||||
// Shape converts the provided glyphs into a path.
|
||||
func (s *shaperImpl) Shape(ops *op.Ops, gs []Glyph) clip.PathSpec {
|
||||
var lastPos f32.Point
|
||||
|
||||
Reference in New Issue
Block a user