File: font_style.rb

package info (click to toggle)
ruby-prawn 2.2.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,320 kB
  • sloc: ruby: 15,654; sh: 43; makefile: 20
file content (20 lines) | stat: -rw-r--r-- 754 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Most font families come with some styles other than normal. Most common are
# <code>bold</code>, <code>italic</code> and <code>bold_italic</code>.
#
# The style can be set the using the <code>:style</code> option, with either the
# <code>font</code> method which will set the font and style for rest of the
# document, or with the inline text methods.

require_relative '../example_helper'

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::ManualBuilder::Example.generate(filename) do
  ['Courier', 'Helvetica', 'Times-Roman'].each do |example_font|
    move_down 20

    [:bold, :bold_italic, :italic, :normal].each do |style|
      font example_font, style: style
      text "I'm writing in #{example_font} (#{style})"
    end
  end
end