2013-06-18 89 views
3

如果您只有一個字體系列,Icomoon字體可以正常工作,但如果我創建了另一個字體系列並希望與第一個字體一起使用,該怎麼辦?我試圖做這樣的事情:如何使用多個Icomoon字體(多種字體系列)

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

@font-face { 
    font-family: 'abccons'; 
    src:url('fonts/abccons.eot'); 
    src:url('fonts/abccons.eot?#iefix') format('embedded-opentype'), 
    url('fonts/abccons.woff') format('woff'), 
    url('fonts/abccons.ttf') format('truetype'), 
    url('fonts/abccons.svg#abccons') format('svg'); 
    font-weight: normal; 
    font-style: normal; 
} 

我有與font-family完全相同的字體文件名。另外我爲第一個字體圖標使用「data-icon」屬性,第二個使用「data-icon2」屬性。

[data-icon]:before { content:attr(data-icon); font-family:'icomoon'; font-variant:normal; font-weight:normal; line-height:1; speak:none; text-transform:none; -webkit-font-smoothing:antialiased; } 

[data-icon2]:before { content:attr(data-icon2); font-family:'abccons'; font-variant:normal; font-weight:normal; line-height:1; speak:none; text-transform:none; -webkit-font-smoothing:antialiased; } 

不知道我是否以正確的方式做。字體以http://css-tricks.com/html-for-icon-font-usage/中描述的方式加載。結果是:第一個字體正確加載,而第二個字體似乎已經加載了一些東西,但全部顯示爲方形,而不是字體。如果我在css文件中設置爲data-icon2,但在html中使用data-icon3(打算出錯),則不會加載任何內容。

有什麼想法?

回答