我有一個角度cli的Angular項目設置。我想捆綁的Roboto字體,我的網站,所以我做的事情是這樣的我在styles.scss聲明它谷歌Web字體沒有在Angular中使用?
/* You can add global styles to this file, and also import other style files */
@import url('https://fonts.googleapis.com/css?family=Roboto');
// Set Global Font
body {
font-family: 'Roboto', sans-serif;
margin: 0;
}
然而,這似乎是字體反正默認爲無襯線代替的Roboto。我試圖在index.html中添加一個鏈接,效果相同。
P.S.不確定是否有關,但我也補充材料圖標
// Import Material Icons
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: local('Material Icons'),
local('MaterialIcons-Regular'),
url('../node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff2') format('woff2'),
url('../node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff') format('woff'),
url('../node_modules/material-design-icons/iconfont/MaterialIcons-Regular.ttf') format('truetype');
}
在同樣的文件,這可能在某種程度上對項目的影響?
看來你的解決方案正在工作。當我禁用Roboto字體系列時,字體實際上會改變,但爲什麼它不適用於在線CDN? –
@NikkiKononov有效的問題。我假設它是CLI編譯器的東西。在樣式標籤中添加CDN時,構建失敗。 而且,據我所知這是推薦的方式。確保你保持cli版本的更新。事情正在迅速改變 –
您可以按照相同的方式添加材料設計圖標@NikkiKononov –