Skip to content

Extent with a decimal in the font size brings an error, not with an integer font size. #390

Open
@gabuzom

Description

Describe the bug

(DISCLAIMER: Sorry if it is my lack of knowledge of Ruby that is at fault here. It is actually very likely. Please accept my apologies in advance if it's the case.)

Ruby crashes with a strange error, like if the extent array was empty or such, whenever the font size in my extent is 6.7. it doesnt when the size is 7.

To Reproduce

WHAT WORKS:

extents = text(str: cards['desc'], font: 'TradeGothic 7', x:100, width:570, height: 235, color: '#0000')
puts extents
ws = extents.inject([]) do |arr, ext|
case ext[:height]
when 0..80
arr << ext[:height]+640 ; arr
...etc.

(later:)
text str: cards['context'], y: ws, layout: "context"

WHAT DOESNT:

extents = text(str: cards['desc'], font: 'TradeGothic 6.7', x:100, width:570, height: 235, color: '#0000')
puts extents
ws = extents.inject([]) do |arr, ext|
case ext[:height]
when 0..80
arr << ext[:height]+640 ; arr
...etc.

(only 7 is changed by 6.7. tried with 6.8 and other values to the same... extent < pun intended)

error is:

peoject.rb:83:in block (2 levels) in <main>': undefined method <<' for nil (NoMethodError)

arr << ext[:height]+620 ; arr 
    ^^
from project.rb:78:in `each'
from project.rb:78:in `inject'
from project.rb:78:in `block in <main>'
from /usr/local/bundle/gems/squib-0.19.0/lib/squib/deck.rb:75:in `instance_eval'
from /usr/local/bundle/gems/squib-0.19.0/lib/squib/deck.rb:75:in `initialize'
from project.rb:12:in `new'
from project.rb:12:in `<main>'

I tried escaping the string with " " and with ' '

Expected behavior

not crashing! :)

Environment

  • Debian linux
    Linux 238bcf6eaeeb 6.1.0-13-amd64 Allow config.yml to define custom colors #1 SMP PREEMPT_DYNAMIC Debian 6.1.55-1 (2023-09-29) x86_64 GNU/Linux
  • Ruby version (e.g. 2.7, 3.0)
    ruby 3.3.1 (2024-04-23 revision c56cd86388) [x86_64-linux]

Additional context
none

Check the following:

  • [x ] I have updated Squib to the latest version.
  • [x ] I have checked the Squib issues backlog for something similar
  • I have attempted to make a minimal script demonstrating my problem
  • [x ] I have reviewed the Squib Docs and there's still a problem

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions