From fd379c2897063168f88f565ab17e3d1baff80b73 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Fri, 21 Apr 2023 13:20:18 +0530 Subject: [PATCH] add comment --- src/element/textElement.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/element/textElement.ts b/src/element/textElement.ts index 3eea27df6..5063d5767 100644 --- a/src/element/textElement.ts +++ b/src/element/textElement.ts @@ -300,6 +300,10 @@ export const measureText = ( const fontSize = parseFloat(font); const height = getTextHeight(text, fontSize, lineHeight); let width = getTextWidth(text, font); + // Since we now preserve trailing whitespaces so if the text has + // trailing whitespaces, it will be considered in the width and thus width + // computed might be much higher than the allowed max width + // by the container hence making sure the width never goes beyond the max width. if (maxWidth) { width = Math.min(width, maxWidth); }