This commit is contained in:
Aakansha Doshi 2023-03-01 20:21:02 +05:30
parent caa22dd4c3
commit b3068a5248

View File

@ -23,6 +23,7 @@ import {
} from "./bounds";
import {
isArrowElement,
isBoundToContainer,
isFreeDrawElement,
isLinearElement,
isTextElement,
@ -44,6 +45,7 @@ import {
getBoundTextElementId,
handleBindTextResize,
getMaxContainerWidth,
getContainerElement,
} from "./textElement";
export const normalizeAngle = (angle: number): number => {
@ -193,8 +195,15 @@ const measureFontSizeFromWidth = (
nextWidth: number,
): number | null => {
// We only use width to scale font on resize
const width = element.width;
let width = element.width;
const hasContainer = isBoundToContainer(element);
if (hasContainer) {
const container = getContainerElement(element);
if (container) {
width = getMaxContainerWidth(container);
}
}
const nextFontSize = element.fontSize * (nextWidth / width);
if (nextFontSize < MIN_FONT_SIZE) {
return null;