2011-02-28 55 views
3

我在Compass(0.11.beta.1)中使用@ font-face mixin並且無法定義粗體和斜體字體。Compass font-face mixin bold

我可以成功地加載和使用的字體用下面的代碼:

@include font-face("PTSerif", font-files("/path/to/font/PTF55F_W.ttf", truetype), "/path/to/font/PTF55F_W.eot"); 

但是我無法找到一個方法來定義粗體面。該源說,style參數已被棄用,並試圖使用它對輸出.css文件沒有影響。

@mixin font-face($name, $font-files, $eot: false, $postscript: false, $style: false) { 
    @if $postscript or $style { 
    @warn "The $postscript and $style variables have been deprecated in favor of the Paul Irish smiley bulletproof technique."; } 
    @font-face { 
    font-family: quote($name); 
    @if $eot { 
    src: font-url($eot); } 
    src: local("☺"), $font-files; } } 

我目前有兩種選擇:

  1. 編輯事後.css文件。對於可維護性沒有好處
  2. 爲不同的樣式定義不同的字體(也不是理想的,但現在可用的)例如

    @include字體面( 「PTSerif」)
    @include字體面( 「PTSerif-B」)

一直沒能找到如何做到這一點的任何適當的例子 - 能夠使用font-weight:bold;

在此先感謝。

回答

1

下面是一個結合常規,粗體和斜體的例子,我工作得很好:@font-face :: IM FELL ENGLISH

+1

我專門詢問有關使用羅盤做到這一點,似乎你的CSS是手工編碼? 此外,你已經實現了與表達類,我想避免這一點。 – acarabott 2011-03-02 10:28:14