diff --git a/text/gotext.go b/text/gotext.go index c7ee3480..60670407 100644 --- a/text/gotext.go +++ b/text/gotext.go @@ -490,10 +490,11 @@ func wrapPolicyToGoText(p WrapPolicy) shaping.LineBreakPolicy { // shapeAndWrapText invokes the text shaper and returns wrapped lines in the shaper's native format. func (s *shaperImpl) shapeAndWrapText(params Parameters, txt []rune) (_ []shaping.Line, truncated int) { wc := shaping.WrapConfig{ - Direction: mapDirection(params.Locale.Direction), - TruncateAfterLines: params.MaxLines, - TextContinues: params.forceTruncate, - BreakPolicy: wrapPolicyToGoText(params.WrapPolicy), + Direction: mapDirection(params.Locale.Direction), + TruncateAfterLines: params.MaxLines, + TextContinues: params.forceTruncate, + BreakPolicy: wrapPolicyToGoText(params.WrapPolicy), + DisableTrailingWhitespaceTrim: params.DisableSpaceTrim, } families := s.defaultFaces if params.Font.Typeface != "" { diff --git a/text/shaper.go b/text/shaper.go index ecd89878..db679268 100644 --- a/text/shaper.go +++ b/text/shaper.go @@ -76,6 +76,11 @@ type Parameters struct { // text with a MaxLines. It is unexported because this behavior only makes sense for the // shaper to control when it iterates paragraphs of text. forceTruncate bool + + // DisableSpaceTrim prevents the width of the final whitespace glyph on a line from being zeroed. + // This is desirable for text editors (so that the whitespace can be selected), but is undesirable + // for ordinary display text. + DisableSpaceTrim bool } type FontFace = giofont.FontFace