@@ -1,18 +1,14 @@
|
||||
import { getFontFamily } from "@/pages/editor/utils/fontFamily";
|
||||
|
||||
/** CSS font-weight values that match irancell @font-face declarations. */
|
||||
/** CSS font-weight values for canvas/Konva text rendering. */
|
||||
export const getCssFontWeight = (fontWeight?: string): number => {
|
||||
if (!fontWeight || fontWeight === "normal") return 300;
|
||||
if (fontWeight === "bold" || fontWeight === "bolder") return 600;
|
||||
if (!fontWeight || fontWeight === "normal") return 400;
|
||||
if (fontWeight === "bold" || fontWeight === "bolder") return 700;
|
||||
|
||||
const n = parseInt(fontWeight, 10);
|
||||
if (!Number.isNaN(n)) {
|
||||
if (n >= 600) return 600;
|
||||
if (n <= 200) return 200;
|
||||
return 300;
|
||||
}
|
||||
if (!Number.isNaN(n)) return n;
|
||||
|
||||
return 300;
|
||||
return 400;
|
||||
};
|
||||
|
||||
/** Konva.Text uses `fontStyle: bold` (canvas keyword), not numeric weight. */
|
||||
|
||||
Reference in New Issue
Block a user