浏览代码

add comment

Aakansha Doshi 2 年之前
父节点
当前提交
fd379c2897
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      src/element/textElement.ts

+ 4 - 0
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);
   }