1 import sys
; sys
.path
[:0] = ["../.."]
6 text
.set(mode
="tex", texdebug
="debug.tex", usefiles
=["debug.dvi", "debug.log"])
9 return " ".join(["".join([random
.choice(string
.lowercase
)
10 for j
in range(random
.randint(1, 3))])
11 for i
in range(random
.randint(100, 300))])
13 def randparwithdisplay():
14 #par = "" # TODO allow for formulas at the beginning -- to be checked
16 for i
in range(random
.randint(0, 3)):
17 par
+= r
"\display{}xxx\enddisplay{}"
18 for j
in range(random
.randint(0, 1)):
20 #return par # TODO allow for formulas at the end -- to be checked
21 return par
+ randpar()
24 return r
"\par{}".join([randparwithdisplay() for i
in range(random
.randint(1, 10))])
26 def output(boxes
, shapes
):
30 for i
in range(len(boxes
)):
33 c
.stroke(path
.rect(0, y
, shape
[0], -shape
[1]))
34 c
.stroke(boxes
[i
].bbox().path(), [trafo
.translate(0, y
), color
.rgb
.red
])
35 c
.insert(boxes
[i
], [trafo
.translate(0, y
)])
36 for mark
in boxes
[i
].markers
.keys():
37 mx
, my
= boxes
[i
].markers
[mark
]
38 c
.insert(tr
.text(mx
,my
+y
, mark
+"~", [text
.size
.tiny
, text
.halign
.right
]))
39 if mark
[:5] == "start":
40 c
.fill(path
.circle(mx
, my
+y
, 0.05), [color
.rgb
.red
])
41 elif mark
[:3] == "end":
42 c
.fill(path
.circle(mx
, my
+y
, 0.05), [color
.rgb
.green
])
44 raise "other marks in there!"
46 c
.writeEPSfile("textboxes")
49 shapes
= [(10,7), (8,5)]*50
52 while only
is None or n
<= only
:
57 thistextfile
= open("debug.thistext", "w")
58 thistextfile
.write(thistext
)
61 thistextfile
= open("debug.thistext", "r")
62 thistext
= thistextfile
.read()
64 if only
is not None and n
<= only
:
66 boxes
= text
.defaulttexrunner
.textboxes(thistext
, shapes
)
68 for i
in range(len(boxes
)):
71 if abs(unit
.topt(boxes
[i
].bbox().right()) - unit
.topt(shape
[0])) > 1:
72 print ("right boundary differs:",
73 unit
.topt(boxes
[i
].bbox().bottom()), -unit
.topt(shape
[1]),
74 unit
.topt(boxes
[i
].bbox().right()), unit
.topt(shape
[0]),