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

Method SetRunes

paint/text.go:318–330  ·  view source on GitHub ↗

SetRunes 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 these

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

Source from the content-addressed store, hash-verified

316// valid Face is available. noBG ignores any BackgroundColor in font style, and never
317// renders background color
318func (tr *Text) SetRunes(str []rune, fontSty *styles.FontRender, ctxt *units.Context, txtSty *styles.Text, noBG bool, rot, scalex float32) {
319 if len(tr.Spans) != 1 {
320 tr.Spans = make([]Span, 1)
321 }
322 tr.Links = nil
323 sr := &(tr.Spans[0])
324 sr.SetRunes(str, fontSty, ctxt, noBG, rot, scalex)
325 sr.SetRunePosLR(txtSty.LetterSpacing.Dots, txtSty.WordSpacing.Dots, fontSty.Face.Metrics.Ch, txtSty.TabSize)
326 ssz := sr.SizeHV()
327 vht := fontSty.Face.Face.Metrics().Height
328 tr.BBox.Min.SetZero()
329 tr.BBox.Max = math32.Vec2(ssz.X, math32.FromFixed(vht))
330}
331
332// SetHTMLSimpleTag sets the styling parameters for simple html style tags
333// that only require updating the given font spec values -- returns true if handled

Callers 2

configTextSizeMethod · 0.45
RenderMethod · 0.45

Calls 5

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

Tested by

no test coverage detected