DVI libraries
DVI is simple to parse but hard to render: glyphs come from TeX fonts (TFM metrics plus PK or Type 1 outlines) that a library has to locate in a TeX installation. Only a few libraries do it; most programs call dvipdfmx, dvisvgm or dvipng instead.
| Language | Library | Read | Write | Notes |
|---|---|---|---|---|
| Python | Matplotlib dviread | yes | no | pages as lists of glyphs and boxes with positions and fonts; needs TeX fonts |
| Go | star-tex dvi | yes | yes | decode commands, interpret pages with a renderer callback, encode DVI |
Other options:
- C/C++: no maintained standalone library. Viewers (xdvi, Okular, Evince) and converters (dvisvgm, dvipdfmx, dvipng) contain their own DVI readers; dvisvgm is the best code to learn from.
- Rust: the dvi crate parses DVI opcodes into an
Instructionenum, but has had no release since 2020. Tectonic’stectonic_xdvreads XeTeX XDV only, not plain DVI.
By language#
- DVI libraries for Go Open-source Go libraries for DVI files: the star-tex dvi package decodes DVI commands, interprets pages with a renderer and encodes DVI. Code examples.
- DVI libraries for Python Open-source Python libraries for DVI files: Matplotlib's dviread module reads pages, glyph positions, rules and fonts from TeX DVI output. Code examples.