Exemple #1
0
func GetFontHeight(fd draw2d.FontData, size float64) (height float64) {
	font := draw2d.GetFont(fd)
	fupe := font.FUnitsPerEm()
	bounds := font.Bounds(fupe)
	height = float64(bounds.YMax-bounds.YMin) * size / float64(fupe)
	return
}
Exemple #2
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)
}