Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
Fix font weight detection of uploaded fonts (#2175)
Bogdan Chadkin5af1ba168fd2
diff --git a/packages/fonts/src/font-data.ts b/packages/fonts/src/font-data.tsindex 9a968a5bef..de4ea2f7a9 100644--- a/packages/fonts/src/font-data.ts+++ b/packages/fonts/src/font-data.ts@@ -25,9 +25,8 @@ export const parseSubfamily = (subfamily: string) => {}let weight: FontWeight = "400";for (weight in fontWeights) {- const { name } = fontWeights[weight];- const { alt } = fontWeights[weight];- if (subfamilyLow.includes(name) || subfamilyLow.includes(alt)) {+ const { names } = fontWeights[weight];+ if (names.some((name) => subfamilyLow.includes(name))) {break;}}diff --git a/packages/fonts/src/font-weights.ts b/packages/fonts/src/font-weights.tsindex 19bcc1586b..06ceacb85b 100644--- a/packages/fonts/src/font-weights.ts+++ b/packages/fonts/src/font-weights.ts@@ -1,52 +1,40 @@export const fontWeights = {"100": {label: "Thin",- name: "thin",- alt: "hairline",+ names: ["thin", "hairline"],},"200": {label: "Extra Light",- name: "extra light",- alt: "ultra light",+ names: ["extra light", "extralight", "ultra light", "ultralight"],},"300": {label: "Light",- name: "light",- alt: "light",+ names: ["light"],},"400": {label: "Normal",- name: "normal",- alt: "normal",+ names: ["normal", "regular"],},"500": {label: "Medium",- name: "medium",- alt: "medium",+ names: ["medium"],},"600": {label: "Semi Bold",- name: "semi bold",- alt: "demi bold",+ names: ["semi bold", "semibold", "demi bold", "demibold"],},"700": {label: "Bold",- name: "bold",- alt: "bold",+ names: ["bold", "bold"],},"800": {label: "Extra Bold",- name: "extra bold",- alt: "ultra bold",+ names: ["extra bold", "extrabold", "ultra bold", "ultrabold"],},"900": {label: "Black",- name: "black",- alt: "heavy",+ names: ["black", "heavy"],},} as const;export type FontWeight = keyof typeof fontWeights;-export type FontWeightKeyword =- | (typeof fontWeights)[FontWeight]["name"]- | (typeof fontWeights)[FontWeight]["alt"];