@header@
 
 
matplotlib.dviread
index
/home/jdhunter/dev/lib64/python2.5/site-packages/matplotlib/dviread.py

An experimental module for reading dvi files output by TeX. Several
limitations make this not (currently) useful as a general-purpose dvi
preprocessor.
 
Interface::
 
  dvi = Dvi(filename, 72)
  for page in dvi:          # iterate over pages
      w, h, d = page.width, page.height, page.descent
      for x,y,font,glyph,width in page.text:
          fontname = font.texname
          pointsize = font.size
          ...
      for x,y,height,width in page.boxes:
          ...

 
Modules
       
matplotlib
matplotlib.cbook
numpy
os
struct

 
Classes
       
__builtin__.object
Dvi
Vf
DviFont
Encoding
PsfontsMap
Tfm

 
class Dvi(__builtin__.object)
    A dvi ("device-independent") file, as produced by TeX.
The current implementation only reads the first page and does not
even attempt to verify the postamble.
 
  Methods defined here:
__init__(self, filename, dpi)
Initialize the object. This takes the filename as input and
opens the file; actually reading the file happens when
iterating through the pages of the file.
__iter__(self)
Iterate through the pages of the file.
 
Returns (text, pages) pairs, where:
  text is a list of (x, y, fontnum, glyphnum, width) tuples
  boxes is a list of (x, y, height, width) tuples
 
The coordinates are transformed into a standard Cartesian
coordinate system at the dpi value given when initializing.
The coordinates are floating point numbers, but otherwise
precision is not lost and coordinate values are not clipped to
integers.
close(self)
Close the underlying file if it is open.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class DviFont(__builtin__.object)
    Object that holds a font's texname and size, supports comparison,
and knows the widths of glyphs in the same units as the AFM file.
There are also internal attributes (for use by dviread.py) that
are _not_ used for comparison.
 
The size is in Adobe points (converted from TeX points).
 
  Methods defined here:
__eq__(self, other)
__init__(self, scale, tfm, texname, vf)
__ne__(self, other)

Data descriptors defined here:
size
texname
widths

 
class Encoding(__builtin__.object)
    Parses a \*.enc file referenced from a psfonts.map style file.
The format this class understands is a very limited subset of
PostScript.
 
Usage (subject to change)::
 
  for name in Encoding(filename):
      whatever(name)
 
  Methods defined here:
__init__(self, filename)
__iter__(self)

Data descriptors defined here:
encoding

 
class PsfontsMap(__builtin__.object)
    A psfonts.map formatted file, mapping TeX fonts to PS fonts.
Usage: map = PsfontsMap('.../psfonts.map'); map['cmr10']
 
For historical reasons, TeX knows many Type-1 fonts by different
names than the outside world. (For one thing, the names have to
fit in eight characters.) Also, TeX's native fonts are not Type-1
but Metafont, which is nontrivial to convert to PostScript except
as a bitmap. While high-quality conversions to Type-1 format exist
and are shipped with modern TeX distributions, we need to know
which Type-1 fonts are the counterparts of which native fonts. For
these reasons a mapping is needed from internal font names to font
file names.
 
A texmf tree typically includes mapping files called e.g.
psfonts.map, pdftex.map,  dvipdfm.map. psfonts.map is used by
dvips, pdftex.map by pdfTeX, and dvipdfm.map by dvipdfm.
psfonts.map might avoid embedding the 35 PostScript fonts, while
the pdf-related files perhaps only avoid the "Base 14" pdf fonts.
But the user may have configured these files differently.
 
  Methods defined here:
__getitem__(self, texname)
__init__(self, filename)

 
class Tfm(__builtin__.object)
    A TeX Font Metric file. This implementation covers only the bare
minimum needed by the Dvi class.
 
Attributes:
 
  checksum: for verifying against dvi file
 
  design_size: design size of the font (in what units?)
 
  width[i]: width of character \#i, needs to be scaled
    by the factor specified in the dvi file
    (this is a dict because indexing may not start from 0)
 
  height[i], depth[i]: height and depth of character \#i
 
  Methods defined here:
__init__(self, filename)

Data descriptors defined here:
checksum
depth
design_size
height
width

 
class Vf(Dvi)
    A virtual font (\*.vf file) containing subroutines for dvi files.
 
Usage::
 
  vf = Vf(filename)
  glyph = vf[code]
  glyph.text, glyph.boxes, glyph.width
 
 
Method resolution order:
Vf
Dvi
__builtin__.object

Methods defined here:
__getitem__(self, code)
__init__(self, filename)

Methods inherited from Dvi:
__iter__(self)
Iterate through the pages of the file.
 
Returns (text, pages) pairs, where:
  text is a list of (x, y, fontnum, glyphnum, width) tuples
  boxes is a list of (x, y, height, width) tuples
 
The coordinates are transformed into a standard Cartesian
coordinate system at the dpi value given when initializing.
The coordinates are floating point numbers, but otherwise
precision is not lost and coordinate values are not clipped to
integers.
close(self)
Close the underlying file if it is open.

Data descriptors inherited from Dvi:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
find_tex_file(filename, format=None)
Call kpsewhich to find a file in the texmf tree.
If format is not None, it is used as the value for the --format option.
See the kpathsea documentation for more information.
 
Apparently most existing TeX distributions on Unix-like systems
use kpathsea. I hear MikTeX (a popular distribution on Windows)
doesn't use kpathsea, so what do we do? (TODO)
@footer@