diff --git a/README.md b/README.md index 9579b1b..b6a6d9e 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,10 @@ Create a `Cardfile` in your working directory. It should look something like thi # prepend this PDF to the outputted PDF (useful for game rules) # c.prepend_pdf = "rules.pdf" + # the cards are landscape, so rotate them counterclockwise + # after rendering in Inkscape + # c.orientation = :landscape + c.data_source = "data.ods" end ``` diff --git a/bin/svggvs b/bin/svggvs index a23cd90..81d2ae6 100755 --- a/bin/svggvs +++ b/bin/svggvs @@ -74,10 +74,24 @@ MSG ensure_tmp @exported_pngs = Parallel.map(context.individual_files.each_with_index) do |svg_file, index| - target = Pathname(context.session.png_files_path % index) + target = Pathname(session.png_files_path % index) target.parent.mkpath - system %{inkscape --export-area-page --export-png "#{target.expand_path}" --export-width #{context.session.png_export_width} --export-background="#ffffffff" "#{svg_file.expand_path}"} + command = %{inkscape --export-area-page --export-png "#{target.expand_path}" --export-background="#ffffffff" } + + case session.orientation + when :portrait + command += %{--export-width #{session.png_export_width}} + when :landscape + command += %{--export-height #{session.png_export_width}} + end + command += %{ "#{svg_file.expand_path}"} + + system command + + if session.orientation == :landscape + system %{convert -verbose "#{target.expand_path}" -rotate 270 "#{target.expand_path}"} + end target end @@ -156,6 +170,10 @@ MSG def write_svgs context.write_individual_files end + + def session + context.session + end end end end diff --git a/lib/svggvs/session.rb b/lib/svggvs/session.rb index 8d91570..ecb25d1 100644 --- a/lib/svggvs/session.rb +++ b/lib/svggvs/session.rb @@ -3,11 +3,12 @@ module SVGGVS attr_accessor :svg_source, :svg_merged_target, :individual_files_path, :on_card_finished attr_accessor :png_files_path, :png_export_width, :pdf_card_size, :pdf_dpi attr_accessor :pdf_target, :card_back, :card_size, :target, :post_read_data - attr_accessor :card_sheet_identifier, :prepend_pdf + attr_accessor :card_sheet_identifier, :prepend_pdf, :orientation def initialize @index = 0 @card_sheet_identifier = "Card Data" + @orientation = :portrait end def configure diff --git a/skel/Cardfile b/skel/Cardfile index fcf975f..98ef317 100644 --- a/skel/Cardfile +++ b/skel/Cardfile @@ -10,6 +10,10 @@ # prepend this PDF to the outputted PDF (useful for game rules) # c.prepend_pdf = "rules.pdf" + # the cards are landscape, so rotate them counterclockwise + # after rendering in Inkscape + # c.orientation = :landscape + c.data_source = "data.ods" end