File: font_size.rb

package info (click to toggle)
ruby-prawn 1.3.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,936 kB
  • ctags: 802
  • sloc: ruby: 13,906; sh: 43; makefile: 15
file content (45 lines) | stat: -rw-r--r-- 1,159 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# encoding: utf-8
#
# The <code>font_size</code> method works just like the <code>font</code>
# method.
#
# In fact we can even use <code>font</code> with the <code>:size</code> option
# to declare which size we want.
#
# Another way to change the font size is by supplying the <code>:size</code>
# option to the text methods.
#
# The default font size is <code>12</code>.
#
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 is the current font_size: #{font_size.inspect}"

  move_down 10
  font_size 16
  text "Yeah, something bigger!"

  move_down 10
  font_size(25) { text "Even bigger!" }

  move_down 10
  text "Back to 16 again."

  move_down 10
  text "Single line on 20 using the :size option.", :size => 20

  move_down 10
  text "Back to 16 once more."

  move_down 10
  font("Courier", :size => 10) do
    text "Yeah, using Courier 10 courtesy of the font method."
  end

  move_down 10
  font("Helvetica", :size => 12)
  text "Back to normal"
end