Quarto not able to render font Roboto Condensed to PDF

42 views Asked by At

I want to create a report by using Quarto. However, I am facing a font issue ( html was okay, but not for pdf ).

I am using mtcars data set so that it eases the troubleshooting progress. The below is my code in .qmd :

---
format: html
editor: visual
self_contained: TRUE
---

## Report as of `r format(Sys.Date(), "%d-%b-%Y")`

```{r message = FALSE, warning = FALSE, echo = FALSE}
packages <- c("here", "readxl", "openxlsx", "plotly","ggplot2", "esquisse", "tidyverse", "lubridate", "future.apply","ggthemes","hrbrthemes","ggrepel")
if (!require(pacman)) install.packages("pacman" , repos = "http://cran.us.r-project.org")
pacman::p_load(char = packages)


unique_carb <- unique(mtcars$carb)
unique_carb <- sort(unique_carb)

for (carb_val in unique_carb) {
  subset_data <- subset(mtcars, carb == carb_val)
  
  p <- ggplot(subset_data) +
    aes(x = mpg) +
    geom_histogram(bins = 30L, fill = "#58e6ed") +
    theme_ft_rc() + 
    scale_fill_ft() +
    ggtitle(paste("Carb =", carb_val))
  
  print(p)
}
```

However, I got the error message as below :

==> quarto preview mtcars.qmd --to pdf --no-watch-inputs --no-browse
    
     
    
    processing file: mtcars.qmd
    1/2                  
    2/2 [unnamed-chunk-1]
    
    Quitting from lines 10-30 [unnamed-chunk-1] (mtcars.qmd)
    Error in `grid.Call.graphics()`:
    ! invalid font type
    Backtrace:
      1. global .main()
     57. grid:::drawGrob(x)
     59. grid:::drawDetails.text(x, recording = FALSE)
     60. grid:::grid.Call.graphics(...)
    There were 50 or more warnings (use warnings() to see the first 50)
    Execution halted

My first attempt :

    library(extrafont)
    loadfonts(device = "win")

> loadfonts(device = "win")
Roboto Condensed already registered with windowsFonts().
...

I can see that "Roboto Condensed" have already downloaded... but when I double check with windowsFonts() , I don't see "Roboto Condensed" appear in the list...

My second attempt :

p <- p + theme_ft_rc(base_family = "Times New Roman") 

But I will still get the exactly same error message.

Need help... I have tried anything I could...

0

There are 0 answers