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:
Mirko K
2019-10-17 11:29:14 -04:00
committed by Andy Meneely
parent 43cca582a6
commit 6d57b3e8c1
28 changed files with 1161 additions and 187 deletions
+6 -1
View File
@@ -1,7 +1,7 @@
require 'squib'
require 'squib/sample_helpers'
Squib::Deck.new(width: 1000, height: 1250) do
Squib::Deck.new(width: 1000, height: 1450) do
draw_graph_paper width, height
sample 'Font strings are quite expressive. Specify family, modifiers, then size. Font names with spaces in them should end with a comma to help with parsing.' do |x, y|
@@ -21,6 +21,11 @@ Squib::Deck.new(width: 1000, height: 1250) do
hint: :red, width: 350, font: 'Serif bold 7'
end
sample 'If you specify ellipsize: :autosize, the font size will autoscale.' do |x, y|
text str: 'This text doeas not fit with font size 7. It is autoscaled to the largest size that fits instead.', x: x - 50, y: y,
hint: :red, width: 350, height: 100, ellipsize: :autoscale, font: 'Serif bold 7'
end
sample 'If you specify the width only, and turn off ellipsize, the height will auto-stretch.' do |x, y|
text str: 'This has fixed width, but not fixed height.', x: x, y: y,
hint: :red, width: 300, ellipsize: false, font: 'Serif bold 8'
Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 230 KiB