我是 Nextjs 的新手。我想将我的自定义字体添加到我的项目中。我完全不知道该怎么做(我的字体在“public/fonts/”中)。我的 global.css 文件是这样的-
html,
body {
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
}
a {
color: inherit;
text-decoration: none;
}
* {
box-sizing: border-box;
}
@font-face {
font-family: "Avenir";
src: url("../public/fonts/AvenirNextRoundedStd-Demi.ttf");
src: url("../public/fonts/AvenirNextRoundedStd-MedIt.ttf");
src: url("../public/fonts/AvenirNextRoundedStd-Reg.ttf");
}
这是我的下一个配置文件 -
// next.config.js
const withCSS = require("@zeit/next-css");
module.exports = withCSS({
/* config options here */
});