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

base64 doesn't work because relative paths get messed up #277

Open
TWiStErRob opened this issue Jun 11, 2015 · 2 comments
Open

base64 doesn't work because relative paths get messed up #277

TWiStErRob opened this issue Jun 11, 2015 · 2 comments

Comments

@TWiStErRob
Copy link

For this config:

font_name: iconfont
css_selector: .icon-{{glyph}}
no_hash: true
# removing this line makes it work, but of course then the font is not embedded
base64: true
force: true
debug: true
input:
  vectors: vectors
output:
  fonts: ../../assets/fonts
  css: ../../_sass
templates:
  - scss
preprocessor_path: ../fonts/

I get this exception:

RUBY/lib/ruby/gems/2.2.0/gems/fontcustom-1.3.8/lib/fontcustom/generator/template.rb:181:in `binread': No such file or directory @ rb_sysopen - ../../assets/fonts/../assets/fonts/iconfont.woff (Errno::ENOENT)
        from RUBY/lib/ruby/gems/2.2.0/gems/fontcustom-1.3.8/lib/fontcustom/generator/template.rb:185:in `woff_base64'
        from RUBY/lib/ruby/gems/2.2.0/gems/fontcustom-1.3.8/lib/fontcustom/generator/template.rb:148:in `font_face'
        from (erb):5:in `template'
        from RUBY/lib/ruby/2.2.0/erb.rb:863:in `eval'
        from RUBY/lib/ruby/2.2.0/erb.rb:863:in `result'
        from RUBY/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:116:in `block in template'
        from RUBY/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:53:in `call'
        from RUBY/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:53:in `render'
        from RUBY/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:46:in `identical?'
        from RUBY/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:72:in `on_conflict_behavior'
        from RUBY/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:113:in `invoke_with_conflict_check'
        from RUBY/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:60:in `invoke!'
        from RUBY/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions.rb:94:in `action'
        from RUBY/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:25:in `create_file'
        from RUBY/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:115:in `template'
        from RUBY/lib/ruby/gems/2.2.0/gems/fontcustom-1.3.8/lib/fontcustom/generator/template.rb:59:in `block in create_files'
        from RUBY/lib/ruby/gems/2.2.0/gems/fontcustom-1.3.8/lib/fontcustom/generator/template.rb:55:in `each'
        from RUBY/lib/ruby/gems/2.2.0/gems/fontcustom-1.3.8/lib/fontcustom/generator/template.rb:55:in `create_files'
        from RUBY/lib/ruby/gems/2.2.0/gems/fontcustom-1.3.8/lib/fontcustom/generator/template.rb:21:in `generate'
        from RUBY/lib/ruby/gems/2.2.0/gems/fontcustom-1.3.8/lib/fontcustom/base.rb:51:in `start_generators'
        from RUBY/lib/ruby/gems/2.2.0/gems/fontcustom-1.3.8/lib/fontcustom/base.rb:22:in `compile'
        from RUBY/lib/ruby/gems/2.2.0/gems/fontcustom-1.3.8/lib/fontcustom/cli.rb:77:in `compile'
        from RUBY/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
        from RUBY/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
        from RUBY/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
        from RUBY/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
        from RUBY/lib/ruby/gems/2.2.0/gems/fontcustom-1.3.8/bin/fontcustom:5:in `<top (required)>'
        from RUBY/bin/fontcustom:23:in `load'
        from RUBY/bin/fontcustom:23:in `<main>'

Values of some variables at the failure:

@options[:output][:fonts]=../../assets/fonts
#{@font_path}.woff=../assets/fonts/iconfont.woff
woff_path=../../assets/fonts/../assets/fonts/iconfont.woff

There's one too many File.join for woff_path, but that doesn't affect the result.

@mgrsskls
Copy link

mgrsskls commented Jul 2, 2015

Exactly the same here!

@baofengs
Copy link

Got the same problem~ BUT I fixed it

I did some changes in this file /usr/local/lib/ruby/gems/2.3.0/gems/fontcustom-2.0.0/lib/fontcustom/generator/template.rb

def woff_base64
    # woff_path = File.join(@options[:output][:fonts], "#{@font_path}.woff")
    woff_path = "#{@font_path_alt}.woff"
    Base64.encode64(File.binread(File.join(woff_path))).gsub("\n", "")
end

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

No branches or pull requests

3 participants