title: How to include @font-face within style tag of RMarkdown?
body: <p>Is it possible to use the <a href="https://stackoverflow.com/questions/8749225/loading-an-external-font-via-inline-css">CSS @font-face</a> to provide font files to an RMarkdown? </p>
  
  <p>e.g.:</p>
  
  <pre><code>&lt;style&gt;
  @font-face {
      font-family: "Custom";
      src: url(https://github.com/stevecondylios/fonts/raw/master/CircularStd-Book.ttf) format("truetype");
  }
  body {
      font-family: "Custom", Verdana, Tahoma;
  }
  &lt;/style&gt;
  </code></pre>
  
  <p>Note that the exact same css code above (less the style tags) <strong><em>does work</em></strong> when it's stored in an external .css file locally and referenced in the Rmd's yaml with </p>
  
  <pre><code>---
  title: "My Rmarkdown doc"
  date: "28 April 2020"
  output: 
    html_document:
      css: mystyles.css
  ---
  </code></pre>
  
  <h3>Ultimate goal</h3>
  
  <p>In case this is an A/B problem, my simple goal is to apply a custom font while avoiding using any local files beyond the Rmd file itself (i.e. no local external style sheets, although reading files from the web is fine). </p>
  
  <p>I believe the only two options are either reading a font file in from the web within <code>&lt;style&gt; ... &lt;/style&gt;</code>, or <a href="http://stephenscaff.com/articles/2013/09/font-face-and-base64-data-uri/" rel="nofollow noreferrer">base64 encoding the font info within the  tags of the Rmd itself</a>. I've been trying both with little success. </p>
  
  <p>A third option could be to provide a url (to a style sheet) to a yaml value, although I am not sure if that's possible</p>
  
  <pre><code>  html_document:
      code_folding: hide
      css: get_file(www.mysite.com/mystyles.css)
  </code></pre>
  
  <h3>Further attempts</h3>
  
  <p>For good measure, I also tried</p>
  
  <pre><code>```{r}
  css_url &lt;- "https://github.com/stevecondylios/fonts/raw/master/CircularStd-Book.ttf"
  ```
  
  &lt;style&gt;
  @font-face {
      font-family: "Custom";
      src: url(`r css_url`) format("truetype");
  }
  body {
      font-family: "Custom", Verdana, Tahoma;
  }
  &lt;/style&gt;
  ```
  </code></pre>
  
  <h3>Update</h3>
  
  <p>I have learned you cannot declare <code>@font-face</code> in the HTML body, but must do so in the header. We can indeed <a href="https://stackoverflow.com/a/43334558/5783745">add HTML tags into the RMarkdown header</a>, but this reads in an external file, which is precisely what I'm trying to avoid, so am back to square 1. </p>