Sha256: 07c87c949bae0091769f4d026689d4d7f408d0720b09294404e3f3abfad55f69

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

#
# Copyright (c) 2019-present, Blue Marble Payroll, LLC
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#

module Proforma
  class PrawnRenderer
    module Util
      # Defines what we & prawn need in a font.
      class Font
        acts_as_hashable

        attr_reader :bold_path,
                    :name,
                    :normal_path

        def initialize(bold_path:, name:, normal_path:)
          raise ArgumentError, 'bold_path is required'    if bold_path.to_s.empty?
          raise ArgumentError, 'name is required'         if name.to_s.empty?
          raise ArgumentError, 'normal_path is required'  if normal_path.to_s.empty?

          @bold_path    = bold_path
          @name         = name
          @normal_path  = normal_path

          freeze
        end

        def prawn_config
          {
            name.to_s => {
              normal: normal_path.to_s,
              bold: bold_path.to_s
            }
          }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
proforma-prawn-renderer-1.1.0 lib/proforma/prawn_renderer/util/font.rb