A library to read and process DVI (DeVice Independent) files, the native output of TeX. The source code provides also a PNG converter and a viewer featuring an hardware acceleration based on the OpenGL API.
Project description
PyDvi
The official PyDvi Home Page is located at http://fabricesalvaire.github.io/PyDVI
The latest documentation build from the git repository is available at readthedocs.org
Written by Fabrice Salvaire.
Introduction
PyDvi is a Python library to read and process DVI (DeVice Independent) files, the native output of the famous TeX typesetting program implemented by Donald E. Knuth.
PyDvi is also able to read most of the file formats associated to the TeX world like packed font, virtual font, TeX font metric, font map and font encoding. It can also read Adobe Font Metrics files.
Basically a DVI file describes the layout of a page by a list of opcodes that interact with a register machine to update the position on the page, to load fonts and to paint glyphs and rules. In short it contains the glyphs and their positions on the page. Since TeX was designed to layout the series of books The Art of Computer Programming at the beginning of the eighties, it focuses on texts and mathematical expressions. Thus DVI is much simpler than Postscript or its successor PDF which are designed for graphics. However we can extend the capabilities of DVI using the special opcode which can contain any text like Postscript snippets.
A DVI stream can come from a file or a TeX daemon in order to render TeX inputs on-the-fly.
The DVI parser of PyDvi builds a program from a DVI stream that could be later processed by the provided DVI machine which is designed to be subclassed by the user.
The source code includes an experimental DVI viewer as exemple which uses the OpenGL API for the rendering and thus feature an hardware accelerated rendering. PyDvi and the viewer can be used as a platform to experiment complex text rendering on GPU.
The source code includes also a clone of the dvipng tool to render DVI to PNG image. This tool is mainly intended to check the compliance of PyDvi by image comparison.
PyDvi can be used for several purpose, we will review them in the followings:
TeX is a major and historical typesetting program. PyDvi can serve to read and process its output using Python. The user can be a curious pearson who want to lean TeX or somebody interested by TeX postprocessing.
TeX is one of the oldest computer program still in activity. The reason is quite simple, these algorithms do the right job, its ecosystem is rich and its code is not so simple. Thus nobody succeeds to reimplement it up to now, excepted its mathematical layout algorithms by the MathJax Javascript library which is intended to bring Mathematical layout to web browser. Before the delivery of Mathjax, the only solution to render properly mathematical content was to generate an image using a program like dvipng. It is what does the engine of Wikipedia behind the scene. Usually these programs like Asymptote or Circuit_macros generate the graphics as a PDF document and then include this document in a LaTeX document which contains the labels placed at absolute positions in the page. With PyDvi we can try another approach which consists to send TeX content to a daemon and get back the glyphs and their positions. Matplotlib uses this approach to render LaTeX labels.
Installation
The installation of PyDvi by itself is quite simple. However it will be easier to get the dependencies on a Linux desktop.
Dependencies
PyDvi requires the following dependencies:
freetype-py for Type1 font rendering
The OpenGL DVI viewer requires these additional dependencies:
The DVI to PNG tool requires these additional dependencies:
Also it is recommanded to have these Python modules:
pip
virtualenv
For development, you will need in addition:
Installation from PyPi Repository
PyDvi is made available on the PyPI repository at https://pypi.python.org/pypi/PyDVI
Run this command to install the last release:
pip install PyDvi
Installation from Source
The PyDvi source code is hosted at https://github.com/FabriceSalvaire/PyDVI
To clone the Git repository, run this command in a terminal:
git clone git@github.com:FabriceSalvaire/PyDvi.git
Then to build and install PyDvi run these commands:
python setup.py build
python setup.py install
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file PyDvi-0.1.0.tar.gz
.
File metadata
- Download URL: PyDvi-0.1.0.tar.gz
- Upload date:
- Size: 1.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29db3b348bbb0e929641a758bfb2afa197e698705edf34f02a1e7b5fc7b8db52 |
|
MD5 | b15e26419409f3b161db3f67f485fa62 |
|
BLAKE2b-256 | 978c501abbb16c50bf5420a166b8c64fbe5f75bca2726d1bbe5dd48e971cc38a |