only split if string is over length.

This commit is contained in:
Sidharth Vinod
2023-06-08 00:07:33 +05:30
parent 0cb6df1ef8
commit ad09d63f65

View File

@@ -119,6 +119,9 @@ function createFormattedText(width, g, structuredText, addBackground = false) {
let tempStr = '';
let linesUnderWidth = [];
let prevIndex = 0;
if (computeWidthOfText(labelGroup, lineHeight, fullStr) <= width) {
linesUnderWidth.push(fullStr);
} else {
for (let i = 0; i <= fullStr.length; i++) {
tempStr = fullStr.slice(prevIndex, i);
log.info(tempStr, prevIndex, i);
@@ -137,6 +140,7 @@ function createFormattedText(width, g, structuredText, addBackground = false) {
if (tempStr != null) {
linesUnderWidth.push(tempStr);
}
}
/** Add each prepared line as a tspan to the parent node */
const preparedLines = linesUnderWidth.map((w) => ({ content: w, type: line.type }));
for (const preparedLine of preparedLines) {