Skip to content

pantoken / formats/icon-font/src / svgToGlyphPath

Function: svgToGlyphPath()

svgToGlyphPath(svg): GlyphPath

Beta

Produce a filled glyph path for an icon SVG.

Parameters

svg

string

Inline SVG markup.

Returns

GlyphPath

The filled path d (in viewBox coordinates) and the viewBox size.

Example

Outline a stroke-based (Lucide) icon and a fill-based icon

ts
import { svgToGlyphPath } from "@pantoken/icon-font";
import { getIcon } from "@pantoken/icons";

const { d, width, height } = svgToGlyphPath(getIcon("arrow-left")!.svg);
// d: a single filled path; width/height: the viewBox size (e.g. 24, 24)