Typeset now only uses SetWrap instead of relying zero values
This commit is contained in:
@@ -108,10 +108,10 @@ type LineLayout struct {
|
||||
|
||||
// DoLine consumes exactly one line from the given string, and produces a line
|
||||
// layout according to the given font. It returns the remaining text as well. If
|
||||
// maxWidth is greater than zero, this function will stop processing words once
|
||||
// the limit is crossed. The word which would have crossed over the limit will
|
||||
// not be processed.
|
||||
func DoLine (text []rune, face font.Face, maxWidth fixed.Int26_6) (line LineLayout, remaining []rune) {
|
||||
// wrap is set to true, this function will stop processing words once maxWidth
|
||||
// is crossed. The word which would have crossed over the limit will not be
|
||||
// processed.
|
||||
func DoLine (text []rune, face font.Face, wrap bool, maxWidth fixed.Int26_6) (line LineLayout, remaining []rune) {
|
||||
remaining = text
|
||||
x := fixed.Int26_6(0)
|
||||
lastWord := WordLayout { }
|
||||
@@ -123,8 +123,8 @@ func DoLine (text []rune, face font.Face, maxWidth fixed.Int26_6) (line LineLayo
|
||||
x += word.Width
|
||||
|
||||
// if we have gone over the maximum width, stop processing
|
||||
// words (if maxWidth is even specified)
|
||||
if !isFirstWord && maxWidth > 0 && x > maxWidth {
|
||||
// words (if wrap is enabled)
|
||||
if !isFirstWord && wrap && x > maxWidth {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -149,16 +149,9 @@ func DoLine (text []rune, face font.Face, maxWidth fixed.Int26_6) (line LineLayo
|
||||
}
|
||||
|
||||
// set the width of the line's content.
|
||||
line.Width = maxWidth
|
||||
line.ContentWidth = lastWord.X + lastWord.Width
|
||||
|
||||
// set the line's width. this is subject to be overridden by the
|
||||
// TypeSetter to match the longest line.
|
||||
if maxWidth > 0 {
|
||||
line.Width = maxWidth
|
||||
} else {
|
||||
line.Width = line.ContentWidth
|
||||
line.SpaceAfter = lastWord.SpaceAfter
|
||||
}
|
||||
line.SpaceAfter = lastWord.SpaceAfter
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user