Browse Source

Merge in PR #272

Fix sheet size for 1-card-per-sheet PDFs and adjust coordinates when
using trim #272
dev
Andy Meneely 7 years ago
parent
commit
1accadfc30
  1. 2
      docs/dsl/save_pdf.rst
  2. 27
      lib/squib/graphics/save_sprue.rb

2
docs/dsl/save_pdf.rst

@ -19,7 +19,7 @@ dir
sprue
default: ``nil``
the sprue file to use. If ``nil``, then no sprue is used and the cards are laid out automatically using the parameters below. If non-nil, Squib checks for a built-in sprue file of that name. Otherwise, it attempts to open a file relative to the current directory. For more information on Squib Sprues, see :doc:`/sprues`.
the sprue file to use. If ``nil``, then no sprue is used and the cards are laid out automatically using the parameters below. If non-nil, Squib checks for a built-in sprue file of that name. Otherwise, it attempts to open a file relative to the current directory. For more information on Squib Sprues, see :doc:`/sprues`. If you use the trim function (see trim option below) the cards are placed considering coordinates reduced by the trim value. A special case is a sprue file which defines one card per sheet: If you use the trim option then the sheet size will be trimmed as well to remove the otherwise added white border in the PDF.
width
default: ``3300``

27
lib/squib/graphics/save_sprue.rb

@ -30,11 +30,11 @@ module Squib
slot = slots[i % per_sheet]
draw_card cc, card,
slot['x'], slot['y'],
slot['x'] - @sheet_args.trim,
slot['y'] - @sheet_args.trim,
slot['rotate'],
slot['flip_vertical'], slot['flip_horizontal'],
slot['flip_vertical'], slot['flip_horizontal'],
@sheet_args.trim, @sheet_args.trim_radius
bar.increment
end
@ -160,11 +160,22 @@ module Squib
def init_cc
ratio = 72.0 / @deck.dpi
surface = Cairo::PDFSurface.new(
full_filename,
@tmpl.sheet_width * ratio,
@tmpl.sheet_height * ratio
)
slots = @tmpl.cards
per_sheet = slots.size
surface = if per_sheet == 1
Cairo::PDFSurface.new(
full_filename,
(@tmpl.sheet_width - 2 * @sheet_args.trim) * ratio,
(@tmpl.sheet_height - 2 *@sheet_args.trim) * ratio
)
else
Cairo::PDFSurface.new(
full_filename,
@tmpl.sheet_width * ratio,
@tmpl.sheet_height * ratio
)
end
cc = CairoContextWrapper.new(Cairo::Context.new(surface))
# cc = Cairo::Context.new(surface)

Loading…
Cancel
Save