Box returns the bounding box of the given non-multiline text where: - width is the horizontal space from the origin. - height is the vertical space above the baseline. - depth is the vertical space below the baseline, a positive number.
(txt string, fnt font.Font)
| 41 | // - height is the vertical space above the baseline. |
| 42 | // - depth is the vertical space below the baseline, a positive number. |
| 43 | func (hdlr Plain) Box(txt string, fnt font.Font) (width, height, depth vg.Length) { |
| 44 | face := hdlr.Fonts.Lookup(fnt, fnt.Size) |
| 45 | ext := face.Extents() |
| 46 | width = face.Width(txt) |
| 47 | height = ext.Ascent |
| 48 | depth = ext.Descent |
| 49 | |
| 50 | return width, height, depth |
| 51 | } |
| 52 | |
| 53 | // Draw renders the given text with the provided style and position |
| 54 | // on the canvas. |