class Prawn::SVG::Interface

Constants

INHERITABLE_OPTIONS
VALID_OPTIONS

Attributes

data[R]
document[R]
options[R]
prawn[R]

Public Class Methods

font_path() click to toggle source
# File lib/prawn/svg/interface.rb, line 63
def self.font_path # backwards support for when the font_path used to be stored on this class
  Prawn::SVG::FontRegistry.font_path
end
new(data, prawn, options, &block) click to toggle source

Creates a Prawn::SVG object.

data is the SVG data to convert. prawn is your Prawn::Document object.

See README.md for the options that can be passed to this method.

# File lib/prawn/svg/interface.rb, line 27
def initialize(data, prawn, options, &block)
  Prawn.verify_options VALID_OPTIONS, options

  @data = data
  @prawn = prawn
  @options = options

  font_registry = Prawn::SVG::FontRegistry.new(prawn.font_families)

  @document = Document.new(
    data, [prawn.bounds.width, prawn.bounds.height], options,
    font_registry: font_registry, &block
  )

  @renderer = Renderer.new(prawn, document, options)
end

Public Instance Methods

draw() click to toggle source

Draws the SVG to the Prawn::Document object.

# File lib/prawn/svg/interface.rb, line 47
def draw
  @renderer.draw
end
position() click to toggle source
# File lib/prawn/svg/interface.rb, line 59
def position
  @renderer.position
end
resize(width: nil, height: nil) click to toggle source
# File lib/prawn/svg/interface.rb, line 55
def resize(width: nil, height: nil)
  document.calculate_sizing(requested_width: width, requested_height: height)
end
sizing() click to toggle source
# File lib/prawn/svg/interface.rb, line 51
def sizing
  document.sizing
end