lib/thinreports/generator/pdf/document/graphics/text.rb in thinreports-0.8.1 vs lib/thinreports/generator/pdf/document/graphics/text.rb in thinreports-0.8.2

- old
+ new

@@ -31,11 +31,11 @@ with_text_styles(attrs) do |built_attrs, font_styles| pdf.formatted_text_box([{ text: content, styles: font_styles }], built_attrs.merge(box_attrs)) end - rescue Prawn::Errors::CannotFit => e + rescue Prawn::Errors::CannotFit # Nothing to do. # # When the area is too small compared # with the content and the style of the text. # (See prawn/core/text/formatted/line_wrap.rb#L185) @@ -80,20 +80,20 @@ fontinfo = {name: attrs.delete(:font).to_s, color: parse_color(attrs.delete(:color)), size: s2f(attrs.delete(:size))} # Add the specified value to :leading option. - if line_height = attrs.delete(:line_height) + line_height = attrs.delete(:line_height) + if line_height attrs[:leading] = text_line_leading(s2f(line_height), name: fontinfo[:name], size: fontinfo[:size]) end # Set the :character_spacing option. - if space = attrs.delete(:letter_spacing) - attrs[:character_spacing] = s2f(space) - end + spacing = attrs.delete(:letter_spacing) + attrs[:character_spacing] = s2f(spacing) if spacing # Or... with_font_styles(attrs, fontinfo, &block) with_font_styles(attrs, fontinfo) do |modified_attrs, styles| block.call(modified_attrs, styles) end @@ -124,10 +124,12 @@ # @yield [attributes, styles] # @yieldparam [Hash] modified_attrs # @yieldparam [Array] styles def with_font_styles(attrs, font, &block) # Building font styles. - if styles = attrs.delete(:styles) + styles = attrs.delete(:styles) + + if styles manual, styles = styles.partition do |style| [:bold, :italic].include?(style) && !font_has_style?(font[:name], style) end end