Skip to content

Commit

Permalink
read padding from correct box when creating new page
Browse files Browse the repository at this point in the history
resolves prawnpdf#1121
  • Loading branch information
mojavelinux committed Jan 24, 2022
1 parent 7b7348d commit 3a01dcf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

### Apply correct margin box when creating or switching pages

When creating a new page or returning to a page previously created, compute the margin box correctly.

(Dan Allen, [#1122](https://github.com/prawnpdf/prawn/pull/1022))

### Look for glyph in correct font

Take the font style into account when looking for a glyph and fallback fonts are enabled.
Expand Down
12 changes: 7 additions & 5 deletions lib/prawn/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -723,15 +723,17 @@ def generate_margin_box
(page.margins[:top] + page.margins[:bottom])
)

# This check maintains indentation settings across page breaks
# update bounding box if not flowing from the previous page
unless @bounding_box&.parent
old_margin_box = @bounding_box
@bounding_box = @margin_box
end

# maintains indentation settings across page breaks
if old_margin_box
@margin_box.add_left_padding(old_margin_box.total_left_padding)
@margin_box.add_right_padding(old_margin_box.total_right_padding)
end

# we must update bounding box if not flowing from the previous page
#
@bounding_box = @margin_box unless @bounding_box&.parent
end

def apply_margin_options(options)
Expand Down

0 comments on commit 3a01dcf

Please sign in to comment.