-
Notifications
You must be signed in to change notification settings - Fork 103
Open
Description
this is the test svg:
<svg width="16" height="24" viewBox="0 0 16 24" style="color: red;" xmlns="http://www.w3.org/2000/svg">
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" color="currentColor"><path d="M5.533 17c-1.422 2.006-1.78 3.065-1.38 3.916q.06.126.14.243C4.862 22 6.34 22 9.295 22h5.408c2.955 0 4.432 0 5.004-.841q.08-.118.139-.243c.4-.85.042-1.91-1.38-3.916"/><path d="M12.998 7h-1.996c-2.87 0-4.805 3.07-3.674 5.828a1 1 0 0 0 .918.633h.703c.237 0 .444.17.501.41l.905 3.786c.189.79.867 1.343 1.645 1.343s1.456-.554 1.645-1.343l.905-3.786a.52.52 0 0 1 .5-.41h.704a1 1 0 0 0 .918-.633C17.804 10.069 15.869 7 12.999 7"/><path d="M14.5 4.5a2.5 2.5 0 1 1-5 0a2.5 2.5 0 0 1 5 0"/></g>
</svg>it seems not parse style in svg tag, and will recursive at this function:
static func parseColor(_ string: String, _ style: [String: String]) -> SVGColor? {
let normalized = string.replacingOccurrences(of: " ", with: "")
if normalized == "none" || normalized == "transparent" {
return .none
} else if normalized == "currentColor", let currentColor = style["color"] {
return parseColor(currentColor, style)
} else if let defaultColor = SVGColor.by(name: normalized) {
return defaultColor
} else if normalized.hasPrefix("rgb") {
return parseRGBNotation(colorString: normalized)
} else {
return createColorFromHex(normalized)
}
}Metadata
Metadata
Assignees
Labels
No labels