MCPcopy Create free account
hub / github.com/cogentcore/core / SetString

Method SetString

paint/text.go:277–289  ·  view source on GitHub ↗

SetString is for basic text rendering with a single style of text (see SetHTML for tag-formatted text) -- configures a single Span with the entire string, and does standard layout (LR currently). rot and scalex are general rotation and x-scaling to apply to all chars -- alternatively can apply thes

(str string, fontSty *styles.FontRender, ctxt *units.Context, txtSty *styles.Text, noBG bool, rot, scalex float32)

Source from the content-addressed store, hash-verified

275// valid Face is available. noBG ignores any BackgroundColor in font style, and never
276// renders background color
277func (tr *Text) SetString(str string, fontSty *styles.FontRender, ctxt *units.Context, txtSty *styles.Text, noBG bool, rot, scalex float32) {
278 if len(tr.Spans) != 1 {
279 tr.Spans = make([]Span, 1)
280 }
281 tr.Links = nil
282 sr := &(tr.Spans[0])
283 sr.SetString(str, fontSty, ctxt, noBG, rot, scalex)
284 sr.SetRunePosLR(txtSty.LetterSpacing.Dots, txtSty.WordSpacing.Dots, fontSty.Face.Metrics.Ch, txtSty.TabSize)
285 ssz := sr.SizeHV()
286 vht := fontSty.Face.Face.Metrics().Height
287 tr.BBox.Min.SetZero()
288 tr.BBox.Max = math32.Vec2(ssz.X, math32.FromFixed(vht))
289}
290
291// SetStringRot90 is for basic text rendering with a single style of text (see
292// SetHTML for tag-formatted text) -- configures a single Span with the

Callers 2

SizeLabelMethod · 0.95
RenderMethod · 0.95

Calls 6

Vec2Function · 0.92
FromFixedFunction · 0.92
SetRunePosLRMethod · 0.80
SizeHVMethod · 0.80
SetStringMethod · 0.65
SetZeroMethod · 0.45

Tested by

no test coverage detected