Sha256: b568223b4f42aa36bfdd33555c4eee7d279019a796390bd704c60b7dba8e2312

Contents?: true

Size: 683 Bytes

Versions: 12

Compression:

Stored size: 683 Bytes

Contents

require 'squib'

# Here's an exmaple of being able to scale a font
# based on the length of individual string.
# Handy for making minor font scales to fill text boxes.
def autoscale(str_array)
  str_array.inject([]) do | memo, str |
    case str.length
    when 0..10
      memo << 125
    when 11..20
      memo << 45
    else
      memo << 36
    end
  end
end

Squib::Deck.new(cards: 3) do
  background color: :white

  title = %w(ShortBig Medium_Length_Name Super_Duper_Long_Name)
  text str: title, x: 65, y: 400, align: :center, width: 700,
       font: 'Arial', font_size: autoscale(title), hint: :red

  save prefix: 'autoscale_', format: :png
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
squib-0.9.0 samples/autoscale_font.rb
squib-0.8.0 samples/autoscale_font.rb
squib-0.7.0 samples/autoscale_font.rb
squib-0.6.0 samples/autoscale_font.rb
squib-0.5.1 samples/autoscale_font.rb
squib-0.5.0 samples/autoscale_font.rb
squib-0.4.0 samples/autoscale_font.rb
squib-0.3.0 samples/autoscale_font.rb
squib-0.2.0 samples/autoscale_font.rb
squib-0.1.0 samples/autoscale_font.rb
squib-0.0.6 samples/autoscale_font.rb
squib-0.0.5 samples/autoscale_font.rb