Example #1
0
func (l *Label) draw(gc draw2d.GraphicContext) {
	gc.SetStrokeColor(color.Black)

	font := draw2d.GetFont(gc.GetFontData())
	bounds := font.Bounds()
	height := float64(bounds.YMax-bounds.YMin) * l.FontSize / float64(font.UnitsPerEm())

	offset := l.Size.Y - (l.Size.Y-height)/2

	safeRect(gc, Coord{0, 0}, l.Size)
	gc.FillStroke()
	gc.Translate(10, offset)
	gc.SetFontSize(l.FontSize)
	gc.FillString(l.Text)
}