Sha256: d3023563abd73c893b1ac79379f3ada01fbc621dc49b212dabb29284f44bc1dd

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

# frozen_string_literal: true

module Prawn
  module SwissQRBill
    # Bill renders the Swiss QR-bill at the bottom of a page
    class Bill
      FONT_DIR = File.expand_path("#{__dir__}/../../../assets/fonts")

      def initialize(document, data)
        @doc = document
        @data = data
      end

      def draw
        set_font

        @doc.canvas do
          Sections.draw_all(@doc, @data)
          CuttingLines.new(@doc).draw
        end
      end

      private

      def set_font
        @doc.font_families.update(
          'Inter' => {
            normal: "#{FONT_DIR}/inter/Inter-Regular.ttf",
            bold: "#{FONT_DIR}/inter/Inter-Bold.ttf"
          }
        )
        @doc.font 'Inter'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prawn-swiss_qr_bill-0.4.2 lib/prawn/swiss_qr_bill/bill.rb