1 import sys
; sys
.path
[:0] = ["../.."]
6 text
.set(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
):
29 for i
in range(len(boxes
)):
32 c
.stroke(path
.rect(0, y
, shape
[0], -shape
[1]))
33 c
.stroke(boxes
[i
].bbox().path(), [trafo
.translate(0, y
), color
.rgb
.red
])
34 c
.insert(boxes
[i
], [trafo
.translate(0, y
)])
35 for mark
in boxes
[i
].markers
.keys():
36 mx
, my
= boxes
[i
].markers
[mark
]
37 if mark
[:5] == "start":
38 c
.fill(path
.circle(mx
, my
+y
, 0.05), [color
.rgb
.red
])
39 elif mark
[:3] == "end":
40 c
.fill(path
.circle(mx
, my
+y
, 0.05), [color
.rgb
.green
])
42 raise "other marks in there!"
44 c
.writeEPSfile("textboxes")
47 shapes
= [(10,7), (8,5)]*50
50 while only
is None or n
<= only
:
54 if only
is not None and n
<= only
:
56 boxes
= text
.defaulttexrunner
.textboxes(thistext
, shapes
)
57 #output(boxes, shapes)
58 for i
in range(len(boxes
)):
61 if abs(unit
.topt(boxes
[i
].bbox().right()) - unit
.topt(shape
[0])) > 1:
62 print ("right boundary differs:",
63 unit
.topt(boxes
[i
].bbox().bottom()), -unit
.topt(shape
[1]),
64 unit
.topt(boxes
[i
].bbox().right()), unit
.topt(shape
[0]),