text documentation (in progress)
[PyX/mjg.git] / examples / valign.py
blobe2c7db32c5d87b78835d7f79d9dbc7669efdf519
1 from pyx import *
3 c = canvas.canvas()
5 # apply global TeX setting
6 text.preamble(r"\parindent=0pt")
8 # vertical alignments by margins
9 c.stroke(path.line(0, 4, 6, 4), canvas.linewidth.THin)
10 c.text(0, 4, r"spam \& eggs", text.vbox(1.2), text.valign.top)
11 c.text(2, 4, r"spam \& eggs", text.vbox(1.2), text.valign.middle)
12 c.text(4, 4, r"spam \& eggs", text.vbox(1.2), text.valign.bottom)
14 # vertical alignments by baselines
15 c.stroke(path.line(0, 2, 6, 2), canvas.linewidth.THin)
16 c.text(0, 2, r"spam \& eggs", text.vbox(1.2), text.valign.topbaseline)
17 c.text(2, 2, r"spam \& eggs", text.vbox(1.2), text.valign.middlebaseline)
18 c.text(4, 2, r"spam \& eggs", text.vbox(1.2), text.valign.bottombaseline)
20 # vertical shifts
21 c.stroke(path.line(0, 0, 8, 0), canvas.linewidth.THin)
22 c.text(0, 0, r"x=0", text.mathmode, text.vshift.topzero)
23 c.text(2, 0, r"x=0", text.mathmode, text.vshift.middlezero)
24 c.text(4, 0, r"x=0", text.mathmode, text.vshift.bottomzero)
25 c.text(6, 0, r"x=0", text.mathmode, text.vshift.mathaxis)
27 c.writetofile("valign")