示例#1
0
文件: vgpdf.go 项目: zzn01/plot
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) {
	fontStr, ok := fontMap[font.Name()]
	if !ok {
		panic(fmt.Sprintf("Unknown font: %s", font.Name()))
	}
	sty := style(fontStr,
		elm("font-size", "medium", "%.*gpt", pr, font.Size.Points()),
		elm("fill", "#000000", colorString(c.cur().color)))
	if sty != "" {
		sty = "\n\t" + sty
	}
	fmt.Fprintf(c.buf, `<text x="%.*g" y="%.*g" transform="scale(1, -1)"%s>%s</text>`+"\n",
		pr, x.Dots(c), pr, -y.Dots(c), sty, str)
}
示例#4
0
文件: vgimg.go 项目: kc-cylon5/gogui
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.DPI()), y.Dots(c.DPI()))
	c.gc.Scale(1, -1)
	c.gc.FillString(str)
}
示例#5
0
文件: vgeps.go 项目: zzn01/plot
func (e *Canvas) FillString(fnt vg.Font, x, y vg.Length, str string) {
	if e.cur().font != fnt.Name() || e.cur().fsize != fnt.Size {
		e.cur().font = fnt.Name()
		e.cur().fsize = fnt.Size
		fmt.Fprintf(e.buf, "/%s findfont %.*g scalefont setfont\n",
			fnt.Name(), pr, fnt.Size)
	}
	fmt.Fprintf(e.buf, "%.*g %.*g moveto\n", pr, x.Dots(DPI), pr, y.Dots(DPI))
	fmt.Fprintf(e.buf, "(%s) show\n", str)
}