@leafer-ui/worker 1.4.2 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2144,13 +2144,14 @@ function toChar(data, charX, rowData, isOverflow) {
2144
2144
  }
2145
2145
 
2146
2146
  function layoutText(drawData, style) {
2147
- const { rows, bounds } = drawData;
2147
+ const { rows, bounds } = drawData, countRows = rows.length;
2148
2148
  const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
2149
- let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
2149
+ let { x, y, width, height } = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
2150
2150
  let starY = __baseLine;
2151
2151
  if (__clipText && realHeight > height) {
2152
2152
  realHeight = Math.max(height, __lineHeight);
2153
- drawData.overflow = rows.length;
2153
+ if (countRows > 1)
2154
+ drawData.overflow = countRows;
2154
2155
  }
2155
2156
  else if (height || autoSizeAlign) {
2156
2157
  switch (verticalAlign) {
@@ -2162,7 +2163,7 @@ function layoutText(drawData, style) {
2162
2163
  }
2163
2164
  starY += y;
2164
2165
  let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
2165
- for (let i = 0, len = rows.length; i < len; i++) {
2166
+ for (let i = 0, len = countRows; i < len; i++) {
2166
2167
  row = rows[i];
2167
2168
  row.x = x;
2168
2169
  if (row.width < width || (row.width > width && !__clipText)) {
@@ -2231,7 +2232,7 @@ function clipText(drawData, style, x, width) {
2231
2232
  if (i === end && charRight < right) {
2232
2233
  break;
2233
2234
  }
2234
- else if (charRight < right && char.char !== ' ') {
2235
+ else if ((charRight < right && char.char !== ' ') || !i) {
2235
2236
  row.data.splice(i + 1);
2236
2237
  row.width -= char.width;
2237
2238
  break;