andymeneely / squib

A Ruby DSL for prototyping card games.
http://squib.rocks
MIT License
923 stars 67 forks source link

Use :scale on images embedded in text. #160

Open ryanabrams opened 8 years ago

ryanabrams commented 8 years ago

When I try to use :scale for the height attribute of images embedded into text, I get a fatal error, reporduced below. This used to work (in like 0.6 iirc - I jumped a lot of versions recently).

/Users/ryan/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/squib-0.10.0/lib/squib/graphics/text.rb:56:in `>': comparison of Symbol with 0 failed (ArgumentError)
    from /Users/ryan/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/squib-0.10.0/lib/squib/graphics/text.rb:56:in `block in max_embed_height'
    from /Users/ryan/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/squib-0.10.0/lib/squib/graphics/text.rb:55:in `each'
    from /Users/ryan/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/squib-0.10.0/lib/squib/graphics/text.rb:55:in `inject'
    from /Users/ryan/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/squib-0.10.0/lib/squib/graphics/text.rb:55:in `max_embed_height'
    from /Users/ryan/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/squib-0.10.0/lib/squib/graphics/text.rb:151:in `block in text'
    from /Users/ryan/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/squib-0.10.0/lib/squib/card.rb:50:in `yield'
    from /Users/ryan/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/squib-0.10.0/lib/squib/card.rb:50:in `use_cairo'
    from /Users/ryan/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/squib-0.10.0/lib/squib/graphics/text.rb:124:in `text'
    from /Users/ryan/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/squib-0.10.0/lib/squib/api/text.rb:20:in `block in text'
    from /Users/ryan/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/squib-0.10.0/lib/squib/args/card_range.rb:13:in `call'
    from /Users/ryan/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/squib-0.10.0/lib/squib/args/card_range.rb:13:in `block in each'
    from /Users/ryan/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/squib-0.10.0/lib/squib/args/card_range.rb:13:in `each'
    from /Users/ryan/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/squib-0.10.0/lib/squib/args/card_range.rb:13:in `each'
    from /Users/ryan/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/squib-0.10.0/lib/squib/api/text.rb:20:in `text'
andymeneely commented 8 years ago

Actually I think the :scale option is pretty new, so it may have never worked. I'll take a look.

andymeneely commented 8 years ago

This might happen someday, but not on this release. It's a handy method to have, but it gets squirrely with embedded icons. For now, I'm just documenting the lack of behavior and considering it a future feature.