FontCustom / fontcustom

Generate custom icon webfonts from the comfort of the command line.
3.28k stars 423 forks source link

fontforge compilation failed #387

Open Kleibert opened 3 years ago

Kleibert commented 3 years ago

Hi i have this problem with fontcustom compile fontcustom-2.0.0 ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]

Copyright (c) 2000-2020. See AUTHORS for Contributors. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html with many parts BSD http://fontforge.org/license.html. Please read LICENSE. Version: 20201107 Based on sources from 2020-11-07 20:56 UTC-ML-D-GDK3. Based on source from git with hash: 21ad4a18fb3d4becfe566d8215eba4483b0ddc4b fontforge 20201107 build date: 2020-11-07 20:56 UTC

fontcustom compile --debug
       debug  Using settings from `fontcustom.yml`.
       debug  Using options:
                {:input=>{:vectors=>"svg", :templates=>"../icons"},
                :output=>
                 {:fonts=>"../icons",
                  :"_icons.sass"=>"../../sass/3.base/",
                  :css=>"../icons",
                  :preview=>"../icons"},
                :config=>"fontcustom.yml",
                :templates=>["_icons.sass"],
                :font_name=>"icons",
                :font_design_size=>16,
                :font_em=>512,
                :font_ascent=>448,
                :font_descent=>64,
                :css_selector=>".icon-{{glyph}}",
                :preprocessor_path=>"",
                :autowidth=>false,
                :no_hash=>true,
                :css3=>false,
                :debug=>true,
                :force=>false,
                :quiet=>false,
                :copyright=>""}
      delete  ../icons/icons.ttf
              ../icons/icons.svg
       debug  Copyright (c) 2000-2020. See AUTHORS for Contributors.
               License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
               with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
               Version: 20201107
               Based on sources from 2020-11-07 20:56 UTC-ML-D-GDK3.
               Based on source from git with hash: 21ad4a18fb3d4becfe566d8215eba4483b0ddc4b
              I'm sorry this file is too complex for me to understand (or is erroneous)
              /Library/Ruby/Gems/2.6.0/gems/fontcustom-2.0.0/lib/fontcustom/scripts/generate.py:80: DeprecationWarning: an integer is required (got type float).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
                glyph.left_side_bearing = glyph.left_side_bearing - shift
              /Library/Ruby/Gems/2.6.0/gems/fontcustom-2.0.0/lib/fontcustom/scripts/generate.py:81: DeprecationWarning: an integer is required (got type float).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
                glyph.right_side_bearing = glyph.right_side_bearing + shift
              Traceback (most recent call last):
                File "/Library/Ruby/Gems/2.6.0/gems/fontcustom-2.0.0/lib/fontcustom/scripts/generate.py", line 120, in <module>
                  subprocess.Popen([scriptPath + '/sfnt2woff', fontfile + '.ttf'], stdout=subprocess.PIPE)
                File "/Applications/FontForge.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 947, in __init__
                  self._execute_child(args, executable, preexec_fn, close_fds,
                File "/Applications/FontForge.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1819, in _execute_child
                  raise child_exception_type(errno_num, err_msg, err_filename)
              OSError: [Errno 86] Bad CPU type in executable: '/Library/Ruby/Gems/2.6.0/gems/fontcustom-2.0.0/lib/fontcustom/scripts/sfnt2woff'

              During handling of the above exception, another exception occurred:

              Traceback (most recent call last):
                File "/Library/Ruby/Gems/2.6.0/gems/fontcustom-2.0.0/lib/fontcustom/scripts/generate.py", line 125, in <module>
                  subprocess.call(['sfnt2woff', fontfile + '.ttf'])
                File "/Applications/FontForge.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 349, in call
                  with Popen(*popenargs, **kwargs) as p:
                File "/Applications/FontForge.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 947, in __init__
                  self._execute_child(args, executable, preexec_fn, close_fds,
                File "/Applications/FontForge.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1819, in _execute_child
                  raise child_exception_type(errno_num, err_msg, err_filename)
              FileNotFoundError: [Errno 2] No such file or directory: 'sfnt2woff'
       error  `fontforge` compilation failed.
/Library/Ruby/Gems/2.6.0/gems/fontcustom-2.0.0/lib/fontcustom/generator/font.rb:92:in `create_fonts'
/Library/Ruby/Gems/2.6.0/gems/fontcustom-2.0.0/lib/fontcustom/generator/font.rb:20:in `generate'
/Library/Ruby/Gems/2.6.0/gems/fontcustom-2.0.0/lib/fontcustom/base.rb:62:in `start_generators'
/Library/Ruby/Gems/2.6.0/gems/fontcustom-2.0.0/lib/fontcustom/base.rb:23:in `compile'
/Library/Ruby/Gems/2.6.0/gems/fontcustom-2.0.0/lib/fontcustom/cli.rb:83:in `compile'
/Library/Ruby/Gems/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
/Library/Ruby/Gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
/Library/Ruby/Gems/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
/Library/Ruby/Gems/2.6.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
/Library/Ruby/Gems/2.6.0/gems/fontcustom-2.0.0/bin/fontcustom:5:in `<top (required)>'
/usr/local/bin/fontcustom:23:in `load'
Cimbali commented 3 years ago

Same issue here, except that instead of OSError: [Errno 86] Bad CPU type in executable I get OSError: [Errno 8] Exec format error, which seems a more generic version of the same error (I guess due to python 3.8 vs 3.9).

fontcustom 2.0.0 ruby 2.7-1.4 Python 3.8.9 OpenSuse Tumbleweed, kernel 5.11.15-1-default, arch x86_64

Trying to execute the bundled executable directly confirms it’s the wrong exec format bash: /.../ruby/2.7.0/gems/fontcustom-2.0.0/lib/fontcustom/scripts/sfnt2woff: cannot execute binary file: Exec format error

I fixed it by building and installing on $PATH the sfnt2woff and woff2sfnt binaries from wget/sfnt2woff.

webia1 commented 8 months ago

In my case, upgrading Ruby resolved the issue:

brew upgrade ruby

Afterward, I updated the path and set some necessary flags/variables in ~/.zshrc:

export PATH=/opt/homebrew/opt/ruby/bin:$PATH
export LDFLAGS="-L/opt/homebrew/opt/ruby/lib"
export CPPFLAGS="-I/opt/homebrew/opt/ruby/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/ruby/lib/pkgconfig"

Then, I restarted the zsh shell to ensure the changes took effect:

zsh -l 

These steps effectively resolved the problem for me.