func (gc *GraphicContext) CreateStringPath(s string, x, y float64) (cursor float64) {
	f, err := gc.loadCurrentFont()
	if err != nil {
		log.Println(err)
		return 0.0
	}
	startx := x
	prev, hasPrev := truetype.Index(0), false
	for _, rune := range s {
		index := f.Index(rune)
		if hasPrev {
			x += fUnitsToFloat64(f.Kern(fixed.Int26_6(gc.Current.Scale), prev, index))
		}
		err := gc.drawGlyph(index, x, y)
		if err != nil {
			log.Println(err)
			return startx - x
		}
		x += fUnitsToFloat64(f.HMetric(fixed.Int26_6(gc.Current.Scale), index).AdvanceWidth)
		prev, hasPrev = index, true
	}

	return x - startx
}
func (gc *GraphicContext) CreateStringPath(s string, x, y float64) (cursor float64) {
	f, err := gc.loadCurrentFont()
	if err != nil {
		log.Println(err)
		return 0.0
	}
	startx := x
	prev, hasPrev := truetype.Index(0), false
	for _, rune := range s {
		index := f.Index(rune)
		if hasPrev {
			x += fUnitsToFloat64(f.Kern(fixed.Int26_6(gc.Current.Scale), prev, index))
		}
		err := gc.drawGlyph(index, x, y)
		if err != nil {
			log.Println(err)
			return startx - x
		}
		x += fUnitsToFloat64(f.HMetric(fixed.Int26_6(gc.Current.Scale), index).AdvanceWidth)
		prev, hasPrev = index, true
	}

	return x - startx
}
func ( gc * GraphicContext ) CreateStringPath ( s string , x , y float64 ) ( cursor float64 ) { f , err := gc . loadCurrentFont ( ) if err != nil { log . Println ( err ) return 0.0 } startx := x prev , hasPrev := truetype . Index ( 0 ) , false for _ , rune := range s { index := f . Index ( rune ) if hasPrev { x += fUnitsToFloat64 ( f . Kern ( fixed . Int26_6 ( gc . Current . Scale ) , prev , index ) ) } err := gc . drawGlyph ( index , x , y ) if err != nil { log . Println ( err ) return startx - x } x += fUnitsToFloat64 ( f . HMetric ( fixed . Int26_6 ( gc . Current . Scale ) , index ) . AdvanceWidth ) prev , hasPrev = index , true } return x - startx }
// NOTE following  two functions and soe other further below copied from dwra2d{img|gl}
// TODO move them all to common draw2dbase?
// CreateStringPath creates a path from the string s at x, y, and returns the string width.
// The text is placed so that the left edge of the em square of the first character of s
// and the baseline intersect at x, y. The majority of the affected pixels will be
// above and to the right of the point, but some may be below or to the left.
// For example, drawing a string that starts with a 'J' in an italic font may
// affect pixels below and left of the point.
NOTE following two functions and soe other further below copied from dwra2d { img|gl } TODO move them all to common draw2dbase? CreateStringPath creates a path from the string s at x y and returns the string width . The text is placed so that the left edge of the em square of the first character of s and the baseline intersect at x y . The majority of the affected pixels will be above and to the right of the point but some may be below or to the left . For example drawing a string that starts with a J in an italic font may affect pixels below and left of the point .