42 lines
760 B
TypeScript
42 lines
760 B
TypeScript
import font from "npm:css-font";
|
|
|
|
export type FontInfo = {
|
|
style: "normal" | "italic" | "oblique";
|
|
variant: "normal" | "small-caps";
|
|
weight:
|
|
| "normal"
|
|
| "bold"
|
|
| "lighter"
|
|
| "bolder"
|
|
| "100"
|
|
| "200"
|
|
| "300"
|
|
| "400"
|
|
| "500"
|
|
| "600"
|
|
| "700"
|
|
| "800"
|
|
| "900";
|
|
stretch:
|
|
| "normal"
|
|
| "condensed"
|
|
| "semi-condensed"
|
|
| "extra-condensed"
|
|
| "ultra-condensed"
|
|
| "expanded"
|
|
| "semi-expanded"
|
|
| "extra-expanded"
|
|
| "ultra-expanded";
|
|
lineHeight: "normal" | number | string;
|
|
size: number | string;
|
|
family: string[];
|
|
};
|
|
|
|
export const parseFont = (fontString: string): FontInfo => {
|
|
return { ...font.parse(fontString) };
|
|
};
|
|
|
|
export const stringifyFont = (fontInfo: FontInfo): string => {
|
|
return font.stringify(fontInfo);
|
|
};
|