mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
text: ensure runereader behaves same as string
This commit fixes a subtle discrepancy in the handling of text input within the shaper. Text provided as an io.RuneReader with a trailing newline would generate an extra (empty) line of text, whereas the same input provided as a string would not. Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
+7
-5
@@ -223,11 +223,13 @@ func (l *Shaper) layoutText(params Parameters, minWidth, maxWidth int, lc system
|
||||
}
|
||||
done = endByte == len(str)
|
||||
}
|
||||
l.txt.append(l.layoutParagraph(params, minWidth, maxWidth, lc, str[startByte:endByte], l.paragraph))
|
||||
if truncating {
|
||||
params.MaxLines = maxLines - len(l.txt.lines)
|
||||
if params.MaxLines == 0 {
|
||||
done = true
|
||||
if startByte != endByte || len(l.paragraph) > 0 {
|
||||
l.txt.append(l.layoutParagraph(params, minWidth, maxWidth, lc, str[startByte:endByte], l.paragraph))
|
||||
if truncating {
|
||||
params.MaxLines = maxLines - len(l.txt.lines)
|
||||
if params.MaxLines == 0 {
|
||||
done = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if done {
|
||||
|
||||
Reference in New Issue
Block a user