Module: Prawn::Core::Text
- Included in:
- Text
- Defined in:
- lib/prawn/core/text.rb,
lib/prawn/core/text/wrap.rb,
lib/prawn/core/text/line_wrap.rb,
lib/prawn/core/text/formatted/wrap.rb,
lib/prawn/core/text/formatted/arranger.rb,
lib/prawn/core/text/formatted/line_wrap.rb
Overview
:nodoc:
Defined Under Namespace
Modules: Formatted, Wrap Classes: LineWrap
Constant Summary collapse
- VALID_OPTIONS =
These should be used as a base. Extensions may build on this list
[:kerning, :size, :style]
Instance Attribute Summary collapse
-
#skip_encoding ⇒ Object
readonly
Returns the value of attribute skip_encoding.
Instance Method Summary collapse
-
#character_spacing(amount = nil) ⇒ Object
Increases or decreases the space between characters.
- #default_kerning(boolean) ⇒ Object (also: #default_kerning=)
-
#default_kerning? ⇒ Boolean
Document wide setting of whether or not to use kerning with text Defaults to true Can be overridden using the :kerning text option.
- #default_leading(number) ⇒ Object (also: #default_leading=)
-
#default_leading? ⇒ Boolean
Document wide setting of leading Defaults to 0 Can be overridden using the :leading text option.
-
#draw_text!(text, options) ⇒ Object
Low level text placement method.
-
#process_text_options(options) ⇒ Object
Low level call to set the current font style and extract text options from an options hash.
-
#word_spacing(amount = nil) ⇒ Object
Increases or decreases the space between words.
Instance Attribute Details
#skip_encoding ⇒ Object (readonly)
Returns the value of attribute skip_encoding.
19 20 21 |
# File 'lib/prawn/core/text.rb', line 19 def skip_encoding @skip_encoding end |
Instance Method Details
#character_spacing(amount = nil) ⇒ Object
Increases or decreases the space between characters. For horizontal text, a positive value will increase the space. For veritical text, a positive value will decrease the space.
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/prawn/core/text.rb', line 80 def character_spacing(amount=nil) return @character_spacing || 0 if amount.nil? original_character_spacing = character_spacing if original_character_spacing == amount yield else @character_spacing = amount add_content "\n%.3f Tc" % amount yield add_content "\n%.3f Tc" % original_character_spacing @character_spacing = original_character_spacing end end |
#default_kerning(boolean) ⇒ Object Also known as: default_kerning=
55 56 57 |
# File 'lib/prawn/core/text.rb', line 55 def default_kerning(boolean) @default_kerning = boolean end |
#default_kerning? ⇒ Boolean
Document wide setting of whether or not to use kerning with text Defaults to true Can be overridden using the :kerning text option
50 51 52 53 |
# File 'lib/prawn/core/text.rb', line 50 def default_kerning? return true if @default_kerning.nil? @default_kerning end |
#default_leading(number) ⇒ Object Also known as: default_leading=
70 71 72 |
# File 'lib/prawn/core/text.rb', line 70 def default_leading(number) @default_leading = number end |
#default_leading? ⇒ Boolean
Document wide setting of leading Defaults to 0 Can be overridden using the :leading text option
65 66 67 68 |
# File 'lib/prawn/core/text.rb', line 65 def default_leading? return 0 if @default_leading.nil? @default_leading end |
#draw_text!(text, options) ⇒ Object
Low level text placement method. All font and size alterations should already be set
24 25 26 27 |
# File 'lib/prawn/core/text.rb', line 24 def draw_text!(text, ) x,y = map_to_absolute([:at]) add_text_content(text,x,y,) end |
#process_text_options(options) ⇒ Object
Low level call to set the current font style and extract text options from an options hash. Should be called from within a save_font block
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/prawn/core/text.rb', line 32 def () if [:style] raise "Bad font family" unless font.family font(font.family, :style => [:style]) end # must compare against false to keep kerning on as default unless [:kerning] == false [:kerning] = font.has_kerning_data? end [:size] ||= font_size end |
#word_spacing(amount = nil) ⇒ Object
Increases or decreases the space between words. For horizontal text, a positive value will increase the space. For veritical text, a positive value will decrease the space.
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/prawn/core/text.rb', line 98 def word_spacing(amount=nil) return @word_spacing || 0 if amount.nil? original_word_spacing = word_spacing if original_word_spacing == amount yield else @word_spacing = amount add_content "\n%.3f Tw" % amount yield add_content "\n%.3f Tw" % original_word_spacing @word_spacing = original_word_spacing end end |