UNPKG

text-to-svg-hb

Version:

Convert text to SVG paths with HarfBuzz support for complex text shaping

32 lines (31 loc) 818 B
export type TextDirection = 'ltr' | 'rtl'; export type TextAlign = 'left' | 'center' | 'right'; export type ScriptCode = string; /** * BCP 47 language tag, e.g., 'en', 'ar', 'hi', 'zh-Hans', 'fr-CA', etc. * See: https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry */ export type LanguageTag = string; export interface TextToSVGOptions { fontPath: string; fontSize: number; maxWidth: number; lineHeight?: number; textAlign?: TextAlign; color?: string; direction?: TextDirection; script?: ScriptCode; language?: LanguageTag; combinePaths?: boolean; } export interface SVGResult { canvasWidth: number; canvasHeight: number; svg: string; } export interface ShapedGlyph { g: number; ax: number; dx: number; dy: number; }