From fec5be6506e29af765c43b7d6ef9191e9d254d16 Mon Sep 17 00:00:00 2001 From: Will Charczuk Date: Sun, 26 Mar 2017 16:27:15 -0700 Subject: [PATCH] adding helper --- vector_renderer.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/vector_renderer.go b/vector_renderer.go index e6f060f..c08fea1 100644 --- a/vector_renderer.go +++ b/vector_renderer.go @@ -19,10 +19,11 @@ func SVG(width, height int) (Renderer, error) { canvas := newCanvas(buffer) canvas.Start(width, height) return &vectorRenderer{ - b: buffer, - c: canvas, - s: &Style{}, - p: []string{}, + b: buffer, + c: canvas, + s: &Style{}, + p: []string{}, + dpi: DefaultDPI, }, nil } @@ -288,7 +289,9 @@ func (c *canvas) styleAsSVG(s Style) string { pieces = append(pieces, "stroke:none") } - if !fc.IsZero() { + if !fnc.IsZero() { + pieces = append(pieces, "fill:"+fnc.String()) + } else if !fc.IsZero() { pieces = append(pieces, "fill:"+fc.String()) } else { pieces = append(pieces, "fill:none") @@ -298,10 +301,6 @@ func (c *canvas) styleAsSVG(s Style) string { pieces = append(pieces, "font-size:"+fmt.Sprintf("%.1fpx", drawing.PointsToPixels(c.dpi, fs))) } - if !fnc.IsZero() { - pieces = append(pieces, "fill:"+fnc.String()) - } - if s.Font != nil { pieces = append(pieces, c.getFontFace(s)) }