more work

This commit is contained in:
Dylan Pizzo
2025-01-06 22:13:53 -05:00
parent 4e79fd38a1
commit 0099624165
5 changed files with 96 additions and 15 deletions

41
src/fonthelper.ts Normal file
View File

@ -0,0 +1,41 @@
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);
};