MCPcopy Index your code
hub / github.com/gonum/plot / Box

Method Box

text/plain.go:43–51  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

41// - height is the vertical space above the baseline.
42// - depth is the vertical space below the baseline, a positive number.
43func (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.

Callers

nothing calls this directly

Calls 3

LookupMethod · 0.80
ExtentsMethod · 0.65
WidthMethod · 0.45

Tested by

no test coverage detected