user1157485
user1157485

Reputation:

importing font type for html output using knitr

I am trying to import the following fonts to be used in my html ouput. They have been included in my .css file, but it is not working.

@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;
}

My YAML looks like this:

---
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
---

Why my html output is not using the specified fonts? Any help is more than welcome!

Upvotes: 0

Views: 433

Answers (1)

Par Tha
Par Tha

Reputation: 1531

Do the below changes in your code

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';

Upvotes: 1

Related Questions