Sha256: 7cb9340722d715ec718b45c4c57833bc05d236e778ac43b32866ac273837212a

Contents?: true

Size: 684 Bytes

Versions: 1

Compression:

Stored size: 684 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

1 entries across 1 versions & 1 rubygems

Version Path
squib-0.0.4 samples/autoscale_font.rb