string-to-svg
Version:
Convert text to SVG path without native dependence.
35 lines (32 loc) • 1.26 kB
TypeScript
import { Font } from 'opentype.js';
type Anchor = 'left' | 'center' | 'right' | 'top' | 'middle' | 'bottom' | 'left baseline' | 'left top' | 'left middle' | 'left bottom' | 'center top' | 'center middle' | 'center bottom' | 'right top' | 'right middle' | 'right bottom';
interface STSOptions {
font?: Font;
x?: number;
y?: number;
fontSize?: number;
anchor?: Anchor;
kerning?: boolean;
letterSpacing?: number;
tracking?: number;
attributes?: Record<string, string>;
beforePath?: string;
afterPath?: string;
}
type STSOptionsWithFont = STSOptions & {
font: Font;
};
declare function getD(text: string, options: STSOptionsWithFont): string;
declare function getPath(text: string, options: STSOptionsWithFont): string;
declare function getHeight(fontSize: number, font: Font): number;
declare function getWidth(text: string, options: STSOptionsWithFont): number;
declare function getMetrics(text: string, options: STSOptionsWithFont): {
x: number;
y: number;
baseline: number;
width: number;
height: number;
ascender: number;
descender: number;
};
export { Anchor as A, STSOptionsWithFont as S, getHeight as a, getMetrics as b, getPath as c, getWidth as d, STSOptions as e, getD as g };