Object
# File lib/prawn/format/state.rb, line 8 def initialize(document, options={}) @document = document @previous = options[:previous] @original_style = (@previous && @previous.inheritable_style || {}). merge(options[:style] || {}) compute_styles! @style[:kerning] = font.has_kerning_data? unless @style.key?(:kerning) end
# File lib/prawn/format/state.rb, line 99 def apply!(text_object, cookies) if cookies[:color] != color cookies[:color] = color text_object.fill_color(color) end if cookies[:vertical_align] != vertical_align cookies[:vertical_align] = vertical_align text_object.rise(vertical_align) end end
# File lib/prawn/format/state.rb, line 111 def apply_font!(text_object, cookies, subset) if cookies[:font] != [font_family, pdf_font_style, font_size, subset] cookies[:font] = [font_family, pdf_font_style, font_size, subset] font = document.font(font_family, :style => pdf_font_style) font.add_to_current_page(subset) text_object.font(font.identifier_for(subset), font_size) end end
# File lib/prawn/format/state.rb, line 124 def bold? font_weight == :bold end
# File lib/prawn/format/state.rb, line 59 def color @style[:color] || "000000" end
# File lib/prawn/format/state.rb, line 39 def display @style[:display] || :inline end
# File lib/prawn/format/state.rb, line 79 def font @font ||= document.find_font(font_family, :style => pdf_font_style) end
# File lib/prawn/format/state.rb, line 47 def font_family @style[:font_family] || "Helvetica" end
# File lib/prawn/format/state.rb, line 43 def font_size @style[:font_size] || 12 end
# File lib/prawn/format/state.rb, line 51 def font_style @style[:font_style] || :normal end
# File lib/prawn/format/state.rb, line 55 def font_weight @style[:font_weight] || :normal end
# File lib/prawn/format/state.rb, line 20 def inheritable_style @inheritable_style ||= begin subset = original_style.dup subset.delete(:meta) subset.delete(:display) subset.delete(:width) # explicitly set font-size so that relative font-sizes don't get # recomputed upon each nesting. subset[:font_size] = font_size subset end end
# File lib/prawn/format/state.rb, line 120 def italic? font_style == :italic end
# File lib/prawn/format/state.rb, line 35 def kerning? @style[:kerning] end
# File lib/prawn/format/state.rb, line 83 def pdf_font_style if bold? && italic? :bold_italic elsif bold? :bold elsif italic? :italic else :normal end end
# File lib/prawn/format/state.rb, line 128 def previous(attr=nil, default=nil) return @previous unless attr return default unless @previous return @previous.send(attr) || default end
# File lib/prawn/format/state.rb, line 67 def text_decoration @style[:text_decoration] || :none end
# File lib/prawn/format/state.rb, line 63 def vertical_align @style[:vertical_align] || 0 end
# File lib/prawn/format/state.rb, line 71 def white_space @style[:white_space] || :normal end
Generated with the Darkfish Rdoc Generator 2.