Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing Error #59

Open
smithi01 opened this issue Nov 30, 2024 · 1 comment
Open

Parsing Error #59

smithi01 opened this issue Nov 30, 2024 · 1 comment

Comments

@smithi01
Copy link

Hi.

Thanks so much for this package.

I am downloading svg data (for station logos in a radio app), and parsing using:

image = SVG(data: httpData)?.rasterize(with: CGSize(width: 64.0 * 3.0, height: 64.0 * 3.0), scale: 3.0, insets: UIEdgeInsets(top: -8, left: -8, bottom: -8, right: -8))

I get the following printed to the console:

[parsing error] <style> line: 2 column: 9 error: invalid

The link to the svg and the svg are below.

The svg looks ok to me, but I am far from an expert. It opens ok in Inkscape. Should SwiftDraw be able to parse this svg without an error?

Cheers,
Ian

Link is https://www.abc.net.au/core-assets/radionational/favicon.svg

svg is

<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128">
  <style>
  g { fill: #000; }

  @media (prefers-color-scheme: dark) {
    g { fill: #fff; }
  }
  </style><g fill-rule="nonzero"><path d="M18.873 17.186c4.686-.062 10.396 1.676 14.243 6.423 1.738 1.676 4.934 9.806 4.934 9.806l19.177 50.952c2.482 6.113 9.899 6.578 12.07.465l5.959-16.073 10.177 26.779c-4.933 9.03-9.743 11.233-15.422 13.312-6.61 2.079-14.522 1.396-20.2-2.141-1.893-1.21-6.827-4.438-10.178-12.537l-20.17-56.475v51.417l7.571-21.72 9.713 27.12c-1.427 6.237-5.927 11.419-11.14 13.87-5.74 2.7-12.567 1.738-17.75-1.52C2.677 103.016 1.218 98.517 1 90.48l.062-55.607c.59-9.247 6.516-14.305 11.698-16.57 2.39-.838 3.383-1.086 6.113-1.117z"/><path d="M107.248 109.905c-4.686.093-10.395-1.676-14.243-6.424-1.738-1.675-4.934-9.805-4.934-9.805l-19.208-50.92c-2.482-6.114-9.898-6.58-12.07-.466l-5.958 16.073-10.147-26.779c4.934-9.03 9.743-11.233 15.422-13.312 6.61-2.079 14.522-1.365 20.2 2.141 1.893 1.21 6.827 4.438 10.178 12.537l20.201 56.444V38.008l-7.54 21.72-9.713-27.12c1.428-6.237 5.927-11.419 11.171-13.87 5.71-2.7 12.568-1.738 17.719 1.52 5.15 3.817 6.609 8.347 6.826 16.353l-.062 55.606c-.59 9.247-6.516 14.305-11.698 16.57-2.39.838-3.414 1.087-6.144 1.118z"/></g>
</svg>
@swhitty
Copy link
Owner

swhitty commented Dec 2, 2024

Hi thanks for reporting this.

I've checked the SVG and SwiftDraw does not support the @media selector within the <style> tag — so it just skips over it.

The error is more like an FYI but maybe the message could be clearer here with something like

warning: ignoring unrecognised css selector @media

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants