Added height return value for DrawStringWraped

This commit is contained in:
Kozjat 2020-02-19 00:38:20 +02:00
parent 4dc34561c6
commit 0b48d69430
2 changed files with 4 additions and 2 deletions

View File

@ -93,7 +93,7 @@ It will even do word wrap for you!
```go ```go
DrawString(s string, x, y float64) DrawString(s string, x, y float64)
DrawStringAnchored(s string, x, y, ax, ay float64) DrawStringAnchored(s string, x, y, ax, ay float64)
DrawStringWrapped(s string, x, y, ax, ay, width, lineSpacing float64, align Align) DrawStringWrapped(s string, x, y, ax, ay, width, lineSpacing float64, align Align) float64
MeasureString(s string) (w, h float64) MeasureString(s string) (w, h float64)
MeasureMultilineString(s string, lineSpacing float64) (w, h float64) MeasureMultilineString(s string, lineSpacing float64) (w, h float64)
WordWrap(s string, w float64) []string WordWrap(s string, w float64) []string

View File

@ -765,7 +765,7 @@ func (dc *Context) DrawStringAnchored(s string, x, y, ax, ay float64) {
// DrawStringWrapped word-wraps the specified string to the given max width // DrawStringWrapped word-wraps the specified string to the given max width
// and then draws it at the specified anchor point using the given line // and then draws it at the specified anchor point using the given line
// spacing and text alignment. // spacing and text alignment.
func (dc *Context) DrawStringWrapped(s string, x, y, ax, ay, width, lineSpacing float64, align Align) { func (dc *Context) DrawStringWrapped(s string, x, y, ax, ay, width, lineSpacing float64, align Align) float64 {
lines := dc.WordWrap(s, width) lines := dc.WordWrap(s, width)
// sync h formula with MeasureMultilineString // sync h formula with MeasureMultilineString
@ -789,6 +789,8 @@ func (dc *Context) DrawStringWrapped(s string, x, y, ax, ay, width, lineSpacing
dc.DrawStringAnchored(line, x, y, ax, ay) dc.DrawStringAnchored(line, x, y, ax, ay)
y += dc.fontHeight * lineSpacing y += dc.fontHeight * lineSpacing
} }
return h
} }
func (dc *Context) MeasureMultilineString(s string, lineSpacing float64) (width, height float64) { func (dc *Context) MeasureMultilineString(s string, lineSpacing float64) (width, height float64) {