Feat/font autoscale (#288)
* PoC font autosize feature * Take enumerables or 'auto' keyword for autoscaling * Allo enumerables of font_size per card, where the largest font size that does not ellipsize is chosen * Use ellipsize: :autoscale keyword to determine font autosizing * Use binary search to find the correct font size * Consider new ellipsize option in testcase * Document ellipsize: :autoscale option * Add ellipsize: :autoscale sample to text sample * Fix double multiplication with Pango::SCALE * Scale embedded images with text when autoscaling * Remove stray semicolon * Return dummy value for FontDescription.size in mock_cairo * Update regression test data for autoscale feature. * Add ellipsize: :autoscale example to existing font_autoscale sample * Add missing :autoscale to list of options in documentation
This commit is contained in:
@@ -16,14 +16,20 @@ def autoscale(str_array)
|
||||
end
|
||||
end
|
||||
|
||||
Squib::Deck.new(width: 300, height: 100, cards: 3) do
|
||||
Squib::Deck.new(width: 300, height: 200, cards: 3) do
|
||||
background color: :white
|
||||
rect
|
||||
title = ['Short & Big',
|
||||
'Medium Length & Size',
|
||||
'Super duper long string here, therefore a smaller font.']
|
||||
|
||||
# Scale text based on the string length
|
||||
text str: title, font: 'Arial', font_size: autoscale(title),
|
||||
x: 10, y:10, align: :center, width: 280, ellipsize: false, hint: :red
|
||||
|
||||
# Automatically scale the text down from the specified font_size to the largest size that fits
|
||||
text str: title, font: 'Arial', font_size: 10,
|
||||
x: 10, y:100, align: :center, width: 280, height: 50, ellipsize: :autoscale, hint: :red
|
||||
|
||||
save_sheet columns: 3
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user