manual/text/formatted_text.rb in prawn-2.1.0 vs manual/text/formatted_text.rb in prawn-2.2.0
- old
+ new
@@ -1,7 +1,5 @@
-# encoding: utf-8
-#
# There are two other text methods available: <code>formatted_text</code> and
# <code>formatted_text_box</code>.
#
# These are useful when the provided text has numerous portions that need to be
# formatted differently. As you might imply from their names the first should
@@ -18,33 +16,41 @@
# <code>:font</code> (the name of a registered font), <code>:color</code> (the
# same input accepted by <code>fill_color</code> and <code>stroke_color</code>),
# <code>:link</code> (an URL to create a link), and <code>:local</code>
# (a link to a local file).
-require File.expand_path(File.join(File.dirname(__FILE__),
- %w[.. example_helper]))
+require_relative '../example_helper'
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::ManualBuilder::Example.generate(filename) do
- formatted_text [ { :text => "Some bold. ", :styles => [:bold] },
- { :text => "Some italic. ", :styles => [:italic] },
- { :text => "Bold italic. ", :styles => [:bold, :italic] },
- { :text => "Bigger Text. ", :size => 20 },
- { :text => "More spacing. ", :character_spacing => 3 },
- { :text => "Different Font. ", :font => "Courier" },
- { :text => "Some coloring. ", :color => "FF00FF" },
- { :text => "Link to the wiki. ",
- :color => "0000FF",
- :link => "https://github.com/prawnpdf/prawn/wiki" },
- { :text => "Link to a local file. ",
- :color => "0000FF",
- :local => "./local_file.txt" }
- ]
+ formatted_text [
+ { text: 'Some bold. ', styles: [:bold] },
+ { text: 'Some italic. ', styles: [:italic] },
+ { text: 'Bold italic. ', styles: [:bold, :italic] },
+ { text: 'Bigger Text. ', size: 20 },
+ { text: 'More spacing. ', character_spacing: 3 },
+ { text: 'Different Font. ', font: 'Courier' },
+ { text: 'Some coloring. ', color: 'FF00FF' },
+ {
+ text: 'Link to the wiki. ',
+ color: '0000FF',
+ link: 'https://github.com/prawnpdf/prawn/wiki'
+ },
+ {
+ text: 'Link to a local file. ',
+ color: '0000FF',
+ local: './local_file.txt'
+ }
+ ]
- formatted_text_box [ { :text => "Just your regular" },
- { :text => " text_box ", :font => "Courier" },
- { :text => "with some additional formatting options " +
- "added to the mix.",
- :color => [50, 100, 0, 0],
- :styles => [:italic] }
- ], :at => [100, 100], :width => 200, :height => 100
+ formatted_text_box(
+ [
+ { text: 'Just your regular' },
+ { text: ' text_box ', font: 'Courier' },
+ {
+ text: 'with some additional formatting options added to the mix.',
+ color: [50, 100, 0, 0], styles: [:italic]
+ }
+ ],
+ at: [100, 100], width: 200, height: 100
+ )
end