Sha256: e09a84254e75d365d1dea8e6d385b8c9a7e84510b6e47bc7aa4676f10ab8fc7d

Contents?: true

Size: 1.13 KB

Versions: 8

Compression:

Stored size: 1.13 KB

Contents

# encoding: utf-8
#
# The <code>font</code> method can be used in three different ways.
#
# If we don't pass it any arguments it will return the current font being used
# to render text.
#
# If we just pass it a font name it will use that font for rendering text
# through the rest of the document.
#
# It can also be used by passing a font name and a block. In this case the
# specified font will only be used to render text inside the block.
#
# The default font is Helvetica.
#
require File.expand_path(File.join(File.dirname(__FILE__),
                                   %w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::ManualBuilder::Example.generate(filename) do
  text "Let's see which font we are using: #{font.inspect}"

  move_down 20
  font "Times-Roman"
  text "Written in Times."

  move_down 20
  font("Courier") do
    text "Written in Courier because we are inside the block."
  end

  move_down 20
  text "Written in Times again as we left the previous block."

  move_down 20
  text "Let's see which font we are using again: #{font.inspect}"

  move_down 20
  font "Helvetica"
  text "Back to normal."
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
prawn-2.1.0 manual/text/font.rb
prawn-git-2.0.1 manual/text/font.rb
prawn-2.0.2 manual/text/font.rb
prawn-2.0.1 manual/text/font.rb
prawn-2.0.0 manual/text/font.rb
prawn-1.3.0 manual/text/font.rb
prawn-1.2.1 manual/text/font.rb
prawn-1.1.0 manual/text/font.rb