'How to load ocr-a font in r markdown with bookdown::pdf_document2 to change title font?

I am trying to change the font for the title of my pdf document in rmarkdown to ocr-a. I have tried tinytex::tlmgr_install("ocr") but only received error messages:

Cannot determine type of tlpdb from /home/<user>/texmf!
cannot setup TLPDB in /home/<user>/texmf at /usr/bin/tlmgr line 6424.
tlmgr update --self
fmtutil [ERROR]: format directory not writable: /var/lib/texmf/web2c
tlmgr install ocr

I have tried creating a home/<user>/textmf folder and copying ocra.mf, ocra.afm, ocra10.mf, ocra.pfb, ocra.ttf, ocra12.mf, ocra17.mf font files to the directory but this hasn't worked.

Also tried:

title: "My Title"
- \usepackage[ocr-a]{ocr}
- \usepackage{titling}
- \usepackage[T1]{fontenc}
- \pretitle{\vspace{\droptitle}\large\ocrfamily}

In yaml header and I get messages: ! Font OT1/ocra/m/n/12=ocr12 at 12.0pt not loadable: Metric (TFM) file not found.

I have tried placing the above files in


again to no benefit.


This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source