box module: changed to relative box aligment; further integration of text into canvas...
[PyX/mjg.git] / test / functional / test_text.py
blob8091eb2bc694a7bda11b378dd2da368b8f456c03
1 #!/usr/bin/env python
2 import sys; sys.path[:0] = ["../.."]
4 from pyx import *
5 from pyx import text
7 c = canvas.canvas()
8 text.set(mode="latex", dvidebug=1)
10 c.stroke(path.line(-1, 0, 6, 0))
12 c.stroke(path.line(6, 5, 6.99, 5), canvas.linewidth.THIN)
13 c.stroke(path.line(6, 6, 6.99, 6), canvas.linewidth.THIN)
14 c.stroke(path.line(8.01, 5, 9, 5), canvas.linewidth.THIN)
15 c.stroke(path.line(8.01, 6, 9, 6), canvas.linewidth.THIN)
16 c.stroke(path.line(7, 4, 7, 4.99), canvas.linewidth.THIN)
17 c.stroke(path.line(8, 4, 8, 4.99), canvas.linewidth.THIN)
18 c.stroke(path.line(7, 6.01, 7, 7), canvas.linewidth.THIN)
19 c.stroke(path.line(8, 6.01, 8, 7), canvas.linewidth.THIN)
20 c.text(7, 5, "\\vrule width1truecm height1truecm")
22 c.text(6.2, 0, "0", text.valign.centerline())
23 c.text(-1.2, 0, "abc", text.valign.centerline(), text.halign.right)
25 t1 = text.text(0, 0, "a b c d e f g h i j k l m n o p q r s t u v w x y z", text.valign.bottomline("2 cm"))
26 c.insert(t1)
27 c.stroke(t1.path())
29 t2 = c.insert(text.text(3, 0, "a b c d e f g h i j k l m n o p q r s t u v w x y z", text.valign.topline("2 cm")))
30 c.stroke(t2.path())
32 c.text(0, 3, r"\int\limits_{-\infty}^\infty \!{\rm d}x\, e^{-a x^2} = \sqrt{\pi\over a}", text.mathmode)
33 c.text(0, 6, r"\int\limits_{-\infty}^\infty \!{\rm d}x\, e^{-a x^2} = \sqrt{\pi\over a}", text.mathmode, text.size.LARGE)
34 # c.text(0, 6, r"\int\limits_{-\infty}^\infty \!{\rm d}x\, e^{-a x^2} = \sqrt{\pi\over a}", text.size.LARGE, text.mathmode)
36 c.stroke(c.text(1, 2, r"Hello, world!").path())
37 c.stroke(c.text(1, 2, r"Hello, world!", trafo.slant(1)).path())
39 c.writetofile("test_text", paperformat="a4")