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

Function TestText

paint/text_test.go:16–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestText(t *testing.T) {
17 size := image.Point{100, 40}
18 sizef := math32.Vector2FromPoint(size)
19 RunTest(t, "text", size.X, size.Y, func(pc *Context) {
20 pc.BlitBox(math32.Vector2{}, sizef, colors.Uniform(colors.White))
21 tsty := &styles.Text{}
22 tsty.Defaults()
23 fsty := &styles.FontRender{}
24 fsty.Defaults()
25 fsty.Size.Dp(60)
26
27 txt := &Text{}
28 txt.SetHTML("This is <a>HTML</a> <b>formatted</b> <i>text</i>", fsty, tsty, &pc.UnitContext, nil)
29
30 tsz := txt.Layout(tsty, fsty, &pc.UnitContext, sizef)
31 _ = tsz
32 // if tsz.X != 100 || tsz.Y != 40 {
33 // t.Errorf("unexpected text size: %v", tsz)
34 // }
35 txt.HasOverflow = true
36 txt.Render(pc, math32.Vector2{})
37 })
38}

Callers

nothing calls this directly

Calls 10

DefaultsMethod · 0.95
DefaultsMethod · 0.95
SetHTMLMethod · 0.95
LayoutMethod · 0.95
RenderMethod · 0.95
Vector2FromPointFunction · 0.92
UniformFunction · 0.92
RunTestFunction · 0.85
BlitBoxMethod · 0.80
DpMethod · 0.45

Tested by

no test coverage detected