Пример #1
0
func (c *Canvas) FillString(fnt vg.Font, x, y vg.Length, str string) {
	t := new(pdf.Text)
	t.SetFont(fnt.Name(), unit(fnt.Size))
	t.NextLineOffset(unit(x), unit(y))
	t.Text(str)
	c.page.DrawText(t)
}
Пример #2
0
// FillString implements the FillString method of the vg.Canvas interface.
func (c *Canvas) FillString(font vg.Font, x, y vg.Length, str string) {
	c.append(&FillString{
		Font: font.Name(),
		Size: font.Size,
		X:    x, Y: y,
		String: str,
	})
}
Пример #3
0
func (c *Canvas) FillString(font vg.Font, x, y vg.Length, str string) {
	c.gc.Save()
	defer c.gc.Restore()

	data, ok := fontMap[font.Name()]
	if !ok {
		panic(fmt.Sprintf("Font name %s is unknown", font.Name()))
	}
	if !registeredFont[font.Name()] {
		draw2d.RegisterFont(data, font.Font())
		registeredFont[font.Name()] = true
	}
	c.gc.SetFontData(data)
	c.gc.SetFontSize(font.Size.Points())
	c.gc.Translate(x.Dots(c), y.Dots(c))
	c.gc.Scale(1, -1)
	c.gc.FillString(str)
}