Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoneType error on bbox #11

Open
bersace opened this issue Feb 12, 2018 · 4 comments
Open

NoneType error on bbox #11

bersace opened this issue Feb 12, 2018 · 4 comments
Labels
Milestone

Comments

@bersace
Copy link

bersace commented Feb 12, 2018

Hi,

Trying to workaround FontAwesome awkwardness, i hit a bug with bounding box management. Here is the output:

$ icon-font-to-png --css my-font-awesome.css --ttf my-fontawesome-webfont.ttf ALL
Exporting icon '500px' as '500px.png'(16x16 pixels)
Traceback (most recent call last):
  File "/home/bersace/.local/share/virtualenvs/pandocker/bin/icon-font-to-png", line 16, in <module>
    command_line.run(sys.argv[1:])
  File "/home/bersace/.local/share/virtualenvs/pandocker/lib/python3.5/site-packages/icon_font_to_png/command_line.py", line 161, in run
    color=args.color, scale=args.scale)
  File "/home/bersace/.local/share/virtualenvs/pandocker/lib/python3.5/site-packages/icon_font_to_png/icon_font.py", line 155, in export_icon
    border_w = int((size - (bbox[2] - bbox[0])) / 2)
TypeError: 'NoneType' object is not subscriptable
52             if bbox:                                                         
153                 icon_image = icon_image.crop(bbox)
154                                                                        
155  ->         border_w = int((size - (bbox[2] - bbox[0])) / 2)
156             border_h = int((size - (bbox[3] - bbox[1])) / 2)
157                                
158             # Create output image
159             out_image = Image.new("RGBA", (size, size), (0, 0, 0, 0))
160             out_image.paste(icon_image, (border_w, border_h))

I don't understand why there is an if bbox as if bbox can be None, but border_* lines requires bbox to be defined. Can you give me a clue ? I can send you a patch.

@pawelad pawelad added the bug label Feb 12, 2018
@pawelad pawelad added this to the v0.4.2 milestone Feb 12, 2018
@pawelad
Copy link
Contributor

pawelad commented Feb 12, 2018

Thanks for reporting, I'll try to find some time for the Font Awesome 5 compatibility in the next few days to fix both this and #10 and do a release.

I don't understand why there is an if bbox as if bbox can be None, but border_* lines requires bbox to be defined. Can you give me a clue ? I can send you a patch.

Very good point : -)
I'm afraid I don't know the answer the the top of my head, but it definitely looks sketchy.

@dteirney
Copy link

dteirney commented May 7, 2019

I ran into this issue trying to use Font Awesome 5 as well. I fixed the BBox error but then ended up with blank images, which didn't help. Root problem seems to be because the font-awesome 5 CSS file includes all of the class names but the different TTF files don't contain all of the glyphs. To generate icons based solely on the icon name, I had to alter my script to try the regular TTF file and, if that returned an error, try the solid TTF file.

@aaronwhite
Copy link

Hoping for a bump in case @pawelad has a secret branch ready to go, or if @dteirney wouldn't mind sharing his fix! Thanks, all!

@youradds
Copy link

Was this ever fixed? I'm getting an error even with a simple usecase:

 icon-font-to-png --css ./css/all.css --ttf ./webfonts/fa-regular-400.ttf ALL
Exporting icon '500px' as '500px.png'(16x16 pixels)
Traceback (most recent call last):
  File "/usr/local/bin/icon-font-to-png", line 16, in <module>
    command_line.run(sys.argv[1:])
  File "/usr/local/lib/python3.8/dist-packages/icon_font_to_png/command_line.py", line 160, in run
    icon_font.export_icon(icon=icon, filename=filename, size=args.size,
  File "/usr/local/lib/python3.8/dist-packages/icon_font_to_png/icon_font.py", line 155, in export_icon
    border_w = int((size - (bbox[2] - bbox[0])) / 2)
TypeError: 'NoneType' object is not subscriptable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants