doing tex support the right way

I would like to ask for some advice from those out there who have experience
dealing with fonts and text layout.

At the end of this message is the output of dvitype, which translates a dvi
file (in this case a file typesetting "0.8" in ptmr7t fonts) into human
readable output. I have considered writing a dvi parser for mpl, intending to
extract the information necessary to render text with mpl's existing font and
text support. There is some more information at
http://en.wikipedia.org/wiki/DVI_(TeX) and
http://www.math.umd.edu/~asnowden/comp-cont/dvi.html#setchar.

Is this worth pursuing? If I could make it work, mpl's only external
dependency would be TeX/LaTeX, even dvipng would not be required.

Thanks,
Darren
(I'm sorry to beat this issue into the ground)

$ dvitype 8b85d26da2410f54cd2d70976999b1d8.dvi
This is DVItype, Version 3.6 (Web2C 7.5.5)
Options selected:
  Starting page = *
  Maximum number of pages = 1000000
  Output level = 4 (the works)
  Resolution = 300.00000000 pixels per inch
numerator/denominator=25400000/473628672
magnification=1000; 0.00006334 pixels per DVI unit
' TeX output 2006.01.21:1639'
Postamble starts at byte 144.
maxv=41484288, maxh=26673152, maxstackdepth=3, totalpages=1
Font 14: ptmr7t---loaded at size 655360 DVI units

42: beginning of page 1
87: down4 41484288 v:=0+41484288=41484288, vv:=2628
92: push
level 0:(h=0,v=41484288,w=0,x=0,y=0,z=0,hh=0,vv=2628)
93: down4 -39649280 v:=41484288-39649280=1835008, vv:=116
98: down4 37683200 v:=1835008+37683200=39518208, vv:=2503
103: push
level 1:(h=0,v=39518208,w=0,x=0,y=0,z=0,hh=0,vv=2503)
104: down4 -35389440 v:=39518208-35389440=4128768, vv:=262
109: push
level 2:(h=0,v=4128768,w=0,x=0,y=0,z=0,hh=0,vv=262)
110: right3 5046272 h:=0+5046272=5046272, hh:=320
[ ]
114: fntdef1 14: ptmr7t
136: fntnum14 current font is ptmr7t
137: setchar48 h:=5046272+327680=5373952, hh:=341
138: setchar46 h:=5373952+163840=5537792, hh:=351
139: setchar56 h:=5537792+327680=5865472, hh:=372
[0.8]
140: pop
level 2:(h=0,v=4128768,w=0,x=0,y=0,z=0,hh=0,vv=262)
141: pop
level 1:(h=0,v=39518208,w=0,x=0,y=0,z=0,hh=0,vv=2503)
142: pop
level 0:(h=0,v=41484288,w=0,x=0,y=0,z=0,hh=0,vv=2628)
143: eop

Darren Dale wrote:

I would like to ask for some advice from those out there who have experience
dealing with fonts and text layout.

At the end of this message is the output of dvitype, which translates a dvi
file (in this case a file typesetting "0.8" in ptmr7t fonts) into human
readable output. I have considered writing a dvi parser for mpl, intending to
extract the information necessary to render text with mpl's existing font and
text support. There is some more information at
Device independent file format - Wikipedia and
http://www.math.umd.edu/~asnowden/comp-cont/dvi.html#setchar.

Is this worth pursuing? If I could make it work, mpl's only external
dependency would be TeX/LaTeX, even dvipng would not be required.

Quite probably. dvitype is new to me. Doing a DVI interpreter for mpl and Chaco
has been on my list of things to look at for some time. The things stopping me
(besides the density of the DVI standard) was that all of the readable code I
found for interpreting DVI files has been GPLed.

You will need to access the parameters defined in the TeX Font Metric files, I
think. I recommend using tftopl(1) to convert them to a parseable form.

···

--
Robert Kern
robert.kern@...149...

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
  -- Richard Harter

How does matplotlib render glyphs, does it use freetype? Would matplotlib be
able to render tex's fonts with the existing codebase, or would I have to
delve into metafont?

···

On Monday 23 January 2006 18:27, Robert Kern wrote:

Darren Dale wrote:
> I would like to ask for some advice from those out there who have
> experience dealing with fonts and text layout.
>
> At the end of this message is the output of dvitype, which translates a
> dvi file (in this case a file typesetting "0.8" in ptmr7t fonts) into
> human readable output. I have considered writing a dvi parser for mpl,
> intending to extract the information necessary to render text with mpl's
> existing font and text support. There is some more information at
> Device independent file format - Wikipedia and
> http://www.math.umd.edu/~asnowden/comp-cont/dvi.html#setchar.
>
> Is this worth pursuing? If I could make it work, mpl's only external
> dependency would be TeX/LaTeX, even dvipng would not be required.

Quite probably. dvitype is new to me. Doing a DVI interpreter for mpl and
Chaco has been on my list of things to look at for some time. The things
stopping me (besides the density of the DVI standard) was that all of the
readable code I found for interpreting DVI files has been GPLed.

You will need to access the parameters defined in the TeX Font Metric
files, I think. I recommend using tftopl(1) to convert them to a parseable
form.

This weekend I took the first small step towards improving usetex and
eliminating the need for PSFrag and dependencies like ghostscript. This is
necessary in order to provide usetex support accross backends (like pdf and
svg). The basic approach is to extract the font layout information from the
dvi files. LaTeX could be the only dependency.

Wikipedia has an article about the dvi specification:
http://en.wikipedia.org/wiki/DVI_file_format, which has a link to a really
useful file called dvitype.web. This file contains the full dvi specification
and can be converted into a plain tex file using weave:
http://www.ctan.org/tex-archive/systems/knuth/texware/dvitype.web

dvitype.web also contains a well documented pascal program illustrating how to
read dvi files correctly and convert them into symbolic form. It was meant as
a guide to programmers developing dvi-related software. It includes a section
on extracting the necessary information from tfm files, and other issues
related to fonts.

I also discovered that xdvi is OSS compliant, and have started studying that
source code as well. I only started writing code to read the dvi information,
but I post here to allow people to comment if they are so inclined, and to
share the dvitype example with anyone who is interested. I have compiled the
tex file, converted it to pdf, and posted the result at
http://staff.chess.cornell.edu/~dale/matplotlib/dvitype.pdf.

Darren

Thanks for doing this Darren. Keep up the good work!

···

On 4/24/06, Darren Dale <dd55@...143...> wrote:

This weekend I took the first small step towards improving usetex and
eliminating the need for PSFrag and dependencies like ghostscript. This is
necessary in order to provide usetex support accross backends (like pdf and
svg). The basic approach is to extract the font layout information from the
dvi files. LaTeX could be the only dependency.

Wikipedia has an article about the dvi specification:
http://en.wikipedia.org/wiki/DVI_file_format, which has a link to a really
useful file called dvitype.web. This file contains the full dvi specification
and can be converted into a plain tex file using weave:
http://www.ctan.org/tex-archive/systems/knuth/texware/dvitype.web

dvitype.web also contains a well documented pascal program illustrating how to
read dvi files correctly and convert them into symbolic form. It was meant as
a guide to programmers developing dvi-related software. It includes a section
on extracting the necessary information from tfm files, and other issues
related to fonts.

I also discovered that xdvi is OSS compliant, and have started studying that
source code as well. I only started writing code to read the dvi information,
but I post here to allow people to comment if they are so inclined, and to
share the dvitype example with anyone who is interested. I have compiled the
tex file, converted it to pdf, and posted the result at
http://staff.chess.cornell.edu/~dale/matplotlib/dvitype.pdf.

Darren

-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel