FIX: Wrap text properly
This fixes a bug where if you were wrapping text, the first word was repeated. We really need tests!
This commit is contained in:
committed by
Nicolás Hatcher Andrés
parent
532386b448
commit
90763048bc
@@ -101,7 +101,8 @@ function computeWrappedLines(
|
||||
for (const line of rawLines) {
|
||||
const words = line.split(" ");
|
||||
let currentLine = words[0];
|
||||
for (const word of words) {
|
||||
for (let i = 1; i < words.length; i += 1) {
|
||||
const word = words[i];
|
||||
const testLine = `${currentLine} ${word}`;
|
||||
const textWidth = context.measureText(testLine).width;
|
||||
if (textWidth < width) {
|
||||
|
||||
Reference in New Issue
Block a user