GenerallyHelpfulSoftware / SVGgh

A framework for using SVG artwork in iOS Apps. Includes a UIView and a button class, printing and PDF export.
MIT License
141 stars 38 forks source link

Black Text #13

Closed ktorimaru closed 8 years ago

ktorimaru commented 8 years ago

I'm having a strange problem. My SVGs are rendering in a SVGDocumentView correctly except the paths that illustrate Black Text. Everything else that should be black is there. Any ideas?

grhowes commented 8 years ago

Could you send me an example?

ktorimaru commented 8 years ago

Hi Glenn:

Thanks for such a quick response!

override func viewDidLoad() {

    super.viewDidLoad()

    // Do any additional setup after loading the view, typically from a

nib.

    let svgView = SVGDocumentView.init(frame: CGRectMake(200, 200, 150,

200))

    svgView.artworkPath = "AC"

    svgView.backgroundColor = UIColor.clearColor()

    self.view.addSubview(svgView)

}

On Thu, Sep 24, 2015 at 1:53 PM, Glenn Howes notifications@github.com wrote:

Could you send me an example?

— Reply to this email directly or view it on GitHub https://github.com/GenerallyHelpfulSoftware/SVGgh/issues/13#issuecomment-143048049 .

grhowes commented 8 years ago

I meant could you send me the SVG.

ktorimaru commented 8 years ago

Sorry, I did attach it. Did you not receive it?

It is attached to this.

On Thu, Sep 24, 2015 at 2:11 PM, Glenn Howes notifications@github.com wrote:

I meant could you send me the SVG.

— Reply to this email directly or view it on GitHub https://github.com/GenerallyHelpfulSoftware/SVGgh/issues/13#issuecomment-143052199 .

ktorimaru commented 8 years ago

Same thing happens here:

    let svgRenderer = SVGRenderer.init(contentsOfURL: NSBundle.

mainBundle().URLForResource("AC", withExtension: "svg")!)

    let img = svgRenderer.asImageWithSize(CGSizeMake(150, 200),

andScale: 1)

    let imgView = UIImageView(image: img)

    imgView.center = CGPointMake(75, 300)

    self.view.addSubview(imgView)

On Thu, Sep 24, 2015 at 2:14 PM, Ken Torimaru ken@torimaru.com wrote:

Sorry, I did attach it. Did you not receive it?

It is attached to this.

On Thu, Sep 24, 2015 at 2:11 PM, Glenn Howes notifications@github.com wrote:

I meant could you send me the SVG.

— Reply to this email directly or view it on GitHub https://github.com/GenerallyHelpfulSoftware/SVGgh/issues/13#issuecomment-143052199 .

ktorimaru commented 8 years ago

https://dl.dropboxusercontent.com/u/2092395/AC.svg

On Thu, Sep 24, 2015 at 2:23 PM, Ken Torimaru ken@torimaru.com wrote:

Same thing happens here:

    let svgRenderer = SVGRenderer.init(contentsOfURL: NSBundle.

mainBundle().URLForResource("AC", withExtension: "svg")!)

    let img = svgRenderer.asImageWithSize(CGSizeMake(150, 200),

andScale: 1)

    let imgView = UIImageView(image: img)

    imgView.center = CGPointMake(75, 300)

    self.view.addSubview(imgView)

On Thu, Sep 24, 2015 at 2:14 PM, Ken Torimaru ken@torimaru.com wrote:

Sorry, I did attach it. Did you not receive it?

It is attached to this.

On Thu, Sep 24, 2015 at 2:11 PM, Glenn Howes notifications@github.com wrote:

I meant could you send me the SVG.

— Reply to this email directly or view it on GitHub https://github.com/GenerallyHelpfulSoftware/SVGgh/issues/13#issuecomment-143052199 .

grhowes commented 8 years ago

Hi Ken, it looks as though you've exposed a bug in the path rendering code, thank you.

     d="m 470.62543,-1041.6816 0,-2.8127 2.68028,0 5.70981,-30.0817 3.24983,0 6.2897,30.0817 2.1644,0 0,2.8127 -7.37513,0 0,-2.8127 1.99038,0 -0.79484,-4.6099 -7.44035,0 -0.57473,4.6099 1.99028,0 0,2.8127 -7.88963,0 z m 13.27957,-10.7064 -3.2345,-16.1007 -3.02962,16.1007 6.26412,0 z m 0,0"

The problem appears to be that after the "z" which closes the path there is an empty sub path that's appended with the "m 0,0". I'll see about fixing this, but in the meantime, you could remove the "m 0,0" at the end of the d parameter by hand.

ktorimaru commented 8 years ago

Glenn:

Thanks!

My workaround was to add a fill:#000000 to the problem SVG paths.

Ken

On Thu, Sep 24, 2015 at 4:44 PM, Glenn Howes notifications@github.com wrote:

Hi Ken, it looks as though you've exposed a bug in the path rendering code, thank you.

 d="m 470.62543,-1041.6816 0,-2.8127 2.68028,0 5.70981,-30.0817 3.24983,0 6.2897,30.0817 2.1644,0 0,2.8127 -7.37513,0 0,-2.8127 1.99038,0 -0.79484,-4.6099 -7.44035,0 -0.57473,4.6099 1.99028,0 0,2.8127 -7.88963,0 z m 13.27957,-10.7064 -3.2345,-16.1007 -3.02962,16.1007 6.26412,0 z m 0,0"

The problem appears to be that after the "z" which closes the path there is an empty sub path that's appended with the "m 0,0". I'll see about fixing this, but in the meantime, you could remove the "m 0,0" at the end of the d parameter by hand.

— Reply to this email directly or view it on GitHub https://github.com/GenerallyHelpfulSoftware/SVGgh/issues/13#issuecomment-143081233 .

grhowes commented 8 years ago

I've checked in a fix into the main line. The problem was with how I was handling paths that didn't have an explicit fill style and didn't have a terminating close path command. Thanks again for exposing the problem.

grhowes commented 8 years ago

Submitted cocoa pod 1.3 with this fixed.