draw2dsvg/gc.go
func (gc *GraphicContext) drawString(text string, drawType drawType, x, y float64) float64 {
	switch gc.svg.FontMode {
	case PathFontMode:
		w := gc.CreateStringPath(text, x, y)
		gc.drawPaths(drawType)
		gc.Current.Path.Clear()
		return w
	case SvgFontMode:
		gc.embedSvgFont(text)
	}

	// create elements
	svgText := Text{}
	group := gc.newGroup(drawType)

	// set attrs to text element
	svgText.Text = text
	svgText.FontSize = gc.Current.FontSize
	svgText.X = x
	svgText.Y = y
	svgText.FontFamily = gc.Current.FontData.Name

	// attach to group
	group.Texts = []*Text{&svgText}
	left, _, right, _ := gc.GetStringBounds(text)
	return right - left
}
func (gc *GraphicContext) drawString(text string, drawType drawType, x, y float64) float64 {
	switch gc.svg.FontMode {
	case PathFontMode:
		w := gc.CreateStringPath(text, x, y)
		gc.drawPaths(drawType)
		gc.Current.Path.Clear()
		return w
	case SvgFontMode:
		gc.embedSvgFont(text)
	}

	// create elements
	svgText := Text{}
	group := gc.newGroup(drawType)

	// set attrs to text element
	svgText.Text = text
	svgText.FontSize = gc.Current.FontSize
	svgText.X = x
	svgText.Y = y
	svgText.FontFamily = gc.Current.FontData.Name

	// attach to group
	group.Texts = []*Text{&svgText}
	left, _, right, _ := gc.GetStringBounds(text)
	return right - left
}
// Add text element to svg and returns its expected width