I cannot tell why you have to use XeLaTeX or LuaLaTeX without seeing more of your code and the actual error messages. However, using these engines should still be possible. My suggestion would be to use
mainfont: TeX Gyre Termes
as YAML header. This brings two changes. First, a special YAML header is used to set the font name instead of using raw LaTeX code. Second, a Times-clone is used instead of the Times font. This font should be included in the TeX installation on shinyapps.io. If it is not, this would be a good reason to contact their support staff.
I have tested this on Linux and it should also work on Windows. However, Mac OS does not allow loading fonts by name from the TEXMF tree with XeLaTeX. There you either have to switch to LuaLaTeX or load the fonts by file name:
BoldFont = texgyretermes-bold.otf,
ItalicFont = texgyretermes-italic.otf,
BoldItalicFont = texgyretermes-bolditalic.otf]
This also works on Linux (and probably Windows), but is rather ugly with all the necessary quoting.
Now for the more general question of how to use a font where no clone is available, I would try the following:
- Include the font as TTF or OTF file in you Shiny app along with the Rmd file.
- Also copy the font file when copying the Rmd file to a temp directory before processing.
- In the Rmd refer to the font by file name. Since the font is in the same directory, no path should be necessary.