Source on Github

Compass Font Face

Provides a mixin to support @font-face. See CSS3 spec: @font-face.

This file can be imported using: @import "compass/css3/font-face"

Examples

Compass Font Face Example
How to use the @font-face mixin

Imports

  1. Shared Utilities

Mixins

view source

=font-face($name, $font-files, $eot: false, $weight: false, $style: false)
  $iefont: unquote("#{$eot}?#iefix")
  @font-face
    font-family: quote($name)
    @if $eot
      src: font-url($eot)
      $font-files: font-url($iefont) unquote("format('eot')"), $font-files
    src: $font-files
    @if $weight
      font-weight: $weight
    @if $style
      font-style: $style
@mixin font-face($name, $font-files, $eot: false, $weight: false, $style: false) {
  $iefont: unquote("#{$eot}?#iefix");
  @font-face {
    font-family: quote($name);
    @if $eot {
      src: font-url($eot);
      $font-files: font-url($iefont) unquote("format('eot')"), $font-files;
    }
    src: $font-files;
    @if $weight {
      font-weight: $weight;
    }
    @if $style {
      font-style: $style;
    }
  }
}

Cross-browser support for @font-face. Supports IE, Gecko, Webkit, Opera.

If you need to generate other formats check out the Font Squirrel font generator

In order to refer to a specific style of the font in your stylesheets as e.g. "font-style: italic;", you may add a couple of @font-face includes containing the respective font files for each style and specying respective the $style parameter. Order of the includes matters, and it is: normal, bold, italic, bold+italic.