syntax - 使用 Gatsby Plugin Google Fonts 添加多种字体的语法是什么?
问题描述
这适用于 Lobster Two 字体:
{
resolve: `gatsby-plugin-google-fonts`,
options: {
fonts: [
`Lobster Two`,
`source sans \pro:400, 400i`, // you can also specify font weights and styles
],
display: "swap",
}
我尝试在字体数组中添加 Poppins 并添加第二个字体数组,但都没有奏效。到目前为止,每个视频和文章都认为适合以一种字体作为演示。
谢谢您的帮助。
解决方案
gatsby-plugin-google-fonts
您需要添加每种特定类型,例如:
fonts: [
`montserrat`, `montserrat\:700`, `montserrat\:900`, `open sans`
]
我建议gatsby-plugin-google-fonts-v2
改用:
plugins: [
{
resolve: `gatsby-plugin-google-fonts-v2`,
options: {
fonts: [
{
family: 'Lobster Two',
},
{
family: 'Source Sans Pro',
weights: ['400, 400i']
}
]
}
}
];
如果上面的代码片段不起作用(检查<link>
生成的<header>
),请尝试遵循此GitHub 线程中建议的方法(在格式之前进行转换):
{
resolve: `gatsby-plugin-google-fonts-v2`,
options: {
fonts: [
{
family: 'Lobster Two',
},
{
family: 'Source Sans Pro:ital,wght@1,400;',
},
]
}
}
推荐阅读
- scala - 如何在火花数据框中明智地访问元素列
- rubygems - Ruby gem 的反向移植补丁
- python - python-使用底图在给定坐标处绘制热图
- php - Php Ziparchive extractTo 方法不提取 zip 文件
- c++ - 类成员值被前一个成员覆盖
- python - Specifying *args for a Callable type hint
- php - SQLSTATE[HY000] [1698]-Laravel-6.5.1
- hyperledger-sawtooth - 如何在事务处理器中将应用方法的调用限制为 1 而不是 2?
- python - 如何引用当前包以与 importlib.resources 一起使用?
- reactjs - 初始设置后未设置 useState