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

Method box

text/text.go:116–134  ·  view source on GitHub ↗

box returns the bounding box of a possibly multi-line text.

(txt string)

Source from the content-addressed store, hash-verified

114
115// box returns the bounding box of a possibly multi-line text.
116func (s Style) box(txt string) (w, h vg.Length) {
117 var (
118 lines = s.Handler.Lines(txt)
119 e = s.FontExtents()
120 linegap = (e.Height - e.Ascent - e.Descent)
121 )
122 for i, line := range lines {
123 ww, hh, dd := s.Handler.Box(line, s.Font)
124 if ww > w {
125 w = ww
126 }
127 h += hh + dd
128 if i > 0 {
129 h += linegap
130 }
131 }
132
133 return w, h
134}
135
136// Rectangle returns a rectangle giving the bounds of
137// this text assuming that it is drawn at (0, 0).

Callers 3

WidthMethod · 0.95
HeightMethod · 0.95
RectangleMethod · 0.95

Calls 3

FontExtentsMethod · 0.95
LinesMethod · 0.65
BoxMethod · 0.65

Tested by

no test coverage detected