Skip to content

Commit

Permalink
Fix line breaking with explicit line breaks, fixes #325
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Nov 24, 2024
1 parent d014681 commit 5f231da
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion text/linebreak.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,13 @@ func GlyphsToItems(glyphs []Glyph, indent float64, align Align) []Item {
} else if IsNewline(glyph.Text) {
// only add one penalty for \r\n
if glyph.Text != '\n' || i == 0 || glyphs[i-1].Text != '\r' {
items = append(items, Penalty(0.0, -Infinity, false))
if align == Centered {
items = append(items, Glue(0.0, stretchWidth, 0.0))
items = append(items, Penalty(0.0, -Infinity, false))
} else {
items = append(items, Glue(0.0, math.Inf(1.0), 0.0))
items = append(items, Penalty(0.0, -Infinity, true))
}
}
items[len(items)-1].Size++
} else if glyph.Text == '\u00AD' || glyph.Text == '\u200B' {
Expand Down

0 comments on commit 5f231da

Please sign in to comment.