class HexaPDF::Layout::TextLayouter::Result
drawing the result (i.e. the layed out lines) on a canvas.
Encapsulates the result of layouting items using a TextLayouter and provides a method for
def draw(canvas, x, y)
def draw(canvas, x, y) last_text_fragment = nil canvas.save_graphics_state do # Best effort for leading in case we have an evenly spaced paragraph canvas.leading(@lines[1].y_offset) if @lines.size > 1 @lines.each do |line| y -= line.y_offset line_x = x + line.x_offset line.each do |item, item_x, item_y| if item.kind_of?(TextFragment) item.draw(canvas, line_x + item_x, y + item_y, ignore_text_properties: last_text_fragment&.style == item.style) last_text_fragment = item elsif !item.empty? canvas.restore_graphics_state item.draw(canvas, line_x + item_x, y + item_y) canvas.save_graphics_state last_text_fragment = nil end end end end end
def initialize(status, lines, remaining_items)
def initialize(status, lines, remaining_items) @status = status @lines = lines @height = @lines.sum(&:y_offset) - (@lines.last&.y_min || 0) @remaining_items = remaining_items end