MCPcopy Index your code
hub / github.com/gonum/plot / TestFontWidth

Function TestFontWidth

font/font_test.go:120–162  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

118}
119
120func TestFontWidth(t *testing.T) {
121 cache := font.NewCache(liberation.Collection())
122 fnt := cache.Lookup(font.Font{Typeface: "Liberation", Variant: "Serif"}, 12)
123
124 for _, tc := range []struct {
125 txt string
126 want font.Length
127 }{
128 // values obtained when gonum/plot used the package
129 // github.com/freetype/truetype for handling fonts.
130 {" ", 3},
131 {"i", 3.333984375},
132 {"q", 6},
133 {"A", 8.666015625},
134 {"F", 6.673828125},
135 {"T", 7.330078125},
136 {"V", 8.666015625},
137 {"Δ", 7.716796875},
138 {"∇", 9.333984375},
139 {" ", 6},
140 {"AA", 17.33203125},
141 {"Aq", 14.666015625},
142 {"Fi", 10.0078125},
143 {"Ti", 10.2421875},
144 {"AV", 15.78515625},
145 {"A∇", 18},
146 {"VA", 15.78515625},
147 {"VΔ", 16.3828125},
148 {"∇Δ", 17.05078125},
149 {" ", 9},
150 {"T T", 17.2265625},
151 } {
152 t.Run(tc.txt, func(t *testing.T) {
153 got := fnt.Width(tc.txt)
154 if got, want := got, tc.want; got != want {
155 t.Fatalf(
156 "invalid width: got=%v, want=%v",
157 got, want,
158 )
159 }
160 })
161 }
162}
163
164func TestFontKern(t *testing.T) {
165 cache := font.NewCache(liberation.Collection())

Callers

nothing calls this directly

Calls 4

LookupMethod · 0.95
NewCacheFunction · 0.92
CollectionFunction · 0.92
WidthMethod · 0.45

Tested by

no test coverage detected