class PDF::Reader::PageLayout
def initialize(runs, mediabox)
def initialize(runs, mediabox) # mediabox is a 4-element array for now, but it'd be nice to switch to a # PDF::Reader::Rectangle at some point PDF::Reader::Error.validate_not_nil(mediabox, "mediabox") @mediabox = process_mediabox(mediabox) @runs = runs @mean_font_size = mean(@runs.map(&:font_size)) || DEFAULT_FONT_SIZE @mean_font_size = DEFAULT_FONT_SIZE if @mean_font_size == 0 @median_glyph_width = median(@runs.map(&:mean_character_width)) || 0 @x_offset = @runs.map(&:x).sort.first || 0 lowest_y = @runs.map(&:y).sort.first || 0 @y_offset = lowest_y > 0 ? 0 : lowest_y end