Module dvi::transforms

source ·
Expand description

Transforms on DVI data.

The DVI format can represent the same document in multiple different ways. For example this list of operations:

vec![
    dvi::Op::SetVar(dvi::Var::X, 3),
    dvi::Op::Move(dvi::Var::X),
    dvi::Op::TypesetChar{char: 'D' as u32, move_h: false},
];

describes the same document as this list of operations:

vec![
    dvi::Op::Right(6),
    dvi::Op::TypesetChar{char: 'D' as u32, move_h: false},
];

In both cases, the result of the DVI operations is a document with the single character D typeset at the coordinate (6,0).

This module contains transforms that change the DVI representation of documents without changing the actual meaning of the document. You can think of transforms as being like optimization passes in an optimizing compiler: the output program behaves the same, but its code is different.

There are at least two reasons why one would want to perform a DVI transform:

  1. To optimize the DVI in some way; for example, to reduce the size of the DVI file. Knuth performs an optmization of this type in TeX.2021.604-615.

  2. To normalize the DVI file so that a DVI produced by one program will match the DVI produced by another program.

Structs§