4 releases

0.2.2 May 18, 2020
0.2.1 May 18, 2020
0.2.0 May 18, 2020
0.1.0 Jul 23, 2017

#1953 in Parser implementations


Used in 2 crates

MIT/Apache

49KB
948 lines

dvi-rs

A parser for the "device independent file" (dvi) format in rust

TODO

  • At the moment, the "parse" function actually lexes. Could parse into a list of pages and fonts.
  • Documentation/examples, currently best examples are the tests

lib.rs:

Dvi format

The dvi format is an ancient format to abstract differences between different printing environments. A program would be provided with the printer hardware to convert dvi into instructions for the print head, which would then produce the desired content on the printed page. This means that a dvi document is essentially a set of instructions for which glyphs to draw where on each page.

It has largely been superseeded, with postscript (ps) and then protable document format (pdf) becoming the dominant document format.

However, it is quite a simple protocol, and it may be useful for working with documents in this format, hence the motivation for writing a library.

A dvi file is a sequence of Instructions. See the Instruction enum for details of the different instructions contained.

Note that currently paths must be utf8, and parsing will error if this is not true

Implementation notes

An instruction is a u8, followed by 0 or more instruction-specific parameters All multi-byte values are big-endian. All values are unsigned, except for 4-byte which is always i32, and distance values, which are signed. Signed values use 2s-complement (same as rust).

See SPECIFICATION.md for more details

Dependencies

~1MB
~19K SLoC