Skip to content

Inlined SVG without xmlns namespace cannot be rendered. #73

Closed
@xhruso00

Description

@xhruso00

This SVG is incorrect if standalone as the namespace is required. However there is no requirement for namespace if it's inlined.

AppKit correctly renders it (_NSSVGImageRep).

        let path = Bundle.main.path(forResource: "brokenSVG", ofType: "svg")!
        let data = try! Data(contentsOf: URL(fileURLWithPath: path))
        let image1 = NSImage(svgNamed: "brokenSVG.svg")
        let image = NSImage(data: data)
        print(image1)
        print(image)
<svg width="24" height="24" viewBox="0 0 48 48">
	<g fill="#00ff00" >
		<path d="M38.9085938,36.3832764 C38.9085938,37.7779998 37.7772516,38.9078455 36.3840246,38.9078455 L11.5049719,38.9078455 C10.1102484,38.9078455 8.97890625,37.7779998 8.97890625,36.3832764 L8.97890625,11.5042236 C8.97890625,10.1095002 10.1102484,8.97965449 11.5049719,8.97965449 L36.3840246,8.97965449 C37.7772516,8.97965449 38.9085938,10.1095002 38.9085938,11.5042236 L38.9085938,36.3832764 Z M39.8843016,0.000748242187 L8.00319844,0.000748242187 C3.58408008,0.000748242187 0,3.58333184 0,8.0024502 L0,39.8850498 C0,44.3041682 3.58408008,47.8867518 8.00319844,47.8867518 L39.8843016,47.8867518 C44.3034199,47.8867518 47.8875,44.3041682 47.8875,39.8850498 L47.8875,8.0024502 C47.8875,3.58333184 44.3034199,0.000748242187 39.8843016,0.000748242187 L39.8843016,0.000748242187 Z">
		</path>
		<path d="M28.4332031,17.9578125 L19.4542969,17.9578125 C18.6521812,17.9578125 17.9578125,18.6506848 17.9578125,19.4542969 L17.9578125,28.4332031 C17.9578125,29.2383117 18.6521812,29.9296875 19.4542969,29.9296875 L28.4332031,29.9296875 C29.2338223,29.9296875 29.9296875,29.2383117 29.9296875,28.4332031 L29.9296875,19.4542969 C29.9296875,18.6506848 29.2338223,17.9578125 28.4332031,17.9578125">
		</path>
	</g>
</svg>

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions