# Getting a virtual font to work in LaTeX

In a quest for greater understanding of all thing LaTeX, I've been playing around with virtual fonts (eg. replacing a hyphenation character and How to create a virtual font?). However, I can't get LaTeX to recognize my new TFM file and I think the problem lies with my lack of understanding of the \pdfmapline command.

Here are the steps I took:

Copied a known working font from my tex directory:

cp /usr/share/texmf-texlive/fonts/tfm/public/cm/cmr10.tfm .


tftopl cmb10 cmb10


Edited cmb10.pl and saved the new file to foobar.vpl. In this case I've mapped the letter b->a just to see if what I've done had some effect (see sec. 6 here). Next I compiled the file to a binary format:

vptovf foobar.vpl


This creates foobar.tfm and foobar.vf. From reading around, it seems that the \pdfmapline looks in the local directory, so for the time being, I can leave the files where they are. Now my LaTeX document looks like:

\documentclass{article}
\pdfmapline{=foorbar cmr10}

\begin{document}
aaaa bbbb aaaa
\font\test=foobar aaaa bbbb aaaa \the\font
\end{document}


This compiles but it does not replace any of the b's with a's.

-
You don't switch to your test font, you just define it (just write \test after the \font .. foobar definition. And (I am not sure about that) your \pdfmapline should have a + instead of a =. –  topskip Oct 7 '11 at 5:37

As Patrick observed, you aren't switching to the new font.

(MAPFONT D 0 (FONTNAME cmr10))


to the generated pl file, changing the entry for b into

(CHARACTER C b
(CHARWD R 0.555557)
(CHARHT R 0.694445)
(MAP
(SELECTFONT D 0)
(SETCHAR C a)
)
)


and saving as foobar.vpl, after vptovf foobar, the document

\pdfmapline{=foobar cmr10}

aaa bbb aaa

\font\test=foobar aaa bbb aaa

\test aaa bbb aaa

\bye


processed with pdftex will give

aaa bbb aaa
aaa bbb aaa
aaa aaa aaa

as expected (the precise alignment is not shown here).

The command \the\font does nothing: it just produces the appropriate declaration for choosing the current font. If you want to print the .tfm file name you have to say \fontname\font. If we add this instruction to the three aaa bbb aaa lines we get

aaa bbb aaa cmr10
aaa bbb aaa cmr10
aaa aaa aaa fooaar

(in the third line the b is changed into a at printing time).

-