ArticleslgStudy

science

TeX font metric

TeX font metric is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand TeX font metric rather than just read about it. In short: TeX font metric (TFM) is a font file format used by the TeX typesetting system. It is a font metric format, not an outline font format like TrueType, because it provides only the information necessary to typeset the font such as each character's width, height and depth.

TeX font metric — main illustration
TeX font metric — illustration

Key takeaways

  • TeX font metric belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect TeX font metric to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of TeX font metric from memory before moving on to harder problems.

Reference excerpt

TeX font metric (TFM) is a font file format used by the TeX typesetting system. It is a font metric format, not an outline font format like TrueType, because it provides only the information necessary to typeset the font such as each character's width, height and depth. The actual glyphs are stored elsewhere. This is not unique to TeX; Adobe's AFM files and Windows' PFM (NTF on modern Windows PostScript driver) files use the same technique. TFM files contain all of the information TeX needs to produce its device-independent (DVI) output. The actual glyphs are then inserted by the eventual DVI output driver or previewer, using, for instance, TrueType fonts, or fonts in the bitmap PK format derived from a METAFONT source. The format is designed to be extremely compact: in the original Computer Modern distribution, every font's TFM file is smaller than 2 kB.

Specification The canonical specification of the TFM format is embedded in the source code of the program TFtoPL. A TFM file is broken down into a series of four-byte words, which can contain data fields of various lengths. Any data fields that are more than one byte long are held in big endian order. (The exact same file will be generated, regardless of architecture of the computer generating it.)

The six-word (24-byte) file header contains twelve unsigned 16-bit integers which describe the length of the file, the range of character codes contained in the font, and the size of each of the tables. A single TFM file describes between 0 and 256 characters, inclusive.

The body of the TFM file consists of a series of ten tables, each one except for the first laid out as an array of fixed-length fields. A 32-bit signed fixed-point number with 12 bits to the left of the decimal point, referred to as a fix_word, is used heavily. The first table, header, contains a checksum designed to prevent a document compiled into a DVI with one set of fonts from being printed with a different set, as well as ASCII descriptions of the character coding scheme (e.g., ASCII or TeX text) and the font family. It also contains the font's design size; all following fix_word values are interpreted as multiplication factors for this.

The next table, char_info, consists of one word per character, and contains indexes into the width, height, depth and italic correction tables. This is a device to save space, because width values, for instance, are frequently duplicated. Because height and depth values are duplicated more frequently, to fit all of these values into a single word, the indexes are limited to four bits. Because of this, there is a limit of sixteen different character heights and sixteen different character depths in any given TFM file. Also, there is a limit of sixty-four different italic corrections. There is also one more index which can point into the lig_kern table, or to information about extensible characters, depending on a two-bit tag value. Extensible characters use a series of repeated characters to construct a single large one of arbitrary size, usually large delimiters such as parentheses or brackets. There then follow the four tables width, height, depth and italic, which contain values (in fix_word format) referred to by indexes in char_info. Ligatures and kerning are represented using a simple programming language consisting of fixed-length four-byte operations in the lig_kern table; it makes use of kerning values (specified as fix_words) in the kern table, which follows it. Extensible characters are specified in the exten table, using a series of four-byte words specifying the top, middle, bottom and repeated sections of an extensible character. For instance, the character at left below would be obtained by setting (top, mid, bot, rep) to the character codes for (/, <, \, |). The first three character codes can be set to zero. For instance, if mid were set to 0 in the previous example, the result would change from the brace drawn at left to the parenthesis drawn to its right.

/ / | | | | < | | | | | \ \

Of course, the font would use specially designed characters for this, instead of reusing existing ones, but the principle is the same. The final table, param, contains a series of specifically defined fix_word values, including the font's x-height and the amount of italic slant (to determine how far to shift accents). Certain coding schemes such as TeX math symbols and TeX math extension define extra parameters which appear after these.

Property lists There is a human-readable equivalent to the TFM format called PL, for property list. There is an exact correspondence between a TFM file and a PL file: one can be freely converted to the other and back again with no loss of information using the tftopl and pltotf programs. The PL format, optimized for usability instead of space, does not make the same use of references that the TFM format does. For instance, many characters in a font may use the same character width, which would be represented only once in the TFM format, and this value would be referenced by each character, since the index would be significantly smaller than the full-precision numerical value. In the PL format, however, the full value is written out each time it appears. For example, this is the code for the upper-case letter Y in Computer Modern Roman, ten point:

The kerning values seen here are copied from another section of the PL file in order to make it easier to read, which in itself is redundant. Notice how the full numeric values of the kerning constants are written out each time they appear, instead of being stored once and referred to by a much smaller index.

Notes

References Fuchs, David (February 1981). "TeX Font Metric files" (PDF). TUGboat. 2 (1): 12–16. Retrieved 2009-08-20.

External links Description of the TFM File Format

Worked examples

Example 1 — a first encounter with TeX font metric

Start with the simplest possible case. Write down what TeX font metric claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to TeX font metric before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about TeX font metric ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of TeX font metric

In research
TeX font metric appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses TeX font metric in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
TeX font metric is common in secondary-school and first-year university syllabi. It links to neighbouring topics Digital typography, Font formats, Typesetting, so understanding it makes those chapters shorter.
In everyday life
Look for TeX font metric outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “TeX font metric” →

How to study TeX font metric in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what TeX font metric means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain TeX font metric out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is TeX font metric in simple terms?

TeX font metric (TFM) is a font file format used by the TeX typesetting system. It is a font metric format, not an outline font format like TrueType, because it provides only the information necessary to typeset the font such as each character's width, height and depth.

Why does TeX font metric matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study TeX font metric?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on TeX font metric.

Tags

  • Digital typography
  • Font formats
  • Typesetting

Keep exploring