Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 资源路径-未应用字体_Ruby On Rails_Ruby_Ruby On Rails 3_Asset Pipeline_Jruby - Fatal编程技术网

Ruby on rails 资源路径-未应用字体

Ruby on rails 资源路径-未应用字体,ruby-on-rails,ruby,ruby-on-rails-3,asset-pipeline,jruby,Ruby On Rails,Ruby,Ruby On Rails 3,Asset Pipeline,Jruby,我正在尝试使用以下方式在rails应用程序中加载一些其他字体: Jruby 1.7.3 轨道3.2.13 css(其类型为css.scss.erb)文档位于app/assets/stylesheets/custom/folder中,如下所示: @font-face { font-family: 'Lato'; font-style: normal; font-weight: 300; src: url('<%= asset_path('/fonts/Lato

我正在尝试使用以下方式在rails应用程序中加载一些其他字体:

  • Jruby 1.7.3
  • 轨道3.2.13
  • css(其类型为css.scss.erb)文档位于app/assets/stylesheets/custom/folder中,如下所示:

    @font-face {
        font-family: 'Lato';
        font-style: normal;
        font-weight: 300;
        src: url('<%= asset_path('/fonts/Lato-Light.woff') %>') format('woff');
    }
    @font-face {
        font-family: 'Lato';
        font-style: normal;
        font-weight: 400;
        src: url('<%= asset_path('/fonts/Lato-Regular.woff') %>') format('woff');
    }
    @font-face {
        font-family: 'Lato';
        font-style: normal;
        font-weight: 700;
        src: url('<%= asset_path('/fonts/Lato-Bold.woff') %>') format('woff');
    }
    
    @font-face{
    字体系列:“Lato”;
    字体风格:普通;
    字体大小:300;
    src:url(“”)格式('woff');
    }
    @字体{
    字体系列:“Lato”;
    字体风格:普通;
    字体大小:400;
    src:url(“”)格式('woff');
    }
    @字体{
    字体系列:“Lato”;
    字体风格:普通;
    字号:700;
    src:url(“”)格式('woff');
    }
    
    字体文件位于应用程序库/资源/字体文件夹中。我在application.rb文件中添加了以下行:


    config.assets.path正如我从Rails 3.1中读到的:

    公用文件夹不再是CSS、图像和文件夹的支持位置 字体,而是存在于app/assets/*和vendor/assets中/* 文件夹

    因此,要设置新字体,我遵循以下步骤:

  • 从下载desire字体
  • 转换每个文件-
  • 在/vendor/assets/font中复制所有*.eot、*.svg、*.ttf、*.woff文件 文件夹
  • 在/assets/stylesheets/custom/文件夹中创建font.css.scss文件 详情如下:

  • 来源:

    看看这个,在rails@richlevis中设置@fontface,谢谢我在那里找到了解决方案。
    config.assets.paths << Rails.root.join('lib', 'assets', 'fonts')
    
    @font-face {
    
    font-family: 'RobotoCondensed';
    src: asset-url('robotocondensed-regular-webfont.eot', 'font');
    src: asset-url('robotocondensed-regular-webfont.eot?#iefix', 'font') format('embedded-opentype'),
    asset-url('robotocondensed-regular-webfont.woff', 'font') format('woff'),
    asset-url('robotocondensed-regular-webfont.ttf', 'font') format('truetype'),
    asset-url('robotocondensed-regular-webfont.svg#roboto_condensedbold','font') format('svg');
    font-weight: normal;
    font-style: normal;
    }