Skip to content

Commit

Permalink
returns more accurate widths from textWrap
Browse files Browse the repository at this point in the history
  • Loading branch information
davelandry committed Aug 19, 2017
1 parent 418ad85 commit 85f95f0
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/textWrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ export default function() {

const lineData = [],
sizes = measure(words, style),
space = measure(" ", style),
widthData = [];
space = measure(" ", style);

for (let i = 0; i < words.length; i++) {
let word = words[i];
Expand All @@ -62,7 +61,6 @@ export default function() {
truncated = true;
break;
}
widthData.push(widthProg);
widthProg = 0;
lineData.push(word);
}
Expand All @@ -72,12 +70,11 @@ export default function() {
widthProg += wordWidth;
widthProg += word.match(/[\s]*$/g)[0].length * space;
}
widthData.push(widthProg);

return {
lines: lineData,
sentence, truncated,
widths: widthData,
widths: measure(lineData, style),
words
};

Expand Down

0 comments on commit 85f95f0

Please sign in to comment.