Using @font-face with Rails 3.1 app?

前端 未结 7 1816
青春惊慌失措
青春惊慌失措 2020-12-02 08:23

I\'m having trouble using the following @font-face declaration to work with my Rails 3.1 app. I put the fonts in the Asset Pipeline in its own folder called \"

7条回答
  •  时光说笑
    2020-12-02 08:56

    I know this is an old question, but I just stumbled across this issue with rails 3.2, and after reading the link to the documentation posted previously, there was no need to edit the application.rb. All I needed to do was do the following in my stylesheet (using sass)

    @font-face {
        font: {
           family: 'Junction';
           weight: 'normal';
           style: 'normal';
        }
        src: asset-url('Junction-webfont.eot', font);
        src: asset-url('Junction-webfont.eot', font) format('embedded-opentype'),
             asset-url('Junction-webfont.woff', font) format('woff'),
             asset-url('Junction-webfont.ttf', font) format('truetype'),
             asset-url('Junction-webfont.svg#JunctionRegular', font) format('svg')
    }
    

    So instead of using url, I used the generic asset-url, which takes 2 arguments, the file and the asset class, in this case 'font'.

提交回复
热议问题