lib/hexapdf/layout/box.rb in hexapdf-0.24.1 vs lib/hexapdf/layout/box.rb in hexapdf-0.24.2

- old
+ new

@@ -32,10 +32,11 @@ # # If the GNU Affero General Public License doesn't fit your need, # commercial licenses are available at <https://gettalong.at/hexapdf/>. #++ require 'hexapdf/layout/style' +require 'geom2d/utils' module HexaPDF module Layout # The base class for all layout boxes. @@ -74,10 +75,12 @@ # #draw:: This method draws the content and the default implementation already handles things # like drawing the border and background. Therefore it's best to implement #draw_content # which should just draw the content. class Box + include Geom2D::Utils + # Creates a new Box object, using the provided block as drawing block (see ::new). # # If +content_box+ is +true+, the width and height are taken to mean the content width and # height and the style's padding and border are added to them appropriately. # @@ -181,10 +184,12 @@ # should be sufficient for most subclasses; only #split_content needs to be implemented if # necessary. def split(available_width, available_height, frame) if @fit_successful [self, nil] - elsif (style.position != :flow && (@width > available_width || @height > available_height)) || + elsif (style.position != :flow && + (float_compare(@width, available_width) > 0 || + float_compare(@height, available_height) > 0)) || content_height == 0 || content_width == 0 [nil, self] else split_content(available_width, available_height, frame) end