fixes/immediate #23

Merged
ilia merged 9 commits from fixes/immediate into main 2026-02-10 08:50:46 +00:00
Showing only changes of commit faf9b8570b - Show all commits

View File

@@ -150,6 +150,26 @@ export function createCharacterComparison<
currentLineWords = [];
}
const wordWidthA = measureText(
ctx,
word,
Math.min(fontSize, controlledFontSize),
currentWeight,
fontA()?.name,
);
const wordWidthB = measureText(
ctx,
word,
Math.min(fontSize, controlledFontSize),
currentWeight,
fontB()?.name,
);
const wordAloneWidth = Math.max(wordWidthA, wordWidthB);
if (wordAloneWidth <= availableWidth) {
// If word fits start new line with it
currentLineWords = [word];
} else {
let remainingWord = word;
while (remainingWord.length > 0) {
let low = 1;
@@ -187,6 +207,7 @@ export function createCharacterComparison<
pushLine([remainingWord.slice(0, bestBreak)]);
remainingWord = remainingWord.slice(bestBreak);
}
}
} else if (maxWidth > availableWidth && currentLineWords.length > 0) {
pushLine(currentLineWords);
currentLineWords = [word];