本文整理匯總了Golang中code/google/com/p/plotinum/vg.Font類的典型用法代碼示例。如果您正苦於以下問題:Golang Font類的具體用法?Golang Font怎麽用?Golang Font使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Font類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: FillString
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: FillString
func (c *Canvas) FillString(font vg.Font, x, y vg.Length, str string) {
c.gc.Save()
c.gc.Translate(x.Dots(c), (y + font.Extents().Ascent).Dots(c))
c.gc.Scale(1, -1)
c.gc.DrawImage(c.textImage(font, str))
c.gc.Restore()
}
示例3: FillString
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: FillString
func (c *XImgCanvas) 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.Translate(x.Dots(c), y.Dots(c))
c.gc.Scale(1, -1)
c.gc.FillString(str)
}
示例5: FillString
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(e), pr, y.Dots(e))
fmt.Fprintf(e.buf, "(%s) show\n", str)
}
示例6: textImage
func (c *Canvas) textImage(font vg.Font, str string) *image.RGBA {
w := font.Width(str).Dots(c)
h := font.Extents().Height.Dots(c)
img := image.NewRGBA(image.Rect(0, 0, int(w+0.5), int(h+0.5)))
gc := draw2d.NewGraphicContext(img)
gc.SetDPI(int(c.DPI()))
gc.SetFillColor(c.color[len(c.color)-1])
gc.SetStrokeColor(c.color[len(c.color)-1])
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
}
gc.SetFontData(data)
gc.SetFontSize(font.Size.Points())
gc.MoveTo(0, h+font.Extents().Descent.Dots(c))
gc.FillString(str)
return img
}