| 16 | ) |
| 17 | |
| 18 | func TestPlainText(t *testing.T) { |
| 19 | type box struct{ w, h, d vg.Length } |
| 20 | |
| 21 | fonts := font.NewCache(liberation.Collection()) |
| 22 | |
| 23 | tr12 := font.Font{Variant: "Serif", Size: 12} |
| 24 | ti12 := font.Font{Variant: "Serif", Size: 12, Style: stdfnt.StyleItalic} |
| 25 | tr42 := font.Font{Variant: "Serif", Size: 42} |
| 26 | |
| 27 | for _, tc := range []struct { |
| 28 | txt string |
| 29 | fnt font.Font |
| 30 | box []box |
| 31 | w vg.Length |
| 32 | h vg.Length |
| 33 | }{ |
| 34 | { |
| 35 | txt: "", |
| 36 | box: []box{ |
| 37 | {0, 10.693359375, 2.595703125}, |
| 38 | }, |
| 39 | w: 0, |
| 40 | h: 13.2890625, |
| 41 | }, |
| 42 | { |
| 43 | txt: " ", |
| 44 | box: []box{{3, 10.693359375, 2.595703125}}, |
| 45 | w: 3, |
| 46 | h: 13.2890625, |
| 47 | }, |
| 48 | { |
| 49 | txt: "hello", |
| 50 | box: []box{{23.994140625, 10.693359375, 2.595703125}}, |
| 51 | w: 23.994140625, |
| 52 | h: 13.2890625, |
| 53 | }, |
| 54 | { |
| 55 | txt: "hello", |
| 56 | fnt: ti12, |
| 57 | box: []box{{23.994140625, 10.693359375, 2.595703125}}, |
| 58 | w: 23.994140625, |
| 59 | h: 13.2890625, |
| 60 | }, |
| 61 | { |
| 62 | txt: "hello", |
| 63 | fnt: tr42, |
| 64 | box: []box{{83.9794921875, 37.4267578125, 9.0849609375}}, |
| 65 | w: 83.9794921875, |
| 66 | h: 46.51171875, |
| 67 | }, |
| 68 | { |
| 69 | txt: "hello\n", |
| 70 | box: []box{{23.994140625, 10.693359375, 2.595703125}}, |
| 71 | w: 23.994140625, |
| 72 | h: 13.2890625, |
| 73 | }, |
| 74 | { |
| 75 | txt: "Agg", |