Пока сделал так
for (let i = 0; i < count; i++){
textWidth[i] = getWidthOfText(text[i],'Lato','18px')
long += +textWidth[i] + emptySpace
if(long<=pageWidth){
line += text[i]+' ';
}else {
long = +textWidth[i] + emptySpace
line += '</br>';
}
}
Но желательно конечно обернуть строки в <p>...</p>