# File lib/prawn/format/line.rb, line 9 def initialize(instructions, hard_break) # need to remember the "source" instructions, because lines can # pushed back onto the stack en masse when flowing into boxes, # if a line is discovered to not fit. Thus, a line must preserve # all instructions it was originally given. @source = instructions @hard_break = hard_break end
distance from top of line to baseline
# File lib/prawn/format/line.rb, line 46 def ascent instructions.map { |instruction| instruction.ascent }.max || 0 end
distance from bottom of line to baseline
# File lib/prawn/format/line.rb, line 51 def descent instructions.map { |instruction| instruction.descent }.min || 0 end
# File lib/prawn/format/line.rb, line 59 def draw_on(document, state, options={}) return if instructions.empty? format_state = instructions.first.state case(options[:align]) when :left state[:dx] = 0 when :center state[:dx] = (state[:width] - width) / 2.0 when :right state[:dx] = state[:width] - width when :justify state[:dx] = 0 state[:padding] = hard_break? ? 0 : (state[:width] - width) / spaces state[:text].word_space(state[:padding]) end state[:dy] -= ascent state[:text].move_to(state[:dx], state[:dy]) state[:line] = self document.save_font do instructions.each { |instruction| instruction.draw(document, state, options) } state[:pending_effects].each { |effect| effect.wrap(document, state) } end state[:dy] -= (options[:spacing] || 0) + (height - ascent) end
# File lib/prawn/format/line.rb, line 37 def hard_break? @hard_break end
# File lib/prawn/format/line.rb, line 55 def height(include_blank=false) instructions.map { |instruction| instruction.height(include_blank) }.max end
Generated with the Darkfish Rdoc Generator 2.