rename texmessage.loadfd to texmessage.loaddef and allow for .def and .fd files
[PyX/mjg.git] / examples / text / valign.py
blobb386f45a0dbb889528a12b459b8738372ed1c580
1 from pyx import *
3 c = canvas.canvas()
4 c.set([style.linestyle.dotted])
6 # apply global TeX setting
7 text.preamble(r"\parindent=0pt")
8 w = 1.2 # an appropriate parbox width for spam & eggs
10 # vertical alignments by margins
11 c.stroke(path.line(0, 4, 8, 4), [style.linewidth.THin])
12 c.text(0, 4, r"spam \& eggs", [text.parbox(w), text.valign.top])
13 c.text(3, 4, r"spam \& eggs", [text.parbox(w), text.valign.middle])
14 c.text(6, 4, r"spam \& eggs", [text.parbox(w), text.valign.bottom])
16 # vertical alignments by baselines
17 c.stroke(path.line(0, 2, 8, 2), [style.linewidth.THin])
18 c.text(0, 2, r"spam \& eggs", [text.parbox(w, baseline=text.parbox.top)])
19 c.text(3, 2, r"spam \& eggs", [text.parbox(w, baseline=text.parbox.middle)])
20 c.text(6, 2, r"spam \& eggs", [text.parbox(w, baseline=text.parbox.bottom)])
22 # vertical shifts
23 c.stroke(path.line(0, 0, 8, 0), [style.linewidth.THin])
24 c.text(0, 0, r"x=0", [text.mathmode, text.vshift.topzero])
25 c.text(2, 0, r"x=0", [text.mathmode, text.vshift.middlezero])
26 c.text(4, 0, r"x=0", [text.mathmode, text.vshift.bottomzero])
27 c.text(6, 0, r"x=0", [text.mathmode, text.vshift.mathaxis])
29 c.writeEPSfile("valign")
30 c.writePDFfile("valign")