我已经下载了.ttf文件从谷歌字体到我的本地css文件夹,但似乎不能正确加载它们。我尝试过以下方法:
CSS
@import url('./css/css?family=Cabin+Condensed:400,500,600,700');
@font-face {
font-family: 'Cabin Condensed';
font-style: normal;
font-weight: 700;
src: local('Cabin Condensed') format('truetype');
}
body, html {
font-family: 'Cabin Condensed', sans-serif;
}HTML
<link href="./css/css?family=Cabin+Condensed:400,500,600" rel="stylesheet">我没有收到任何错误,但字体也没有显示。奇怪的是,官方文件甚至没有提到本地字体。
发布于 2018-05-02 07:31:31
在我看来,问题是使用local路径,它需要在本地安装字体。
尝试删除@import并将src: url的回退添加到src: local中
@font-face {
font-family: 'Cabin Condensed';
src: local('Cabin Condensed'), url(<path to the TTF file>);
}例如:
@font-face {
font-family: 'Cabin Condensed';
src: local('Cabin Condensed'), url('/css/fonts/Cabin-Condensed.ttf');
}https://stackoverflow.com/questions/50129139
复制相似问题