Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fabricesalvaire/pydvi
PyDvi is a Python library to read and process DVI (DeVice Independent) files, the native output of LaTeX. The library provides a DVI machine as a base class which can be extended by the user and plugged to a TeX daemon in order to render contents on-the-fly. Also the source code provides a DVI viewer featuring an hardware accelerated rendering on GPU.
https://github.com/fabricesalvaire/pydvi
dvi latex python python-library tex
Last synced: 9 days ago
JSON representation
PyDvi is a Python library to read and process DVI (DeVice Independent) files, the native output of LaTeX. The library provides a DVI machine as a base class which can be extended by the user and plugged to a TeX daemon in order to render contents on-the-fly. Also the source code provides a DVI viewer featuring an hardware accelerated rendering on GPU.
- Host: GitHub
- URL: https://github.com/fabricesalvaire/pydvi
- Owner: FabriceSalvaire
- License: gpl-3.0
- Created: 2013-05-01T20:02:24.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-09-22T19:23:09.000Z (about 10 years ago)
- Last Synced: 2024-10-18T15:54:09.275Z (19 days ago)
- Topics: dvi, latex, python, python-library, tex
- Language: Python
- Homepage:
- Size: 4.26 MB
- Stars: 15
- Watchers: 2
- Forks: 2
- Open Issues: 13
-
Metadata Files:
- Readme: README.html
- License: LICENSE.txt
Awesome Lists containing this project
README
/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 7614 2013-02-21 15:55:51Z milde $
:Copyright: This stylesheet has been placed in the public domain.Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*//* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }.last, .with-subtitle {
margin-bottom: 0 ! important }.hidden {
display: none }a.toc-backref {
text-decoration: none ;
color: black }blockquote.epigraph {
margin: 2em 5em ; }dl.docutils dd {
margin-bottom: 0.5em }object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/div.abstract {
margin: 2em 5em }div.abstract p.topic-title {
font-weight: bold ;
text-align: center }div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }div.figure {
margin-left: 2em ;
margin-right: 2em }div.footer, div.header {
clear: both;
font-size: smaller }div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }div.system-messages {
margin: 5em }div.system-messages h1 {
color: red }div.system-message {
border: medium outset ;
padding: 1em }div.system-message p.system-message-title {
color: red ;
font-weight: bold }div.topic {
margin: 2em }h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }h1.title {
text-align: center }h2.subtitle {
text-align: center }hr.docutils {
width: 75% }img.align-left, .figure.align-left, object.align-left {
clear: left ;
float: left ;
margin-right: 1em }img.align-right, .figure.align-right, object.align-right {
clear: right ;
float: right ;
margin-left: 1em }img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}.align-left {
text-align: left }.align-center {
clear: both ;
text-align: center }.align-right {
text-align: right }/* reset inner alignment in figures */
div.align-right {
text-align: inherit }/* div.align-center * { */
/* text-align: left } */ol.simple, ul.simple {
margin-bottom: 1em }ol.arabic {
list-style: decimal }ol.loweralpha {
list-style: lower-alpha }ol.upperalpha {
list-style: upper-alpha }ol.lowerroman {
list-style: lower-roman }ol.upperroman {
list-style: upper-roman }p.attribution {
text-align: right ;
margin-left: 50% }p.caption {
font-style: italic }p.credits {
font-style: italic ;
font-size: smaller }p.label {
white-space: nowrap }p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }p.topic-title {
font-weight: bold }pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}span.classifier {
font-family: sans-serif ;
font-style: oblique }span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }span.interpreted {
font-family: sans-serif }span.option {
white-space: nowrap }span.pre {
white-space: pre }span.problematic {
color: red }span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }table.citation {
border-left: solid 1px gray;
margin-left: 1px }table.docinfo {
margin: 2em 4em }table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }table.footnote {
border-left: solid 1px black;
margin-left: 1px }table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }ul.auto-toc {
list-style-type: none }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:
- Python
- Numpy
freetype-py for Type1 font renderingThe 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 PyDviInstallation 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 [email protected]:FabriceSalvaire/PyDvi.gitThen to build and install PyDvi run these commands:
python setup.py build
python setup.py install