module Prawn::Icon::Interface
Public Instance Methods
Set up and draw an icon on this document. This method operates much like
Prawn::Text::Box
.
Parameters:¶ ↑
- key
-
Contains the key to a particular icon within a font family. If :inline_format is true, then key may contain formatted text marked with <icon></icon> tags and any tag supported by Prawn's parser.
- opts
-
A hash of options that may be supplied to the underlying
text
method call.
Examples:¶ ↑
pdf.icon 'fa-beer' pdf.icon '<icon color="0099FF">fa-arrows</icon>', inline_format: true
# File lib/prawn/icon/interface.rb, line 64 def icon(key, opts = {}) make_icon(key, opts).tap(&:render) end
Initialize a new formatted text box containing icon information, but don't render it to the document.
Parameters:¶ ↑
- text
-
Input text to be parsed initially for <icon> tags, then passed to Prawn's formatted text parser.
- opts
-
A hash of options that may be supplied to the underlying text call.
# File lib/prawn/icon/interface.rb, line 105 def inline_icon(text, opts = {}) parsed = Icon::Parser.format(self, text) content = Text::Formatted::Parser.format(parsed) box_options = opts.merge( inline_format: true, document: self, at: [bounds.left, cursor] ) icon_box(content, box_options) end
Initialize a new icon object, but do not render it to the document.
Parameters:¶ ↑
- key
-
Contains the key to a particular icon within a font family. If :inline_format is true, then key may contain formatted text marked with <icon></icon> tags and any tag supported by Prawn's parser.
- opts
-
A hash of options that may be supplied to the underlying text method call.
# File lib/prawn/icon/interface.rb, line 83 def make_icon(key, opts = {}) if opts[:inline_format] inline_icon(key, opts) else Icon.new(key, self, opts) end end
Initialize a new Prawn::Icon, but don't render the icon to a document. Intended to be used as an entry of a data array when combined with Prawn::Table.
Parameters:¶ ↑
- key
-
Contains the key to a particular icon within a font family. The key may contain a string with format tags if +inline_format: true+ in the
opts
hash. - opts
-
A hash of options that may be supplied to the underlying text call.
Returns:¶ ↑
A Hash containing +font+ and +content+ keys that match the data necessary for the specified icon. eg. { font: 'fa', content: '\uf047' } Note that the +font+ key will not be set if +inline_format: true+.
Examples:¶ ↑
require 'prawn/table' data = [ # Explicit brackets must be used here [pdf.table_icon('fa-arrows'), 'Cell 1'], ['Cell 2', 'Cell 3'] ] pdf.table(data) => (2 x 2 table)
# File lib/prawn/icon/interface.rb, line 153 def table_icon(key, opts = {}) if opts[:inline_format] content = Icon::Parser.format(self, key) opts.merge(content: content) else make_icon(key, opts).format_hash end end