fix text in viewer
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
/** CSS font-weight values that match irancell @font-face declarations. */
|
||||
export const getCssFontWeight = (fontWeight?: string): number => {
|
||||
if (!fontWeight || fontWeight === "normal") return 300;
|
||||
if (fontWeight === "bold" || fontWeight === "bolder") return 600;
|
||||
|
||||
const n = parseInt(fontWeight, 10);
|
||||
if (!Number.isNaN(n)) {
|
||||
if (n >= 600) return 600;
|
||||
if (n <= 200) return 200;
|
||||
return 300;
|
||||
}
|
||||
|
||||
return 300;
|
||||
};
|
||||
|
||||
export const isSingleLineText = (text?: string): boolean => !text?.includes("\n");
|
||||
|
||||
/** Scaled width for viewer text; adds slack so CSS does not wrap tighter than Konva. */
|
||||
export const getScaledTextWidth = (
|
||||
width: number | undefined,
|
||||
scale: number,
|
||||
singleLine: boolean,
|
||||
): number | undefined => {
|
||||
if (!width) return undefined;
|
||||
const scaled = Math.ceil(width * scale);
|
||||
return singleLine ? scaled + 2 : scaled;
|
||||
};
|
||||
Reference in New Issue
Block a user