def calculate_pointsize(text, size_range: 28...128)
      draw = Magick::Draw.new
      draw.font = File.join(File.dirname(File.expand_path(__FILE__)), '..', '..', 'fonts', 'Impact.ttf')
      draw.font_weight = Magick::BoldWeight

      size = size_range.detect(-> { size_range.last }) do |pointsize|
        draw.pointsize = pointsize + 1
        current_stroke = pointsize / 30.0

        metrics = draw.get_multiline_type_metrics(text)

        metrics.width + current_stroke > @canvas.columns - 20 || metrics.height + current_stroke > (@canvas.rows / 2) - 20
      end
      [draw, size]
    end
def calculate_pointsize(text, size_range: 28...128)
      draw = Magick::Draw.new
      draw.font = File.join(File.dirname(File.expand_path(__FILE__)), '..', '..', 'fonts', 'Impact.ttf')
      draw.font_weight = Magick::BoldWeight

      size = size_range.detect(-> { size_range.last }) do |pointsize|
        draw.pointsize = pointsize + 1
        current_stroke = pointsize / 30.0

        metrics = draw.get_multiline_type_metrics(text)

        metrics.width + current_stroke > @canvas.columns - 20 || metrics.height + current_stroke > (@canvas.rows / 2) - 20
      end
      [draw, size]
    end
rubocop:disable Metrics/AbcSize