lib/hexapdf/document/layout.rb in hexapdf-0.37.2 vs lib/hexapdf/document/layout.rb in hexapdf-0.38.0

- old
+ new

@@ -484,14 +484,18 @@ @argument_infos << ArgumentInfo.new(rows, cols, args) end # Retrieves the merged keyword arguments for the cell in +row+ and +col+. # - # Earlier defined arguments are overridden by later ones. + # Earlier defined arguments are overridden by later ones, except for the +:cell+ key which + # is merged. def retrieve_arguments_for(row, col) @argument_infos.each_with_object({}) do |arg_info, result| next unless arg_info.rows.cover?(row) && arg_info.cols.cover?(col) + if arg_info.args[:cell] + arg_info.args[:cell] = (result[:cell] || {}).merge(arg_info.args[:cell]) + end result.update(arg_info.args) end end private @@ -633,18 +637,18 @@ # style :base is used # # If the +properties+ hash is not empty, the retrieved style is duplicated and the properties # hash is applied to it. # - # Finally, a default font is set if necessary to ensure that the style object works in all - # cases. + # Finally, a default font (the one from the :base style or otherwise 'Times') is set if + # necessary to ensure that the style object works in all cases. def retrieve_style(style, properties = nil) if style.kind_of?(Symbol) && !@styles.key?(style) raise HexaPDF::Error, "Style #{style} not defined" end style = HexaPDF::Layout::Style.create(@styles[style] || style || @styles[:base]) style = style.dup.update(**properties) unless properties.nil? || properties.empty? - style.font('Times') unless style.font? + style.font(@styles[:base].font? && @styles[:base].font || 'Times') unless style.font? unless style.font.respond_to?(:pdf_object) name, options = *style.font style.font(@document.fonts.add(name, **(options || {}))) end style