Problem with generating rmarkdown pdf report with Ukrainian alphabet via shiny app

Hey guys!

I am trying to create shiny app, that produces rmarkdown pdf reports with content depending on user input. Text will be in Latin and Ukrainian alphabet. App works perfectly locally, however hosted on does not display Ukrainian text.

Minimal example:


f = dir("www")
file.copy(paste("www/",f,sep=""), "~/.fonts")  
system('fc-cache -f ~/.fonts') 
  ui = fluidPage(
    downloadButton("report", "Generate report")
  server = function(input, output) {
    output$report <- downloadHandler(
      filename = "report.pdf",
      content = function(file) {
        tempReport <- file.path(tempdir(), "report.Rmd")
        file.copy("report.Rmd", tempReport, overwrite = TRUE)
        params <- NULL
        rmarkdown::render(tempReport, output_file = file,
                          params = params,
                          envir = new.env(parent = globalenv())


geometry: "left=5mm,top=5mm,right=10mm,bottom=5mm"
    latex_engine: xelatex
      tikz: null
      enumitem: null
      xcolor: null
      polyglossia: null
      blindtext: null
      rotating: null
      multicol: null
  - \newfontfamily{\cyrillicfont}{Arimo-Regular.ttf}
  - \newfontfamily{\cyrillicfontsf}{Arimo-Regular.ttf}

This is text in latin alphabet. 

Це український текст.

If anyone has idea how to make it working on, I would appreciate.

I suspect there might be an issue with your fonts. You seem to be installing them at the OS level, which is kinda risky as you need to distribute the ttf file. I believe you would be better off with installing them at LaTeX level, via an appropriate font package. runs on Ubuntu, which runs on UTF-8 and should not have issues with Cyrillic (I know it handles Czech well, but haven't tried Cyrillic, and your code doesn't run for me).

You may also consider putting the LaTeX code into a template file, I have found it much easier to troubleshoot than YAML. Have a look at this earlier topic on this matter: