Sha256: 5e0e1f1e0f7f96482b4e692fe0b1c745b93a49f9e138a7933aca1af700f163bf
Contents?: true
Size: 715 Bytes
Versions: 3
Compression:
Stored size: 715 Bytes
Contents
require 'squib' # Here's an example 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.map do | str | case str.length when 0..15 10.66 when 16..20 6 else 4 end end end Squib::Deck.new(width: 300, height: 100, cards: 3) do background color: :white rect title = ['Short & Big', 'Medium Length & Size', 'Super duper long string here, therefore a smaller font.'] text str: title, font: 'Arial', font_size: autoscale(title), x: 10, y:10, align: :center, width: 280, ellipsize: false, hint: :red save_sheet columns: 3 end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
squib-0.15.2 | samples/autoscale_font/_autoscale_font.rb |
squib-0.15.1 | samples/autoscale_font/_autoscale_font.rb |
squib-0.14.2 | samples/autoscale_font/_autoscale_font.rb |