# How can one determine where in a document a font is used?

Looking at the output of pdffonts, I see fonts I expect and some I do not. How can I determine where a particular font is used? For example, I see that SFTT1095 is being used somewhere in one of my documents. Google tells me this is from the cm-super package (which I am not using) and that it is the computer modern typewriter font. I don't believe I have any text in typewriter font and I don't see a difference when I change the typewriter font to a different font.

Is there a good way to determine what is causing this particular font to be embedded? Some sort of visual pdf debugger would be handy.

I suspect that in the end, I'll just end up binary searching my way through the document, but I'm hoping there's a better way.

-
Not sure either. I'd also love something similar in a PDF viewer. – Will Robertson Sep 8 '10 at 15:41

I would at first look when t1cmtt.fd is loaded. This should give you some indication when the font is used the first time.

You could also manipulate the map-line. With a bit chance you can see where the font is used, or you get at least informations in the log about the glyph names used.

 \documentclass{scrartcl}

\usepackage[ansinew]{inputenc}
\usepackage[T1]{fontenc}
\pdfmapline{=ectt1095 SFTT1095 <SkakNew-Figurine.pfb}

\begin{document}
abc {\ttfamily abc KQR}

\end{document}

-
The main problem with the manipulated map line is that "replacement" font can miss some of the glyph, which will give gap. One can improve the idea by using an encoding: – Ulrike Fischer Sep 9 '10 at 12:34
\pdfmapline{=ectt1095 SFTT1095 " TestEncodingBell ReEncodeFont " <test-enc.enc <wasy10.pfb} where the content of test-enc.enc is /TestEncodingBell[/bell /bell ...256 times] def. This will replace each glyph of the font with a bell. – Ulrike Fischer Sep 9 '10 at 12:35

You can do this with Acrobat Professional, but it's a little bit obscure. Here's the recipe for Acrobat 9:

1. Advanced->Preflight...
2. Select the Profiles tab, and the left of the three buttons (with the tooltip Select profiles, and an icon that's maybe supposed to be a basket?)
3. This step is optional, but if you do it then you can choose the fonts from a list instead of having to type them:
• Select any one of the profiles (I like Report PDF syntax issues) and execute it by pressing the Analyze button.
• Assuming there were no errors, go back to the profile tab
4. From the Options button/menu in the top right of the window, select Create New Preflight Profile...
5. Give the profile a name (eg "Check usage of specific fonts").
6. In the tree panel on the left, on the Fonts branch of your new profile.
7. Use the dropdown next to A font is used which is to change it to Info.
8. Click on the Add... button and choose the font(s) you wish to investigate (if you skipped the optional step above, then you have to simply type the font name, ignoring the 6-character random prefix).
9. Click OK, select your new profile (under Custom profiles) and press Analyze
10. Expand the Text uses font tree branch, to see all the uses. Choose the different uses of your font(s) and either double click to jump to the location in the document (with a box around it for emphasis), or click Show in snap to see a preview of only the text in question.

Another useful tool for investigating the usage of fonts in PDFs is also available from the Acrobat 9 preflight tool. Click on the Options button/menu and choose Create inventory.... Check only Fonts and click OK. Now you have a document showing the use of all the fonts, including which glyphs are included in the subset, what are their Unicode names, which pages they appear on, as well as other arcana such as the PostScript name and the italic angle.

-
Thanks. Those look pretty good...except that I don't own Acrobat so I can't try them out. =/ – TH. Sep 9 '10 at 18:31

I usually open the PDF in FontForge, select the font in question and see what subset of glyphs are used and then search for them in the PDF. Might not be the best method, but I used it a lot while testing unicode-math package to see what symbols were still taken from CM and not from my fonts.

-