我正在尝试导入以下字体以在我的 html 输出中使用。它们已包含在我的 .css 文件中,但它不起作用。
@import url('https://fonts.googleapis.com/css?family=Josefin+Sans:300,300i,400,400i,600,600i,700,700i');
@import url('https://fonts.googleapis.com/css?family=Fira+Sans:300,300i,400,400i,500,500i,600,600i,700,700i');
@import url('https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600');
h1, h2, h3 {
font-family: 'Josefin Sans, serif';
font-weight: normal;
}
body {
font-family: 'Fira Sans', serif;
}
.remark-code, .remark-inline-code {
font-family: 'Source Code Pro', monospace;
}
我的 YAML 看起来像这样:
---
title: "title"
subtitle: "subtitle"
author: "author"
date: "date"
output:
html_document:
toc: true # table of content true
toc_float: true
depth: 3 # upto three depths of headings (specified by #, ## and ###)
number_sections: false ## if you want number sections at each table header
css: [style.css]
highlight: zenburn # specifies the syntax highlighting style
fig.retina: 3
self_contained: yes
---
为什么我的 html 输出没有使用指定的字体?我们非常欢迎任何帮助!
最佳答案
在您的代码中进行以下更改
h1, h2, h3 {
font-family: 'Josefin Sans', serif;
font-weight: normal;
}
Right Way -> font-family: 'Josefin Sans', serif;
Wrong Way -> font-family: 'Josefin Sans, serif';
关于html - 使用 knitr 导入 html 输出的字体类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58779282/