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

Method configTextAlloc

core/text.go:307–319  ·  view source on GitHub ↗

configTextAlloc is used for determining how much space the text takes, using given size (typically Alloc). In this case, alignment factors are turned off, because they otherwise can absorb much more space, which should instead be controlled by the base Align X,Y factors.

(sz math32.Vector2)

Source from the content-addressed store, hash-verified

305// because they otherwise can absorb much more space, which should
306// instead be controlled by the base Align X,Y factors.
307func (tx *Text) configTextAlloc(sz math32.Vector2) math32.Vector2 {
308 // todo: last arg is CSSAgg. Can synthesize that some other way?
309 fs := tx.Styles.FontRender()
310 txs := &tx.Styles.Text
311 align, alignV := txs.Align, txs.AlignV
312 txs.Align, txs.AlignV = styles.Start, styles.Start
313 tx.paintText.SetHTML(tx.Text, fs, txs, &tx.Styles.UnitContext, nil)
314 tx.paintText.Layout(txs, fs, &tx.Styles.UnitContext, sz)
315 rsz := tx.paintText.BBox.Size().Ceil()
316 txs.Align, txs.AlignV = align, alignV
317 tx.paintText.Layout(txs, fs, &tx.Styles.UnitContext, rsz)
318 return rsz
319}
320
321func (tx *Text) SizeUp() {
322 tx.WidgetBase.SizeUp() // sets Actual size based on styles

Callers 1

SizeDownMethod · 0.95

Calls 5

FontRenderMethod · 0.80
SetHTMLMethod · 0.80
LayoutMethod · 0.80
SizeMethod · 0.65
CeilMethod · 0.45

Tested by

no test coverage detected