From 0b48d69430ff11bb36c0e0eb7975e2525bc0672e Mon Sep 17 00:00:00 2001 From: Kozjat <16747629+kozjat@users.noreply.github.com> Date: Wed, 19 Feb 2020 00:38:20 +0200 Subject: [PATCH] Added height return value for DrawStringWraped --- README.md | 2 +- context.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 575f0ec..648262e 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ It will even do word wrap for you! ```go DrawString(s string, x, y 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) MeasureMultilineString(s string, lineSpacing float64) (w, h float64) WordWrap(s string, w float64) []string diff --git a/context.go b/context.go index 1ddb09f..e864a9b 100644 --- a/context.go +++ b/context.go @@ -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 // and then draws it at the specified anchor point using the given line // 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) // 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) y += dc.fontHeight * lineSpacing } + + return h } func (dc *Context) MeasureMultilineString(s string, lineSpacing float64) (width, height float64) {