mirror of
https://github.com/foliojs/pdfkit.git
synced 2025-12-08 20:15:54 +00:00
Correcting for edge case in line wrapping
If you look at the flow of the `eachWord` function, you'll notice that we add the word to the buffer if the width of the word `w` is less than the space available. There's an edge case where `linebreaker` says that a line break is required on a word (because of a manual break: `theword\n`) and the width of the word being considered is greater than `spaceLeft`. In the current pdfkit, if this is the case: * we do not append the word to the buffer * we emit the line * we break and move on to the next line, starting with a clean line This omits the word entirely. This commit makes it so that we only break the line and start with a clean line if we already had the space to write the line to the buffer. Otherwise, we append the word to the buffer and go to a new line.
This commit is contained in:
parent
5a530712c3
commit
6637dca8eb
@ -165,7 +165,7 @@ class LineWrapper extends EventEmitter
|
||||
return no
|
||||
|
||||
# reset the space left and buffer
|
||||
if bk.required
|
||||
if bk.required and w <= @spaceLeft
|
||||
@spaceLeft = @lineWidth
|
||||
buffer = ''
|
||||
textWidth = 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user