mirror of
https://github.com/foliojs/pdfkit.git
synced 2025-12-08 20:15:54 +00:00
Make sure heightOfString doesn't break pages
This commit is contained in:
parent
c72b50927c
commit
8eece7e9ea
@ -57,14 +57,17 @@ module.exports =
|
||||
widthOfString: (string, options = {}) ->
|
||||
@_font.widthOfString(string, @_fontSize) + (options.characterSpacing or 0) * (string.length - 1)
|
||||
|
||||
heightOfString: (text, options) ->
|
||||
heightOfString: (text, options = {}) ->
|
||||
{x,y} = this
|
||||
lineGap = options.lineGap or @_lineGap or 0
|
||||
|
||||
@_text text, 0, 0, options, (line, options) =>
|
||||
options = @_initOptions(options)
|
||||
options.height = Infinity # don't break pages
|
||||
|
||||
lineGap = options.lineGap or @_lineGap or 0
|
||||
@_text text, @x, @y, options, (line, options) =>
|
||||
@y += @currentLineHeight(true) + lineGap
|
||||
|
||||
height = @y # we started at y=0
|
||||
height = @y - y
|
||||
@x = x
|
||||
@y = y
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user