Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to use an OCR-A font in a LaTeX document to embed a short code.

I've finally got it reading a system font that I've installed (I think from ocr-a-font), which works well in any other application that I've tried it in, including GIMP, Inkscape, and Synfig.

When I try to use it in my LaTeX document, I'm only seeing the uppercase and numeral characters.

{\fontfamily{ocra}\fontseries{m}\fontshape{n}\selectfont [xxxx-xxxx] }

The document is an article, with hyperref, enumitem, and tikz, and I'm compiling with pdflatex.

MWE (requires font to be installed, so I don't know how useful it will be)

% mwe.tex
\documentclass{article}
\begin{document}
{\fontfamily{ocra}\fontseries{m}\fontshape{n}\selectfont aBcD-0123 }
\end{document}

When compiled with pdflatex mwe.tex, I only see BD-0123. MWE Output (PDF viewed in Document Viewer)

Might anyone know what is causing this, and how it could be remedied?

share|improve this question
2  
The ocra font has only uppercase letters. –  egreg Sep 22 '13 at 16:34
    
@egreg the font that I'm using has both uppercase and lowercase letters, how can I tell which font is being used? imgur.com/gN3F7yI –  Ryan Leonard Sep 22 '13 at 16:42
    
Not the font you're choosing with the \fontfamily{ocra} declaration, which probably is the legacy font found on CTAN. –  egreg Sep 22 '13 at 18:04

1 Answer 1

I have obtained a (not very satisfying) result by downloading OCRA.pfa and OCRA.afm from that site; I then modified the entry in OCRA.afm for z, changing enc-122 into z.

Running afm2tfm OCRA.afm and preparing in the same directory the file

\documentclass{article}
\usepackage{fonttable}

% make the pfa file known to pdftex
\pdfmapline{+OCRA < OCRA.pfa}
% create a new font family
\DeclareFontFamily{U}{OCRA}{}
\DeclareFontShape{U}{OCRA}{m}{n}{<->OCRA}{}

\begin{document}
\xfonttable{U}{OCRA}{m}{n}
\end{document}

produces the following output.

enter image description here

So your document can be

\documentclass{article}

% make the pfa file known to pdftex
\pdfmapline{+OCRA < OCRA.pfa}
% create a new font family
\DeclareFontFamily{U}{OCRA}{}
\DeclareFontShape{U}{OCRA}{m}{n}{<->OCRA}{}

\begin{document}
{\usefont{U}{OCRA}{m}{n}aBcD-0123}
\end{document}

The .tfm, and .pfa files can be moved in a directory known by the TeX system, for instance

/usr/local/texlive/texmf-local/fonts/tfm/ocra/ocra.tfm
/usr/local/texlive/texmf-local/fonts/type1/ocra/ocra.pfa

(note the case change) and you can make a small package:

\ProvidesPackage{ocra}

\pdfmapline{+ocra < OCRA.pfa}

\DeclareFontFamily{U}{ocra}{}
\DeclareFontShape{U}{ocra}{m}{n}{<->ocra}{}

\DeclareRobustCommand{\ocratext}{\usefont{U}{ocra}{m}{n}}
\DeclareTextFontCommand{\textocra}{\ocratext}

to be saved as /usr/local/texlive/texmf-local/tex/latex/ocra/ocra.sty.

Run mktexlsr as super user and then your document can be

So your document can become

\documentclass{article}

\usepackage{ocra}

\begin{document}
\textocra{aBcD-0123}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.