# What are .gf and .pk font files?

I've recently read this very interesting thread: How (La)TeX makes use of font related files, i.e., .fd, .map, .enc, .def,etc when selecting fonts?.

In the meantime, I've been playing with compiling (for fun) MetaFont `.mf` files found in my MiKTeX distribution.

For example, I've compiled the file `cmr10.mf` and it has produced the file `cmr10.2602gf`, which seems to have one of the filetypes mentioned in the above thread (`.gf`, or something similar).

Now, given that `.gf` files are the output of MetaFont (or not?),

1. what are they used for? are they only useful for being converted to `.pk` files through `gftopk`?
2. what are exactly `.pk` files and what are they used for? (egreg's answer doesn't mention this filetype)
3. how do I obtain `.tfm` or `.vf` font metric files from MetaFont output, since I seem to understand from that thread that these are the "real" font files searched by LaTeX?
-

If you are using a metafont font (which is increasingly rare) then the original source is written in MetaFont. Processing that source with metafont produces two files: the `tfm` file which encodes the font metrics (that is essentially just the size of each character, and information about ligatures and kerns with no information about shape) and a `gf` file which contains a sequence of bitmaps at a specified resolution (that needed to be specified to metafont, usually as part of a printer configuration). (The resolution by default got recorded in the file extension hence the example in your question)

tfm files are read directly by TeX but few programs could read gf fonts directly so they were almost always converted immediately to pk (packed) format which contained the same information in a more compressed form and could be read by dvi drivers such as dvips or xdvi.

So the end result was you could generate bitmap pk fonts exactly tuned to the printer you were using, not just the basic resolution but "blackness" control, ie how well the printer could cope with thin lines, or lines close together, metafont would if needed produce bitmaps with thicker lines etc. For printing on paper this produced very high quality output and for viewing on screen it could produce good results if you had high resolution and sensibly sampled and anti-aliased the bitmaps to the screen resolution, as dviview or xdvi did, but acrobat in its earlier versions made bitmap fonts more or less unreadable, which increased the urgency to develop type1 and other scalable format versions of the TeX fonts, which are the forms most commonly used today.

To see how the bitmaps were tuned to each printer look at `modes.mf`

``````/usr/local/texlive/2013/texmf-dist/metafont/misc/modes.mf
``````

on my system

It's a very long file with information such as

``````% From {\tt ..........compulink.co.uk}, 9 February 1994.
mode_def bjtenex =                  %\[ Canon BubbleJet 10ex (360dpi)
mode_param (pixels_per_inch, 360);
mode_param (blacker, .6);
mode_param (fillin, 0);
mode_param (o_correction, .6);
mode_common_setup_;
enddef;
``````

which tells metafont how to make bitmaps tuned to that particular printer model. (You can see this isn't ideal for putting pdf on the web to be printed anywhere)

`pixels_per_inch` is the resolution

`blacker` is a measure of how much blacker (ie thicker) thin lines need to be before they disappear when printed on this device.

`fillin` controls diagonals so that the angles in the corners would remain sharp and not be "filled in" as an artefact of the resolution.

`o_correction` is overshoot correction to control whether curves should overshoot the bounding box (which works better at higher resolutions than lower)

These mode corrections have no effect on the font metrics in the tfm file, so tex would produce the same dvi file in all cases but dvips would use them to pull in printer-specific bitmaps depending which printer was being targeted with the PostScript.

-
@Sterry Just to add a little thing to David's great answer: to obtain the `.tfm` file from the `.mf` source, add the line `fontmaking:=1;` in that file (David will correct me if I'm wrong...) –  karlkoeller Jun 21 '13 at 17:56
The way you use the past sense suggests this is no longer the case for e.g. `pdflatex` - is that so ? –  ach Jun 21 '13 at 20:26
@ach you can still use bitmap fonts with all the tex variants, it's just that normally, you don't. If you have the `pdffonts` utility or the fonts menu in acrobat look at any of your latex generated pdf and see how many have Type 3 fonts. –  David Carlisle Jun 21 '13 at 21:52
Thanks for this very exhaustive response. However you didn't answer my third question (probably I had better to start a new thread with that one). About tfm files, you said they are produced from the source, but I haven't been able to achieve a result following @karlkoeller's comment. And what about vf files? How to generate them? Thanks. –  Sterry Jun 22 '13 at 4:20
@Sterry I'll add something about vf files (which are rather different)later –  David Carlisle Jun 22 '13 at 14:24