diff options
| -rw-r--r-- | svgbasic.go | 8 | ||||
| -rw-r--r-- | svgwrite.go | 4 | 
2 files changed, 8 insertions, 4 deletions
| diff --git a/svgbasic.go b/svgbasic.go index 0eea754..51a93fe 100644 --- a/svgbasic.go +++ b/svgbasic.go @@ -34,7 +34,8 @@ func init() {  		"M", " M ", "m", " m ",  		"H", " H ", "h", " h ",  		"V", " V ", "v", " v ", -		"Q", " Q ", "q", " q ", ) +		"Q", " Q ", "q", " q ", +		"Z", " Z ", "z", " z ")  }  // SVGBasicSegmentType describes a single curve or position segment @@ -103,7 +104,8 @@ func absolutizePath(segs []SVGBasicSegmentType) {  			segPtr.Arg[0] += y  			segPtr.Cmd = 'V'  			y += seg.Arg[0] - +		case 'z': +			segPtr.Cmd = 'Z'  		}  	}  } @@ -161,7 +163,7 @@ func pathParse(pathStr string) (segs []SVGBasicSegmentType, err error) {  				case 'V', 'v': // Absolute/relative vertical line to: x  					setup(1)  				case 'Z', 'z': // closepath instruction (takes no arguments) -					break +					segs = append(segs, seg)  				default:  					err = fmt.Errorf("expecting SVG path command at position %d, got %s", j, str)  				} diff --git a/svgwrite.go b/svgwrite.go index d438393..7045199 100644 --- a/svgwrite.go +++ b/svgwrite.go @@ -29,6 +29,7 @@ func (f *Fpdf) SVGBasicWrite(sb *SVGBasicType, scale float64) {  	var cx0, cy0, cx1, cy1 float64  	var path []SVGBasicSegmentType  	var seg SVGBasicSegmentType +	var startX, startY float64  	sval := func(origin float64, arg int) float64 {  		return origin + scale*seg.Arg[arg]  	} @@ -48,6 +49,7 @@ func (f *Fpdf) SVGBasicWrite(sb *SVGBasicType, scale float64) {  			switch seg.Cmd {  			case 'M':  				x, y = val(0) +				startX, startY = x, y  				f.SetXY(x, y)  			case 'L':  				newX, newY = val(0) @@ -73,7 +75,7 @@ func (f *Fpdf) SVGBasicWrite(sb *SVGBasicType, scale float64) {  				f.Line(x, y, x, newY)  				y = newY  			case 'Z': -				f.Line(x, y, originX, originY) +				f.Line(x, y, startX, startY)  			default:  				f.SetErrorf("Unexpected path command '%c'", seg.Cmd)  			} | 
