lib/hexapdf/layout/column_box.rb in hexapdf-0.34.1 vs lib/hexapdf/layout/column_box.rb in hexapdf-0.35.0
- old
+ new
@@ -136,16 +136,18 @@
# Returns +true+ if no box was fitted into the columns.
def empty?
super && (!@box_fitter || @box_fitter.fit_results.empty?)
end
- # Fits the column box into the available space.
+ # Fits the column box into the current region of the frame.
#
# If the style property 'position' is set to :flow, the columns might not be rectangles but
# arbitrary (sets of) polygons since the +frame+s shape is taken into account.
def fit(available_width, available_height, frame)
- initial_fit_successful = (@equal_height ? nil : false)
+ return false if @initial_height > available_height || @initial_width > available_width
+
+ initial_fit_successful = (@equal_height && @columns.size > 1 ? nil : false)
tries = 0
@width = if style.position == :flow
(@initial_width > 0 ? @initial_width : frame.width) - reserved_width
else
(@initial_width > 0 ? @initial_width : available_width) - reserved_width
@@ -203,10 +205,10 @@
end
tries += 1
end
@width = columns[-1].sum + reserved_width
- @height = @box_fitter.content_heights.max + reserved_height
+ @height = (@initial_height > 0 ? @initial_height : @box_fitter.content_heights.max + reserved_height)
@draw_pos_x = frame.x + reserved_width_left
@draw_pos_y = frame.y - @height + reserved_height_bottom
@box_fitter.fit_successful?
end