Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>We keep our fonts in the /app/assets/fonts folder and to my recollection we did not have to do any additional configuration.</p> <p>You do however have to use the <code>asset_path</code> helper in your CSS files when you reference the fonts (same as when referencing asset pipeline images in CSS). This requires changing your file extension from <strong>.css</strong> to <strong>.css.erb</strong>. It's hard to tell for certain from your description but I'm guessing that may be the problem.</p> <p><br/></p> <h3>Example</h3> <p>We use the Museo500 font in our app and store it in app/assets/fonts:</p> <pre><code>app/assets/fonts: - museo700-regular-webfont.eot - museo700-regular-webfont.woff - museo700-regular-webfont.ttf - museo700-regular-webfont.svg </code></pre> <p>The @font-face declaration is as follows:</p> <pre><code>@font-face { font-family: 'Museo700'; src: url('&lt;%= asset_path "museo700-regular-webfont.eot" %&gt;'); src: url('&lt;%= asset_path "museo700-regular-webfont.eot" %&gt;?#iefix') format('embedded-opentype'), url('&lt;%= asset_path "museo700-regular-webfont.woff" %&gt;') format('woff'), url('&lt;%= asset_path "museo700-regular-webfont.ttf" %&gt;') format('truetype'), url('&lt;%= asset_path "museo700-regular-webfont.svg" %&gt;#Museo700') format('svg'); font-weight: normal; font-style: normal; } </code></pre> <p><br/></p> <h3>Benefits of using asset pipeline for binary files</h3> <p>We don't do any kind of precompilation for image or font assets (I guess you could gzip the fonts or something but we don't) but I still see a benefit to hosting them through the asset pipeline: uniformity and convention. With Rails convention can offer all kinds of benefits.</p> <p>Ex: At some point you may want to use a CDN like Amazon Cloudfront and will need to make all your asset urls in production point to the CDN copies. If you're hosting all your assets including fonts and images through the asset pipeline that change is as easy changing the asset_host in your production.rb file by uncommenting the lines:</p> <pre><code> # Enable serving of images, stylesheets, and JavaScripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" </code></pre> <p>If you're already referencing your fonts with the <code>asset_path</code> helper then those urls will be updated automatically to point to the CDN. I guess it's as much a benefit of using path_helpers as the asset pipeline itself, but either way it's beneficial.</p> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload