Note that there are some explanatory texts on larger screens.

plurals
  1. PONew Bulletproof @font-face syntax using Data URIs in Compass
    primarykey
    data
    text
    <p> I am using compass' <code>font-face</code> mixin along with the <code>inline-font-files</code> and <code>font-files</code> in order to create something along the lines of the <a href="http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax" rel="noreferrer">The New Bulletproof @Font-Face Syntax</a> using <a href="http://en.wikipedia.org/wiki/Data_URI_scheme" rel="noreferrer">Data URIs</a> for woff, ttf and otf files.</p> <p>I use relative URLs for eot (due to lack of IE support for data URI) and for svg files, (due to the #FontName hash I guess). The eot file poses no problem since there is a parameter for that, but because <code>font-face</code> in Compass treats svg no different from other formats I simply cannot use <code>inline-font-files</code> to include the font data, since that would make the svg version inline as well. </p> <p>Is there a way to make <code>font-face</code> return something like the below:</p> <pre class="lang-css prettyprint-override"><code>@font-face { font-family: 'PTSans'; src: url('pts55fwebfont.eot'); src: url('pts55fwebfont.eot?#iefix') format('embedded-opentype'), url('data:WOFF_DATA') format('woff'), url('data:TTF_DATA') format('truetype'), url('pts55fwebfont.svg#PTSansRegular') format('svg'); font-weight: normal; font-style: normal; } </code></pre> <p>The thing is I cannot figure out how to make the woff, otf and ttf versions use the Data URI while still allowing the svg version to use a standard URL. The best I have come up with is this:</p> <pre class="lang-css prettyprint-override"><code>@include font-face('PTSans', inline-font-files('ptsans/pts55fwebfont.woff', woff, 'ptsans/pts55fwebfont.ttf', truetype), 'ptsans/pts55fwebfont.eot', normal, normal); @include font-face('PTSans', font-files('ptsans/pts55fwebfont.svg#PTSansRegular'), $weight: normal, $style: normal); </code></pre> <p>Which will break the svg into its own @font-face. Is that valid CSS on the same account that I can create multiple @font-face rules with the same family name using different weights and styles? If that is the case, will it work just as good as the example CSS above (it appears to)? And, of course, is there a better way of accomplishing this in Compass/sass?</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.
 

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