Skip to content

Commit

Permalink
Merge pull request #647 from ruilisi/textbreak-optimizations
Browse files Browse the repository at this point in the history
Optimize textbreak processing
  • Loading branch information
sanchit3008 authored Dec 7, 2024
2 parents 4f0399a + 21b74a3 commit cab5d3d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/core/src/modules/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,7 @@ export function getCellTextInfo(
}
} else {
value = value.toString();
let parsedTextHeight = 0;
while (i <= value.length) {
const str = value.substring(anchor, i);
const measureText = getMeasureText(str, renderCtx, sheetCtx);
Expand Down Expand Up @@ -1192,8 +1193,10 @@ export function getCellTextInfo(
});

splitIndex += 1;

spaceOrTwoByte = null;

parsedTextHeight += preTextHeight;
if (parsedTextHeight >= cellHeight) break;
} else {
spaceOrTwoByte = null;
anchor = i - 1;
Expand All @@ -1210,10 +1213,10 @@ export function getCellTextInfo(
desc: preMeasureText.actualBoundingBoxDescent,
fs: fontSize,
});

// console.log(2);

splitIndex += 1;

parsedTextHeight += preTextHeight;
if (parsedTextHeight >= cellHeight) break;
}
} else if (i === value.length) {
if (_.isNil(text_all_split[splitIndex])) {
Expand Down Expand Up @@ -1649,8 +1652,6 @@ export function getCellTextInfo(
}

cumWordHeight += size.height;
// stop processing if rest of the cell isnt visible
if (cumWordHeight >= cellHeight) break;
}
}

Expand Down

0 comments on commit cab5d3d

Please sign in to comment.