使用 knitr 为 html 输出导入字体类型

importing font type for html output using knitr

我正在尝试导入以下字体以用于我的 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';