MCPcopy Index your code
hub / github.com/tdewolff/canvas / NewTextBox

Function NewTextBox

text.go:414–418  ·  view source on GitHub ↗

NewTextBox is an advanced text formatter that will format text placement based on the settings. It takes a single font face, a string, the width or height of the box (can be zero to disable), horizontal and vertical alignment (Left, Center, Right, Top, Bottom or Justify), text indentation for the fi

(face *FontFace, s string, width, height float64, halign, valign TextAlign, opts *TextOptions)

Source from the content-addressed store, hash-verified

412
413// NewTextBox is an advanced text formatter that will format text placement based on the settings. It takes a single font face, a string, the width or height of the box (can be zero to disable), horizontal and vertical alignment (Left, Center, Right, Top, Bottom or Justify), text indentation for the first line and line stretch (percentage to stretch the line based on the line height).
414func NewTextBox(face *FontFace, s string, width, height float64, halign, valign TextAlign, opts *TextOptions) *Text {
415 rt := NewRichText(face)
416 rt.WriteString(s)
417 return rt.ToText(width, height, halign, valign, opts)
418}
419
420type indexer []int
421

Callers 4

drawTextFunction · 0.92
drawDocumentFunction · 0.92
DrawPreviewWithAssetsFunction · 0.85
TestTextBoxFunction · 0.85

Calls 2

ToTextMethod · 0.95
NewRichTextFunction · 0.85

Tested by 1

TestTextBoxFunction · 0.68