UNPKG

string-to-svg

Version:

Convert text to SVG path without native dependence.

35 lines (33 loc) 716 B
import { getD, getHeight, getMetrics, getPath, getWidth } from "./chunk-3RXCOM3X.js"; // src/browser.ts import { Font, parse } from "opentype.js"; function loadFont(font) { return parse(font); } function getSVG(text, options) { const metrics = getMetrics(text, options); let svg = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${metrics.width}" height="${metrics.height}">`; if (options.beforePath) svg += options.beforePath; svg += getPath(text, options); if (options.afterPath) svg += options.afterPath; svg += "</svg>"; return svg; } export { Font, getD, getHeight, getMetrics, getPath, getSVG, getWidth, loadFont };