2 import sys
; sys
.path
[:0] = ["../.."]
15 \definecolor{col0}{gray}{0.1}
16 \definecolor{col1}{cmyk}{0.3, 0.2, 0.1, 0.1}
17 \definecolor{col2}{rgb}{0.4, 0.3, 0.1}
18 \definecolor{col3}{RGB}{200, 200, 200}
19 \definecolor{col4}{hsb}{0.1, 0.1, 0.1}
20 \definecolor{col5}{named}{Red}
21 \definecolor{col6}{pyx}{pyx.color.cmyk.PineGreen}
22 \definecolor{col7}{pyx}{color.cmyk(0.92, 0, 0.59, 0.25)}
23 \definecolor{col0}{gray}{0.5}""")
25 c
.stroke(path
.line(-1, 0, 6, 0))
27 c
.stroke(path
.line(6, 5, 6.99, 5), [style
.linewidth
.THIN
])
28 c
.stroke(path
.line(6, 6, 6.99, 6), [style
.linewidth
.THIN
])
29 c
.stroke(path
.line(8.01, 5, 9, 5), [style
.linewidth
.THIN
])
30 c
.stroke(path
.line(8.01, 6, 9, 6), [style
.linewidth
.THIN
])
31 c
.stroke(path
.line(7, 4, 7, 4.99), [style
.linewidth
.THIN
])
32 c
.stroke(path
.line(8, 4, 8, 4.99), [style
.linewidth
.THIN
])
33 c
.stroke(path
.line(7, 6.01, 7, 7), [style
.linewidth
.THIN
])
34 c
.stroke(path
.line(8, 6.01, 8, 7), [style
.linewidth
.THIN
])
35 c
.text(7, 5, "\\vrule width1truecm height1truecm")
37 c
.text(6.2, 0, "0", [text
.vshift
.middlezero
])
38 c
.text(-1.2, 0, "abc", [text
.vshift
.mathaxis
, text
.halign
.right
])
40 t1
= text
.text(0, 0, "a \PyXMarker{beforeb}b\PyXMarker{afterb} 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
.parbox(2, baseline
=text
.parbox
.bottom
)])
44 t2
= c
.insert(text
.text(3, 0, "a \PyXMarker{beforeb}b\PyXMarker{afterb} 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
.parbox(2, baseline
=text
.parbox
.top
)]))
46 c
.stroke(path
.line(*(t1
.marker("beforeb") + t2
.marker("beforeb"))), [color
.rgb
.red
])
47 c
.stroke(path
.line(*(t1
.marker("afterb") + t2
.marker("afterb"))), [color
.rgb
.green
])
49 c
.text(0, 3, r
"\int\limits_{-\infty}^\infty \!{\rm d}x\, e^{-a x^2} = \sqrt{\pi\over a}", [text
.mathmode
])
50 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
])
52 c
.stroke(c
.text(1, 2, r
"Hello, world!").path())
54 # test a virtual font with encoding
55 c
.text(0, 8, r
"\sffamily VF test: \"o\ss ffl \char0
")
56 c.text(0, 9, r"\sffamily
\fontsize{30}{35}\selectfont VF test
: \"o\ss ffl \char0
")
60 t = c.text(0, 11, r"scale test
", [color.rgb.green])
62 t = c.text(0, 11, r"scale test
", [color.rgb.red])
64 # test font stripping (proper usedchar selection)
65 c.text(0, 12, r"usechar
test (``fl
'' should be typed
):")
66 myrunner = text.texrunner(fontmaps="download35
.map")
67 myrunner.preamble(r"\font\pyxfont
=phvr8t\pyxfont
")
68 c.insert(myrunner.text(5.5, 12, r"\char
'035"))
70 myrunner2 = text.texrunner(fontmaps="download35.map")
71 myrunner2.preamble(r"\font\pyxfont=ptmr8t\pyxfont")
72 c.insert(myrunner2.text(6.5, 12, r"\char'035"))
75 c.stroke(c.text(10, 2, r"Hello
, \color{green}world
!", [trafo.slant(1)]).path())
76 c.insert(c.text(10, 0, r"\begin{rotate}{90}\parbox{5cm}
{rotated
\\ in \LaTeX
}\end{rotate}
"))
79 d.stroke(path.rect(0,0, 1,1))
80 d.stroke(path.line(0,0, 1,1))
81 d.stroke(path.line(1,0, 0,1))
82 d.writeEPSfile("eps
/sample
")
83 c.insert(c.text(10, 0, r"""
84 \textcolor{col0}{col0}
85 \textcolor{col1}{col1}
86 \textcolor{col2}{col2}
87 \textcolor{col3}{col3}
88 \textcolor{col4}{col4}
89 \textcolor{col5}{col5}
90 \textcolor{col6}{col6}
91 \textcolor{col7}{col7}%
92 """, [text.parbox(3.5)]))
93 c.insert(c.text(15, 0, r"""
94 \colorbox{col1}{ColorBox}\\
95 \fcolorbox{col5}{col6}{FColorBox}"""))
97 c.text(4, 2, r"{\color
[cmyk
]{0.1,0.2,0.3,0.4}c\color
[gray
]{0.5}o\color
[hsb
]{0.2,0.3,0.4}l\color
[rgb
]{0.2,0.4,0.6}o\color
[RGB
]{100,200,50}r
}s
!")
99 c.writePDFfile("test_text
", paperformat=document.paperformat.A4)
101 c.insert(c.text(10, 4, r"""%
102 \fbox{\includegraphics[%
103 %type=eps, %% type of the file ... should not change anything --
104 % BUG!!!!!! size and filename information gets
105 % wrong when this is used ===> not supported!
106 %command=..., %% not supported!
107 bb = 0 0 25 25, %% bounding box in original size
108 hiresbb=, %! read high resolution in original file (if not bb)
109 %viewport= 0 0 15 15, %% bounding box with respect to bb
110 %trim=1 1 1 1, %% correction of the bounding box with respect to bb
111 width=1in, %! final width
112 height=2in, %! final height
113 %totalheight=3in, %% final height+depth
114 %keepaspectratio=, %! keep aspect ratio, but do not exceed width nor height
115 angle=30, %! wraps around include
116 origin=tr, %% one or two chars of 'lrtcbB' (B for baseline)
117 %scale=2, %! wraps around rotating and include
118 %draft=, %% do not print anything,
119 clip=]% %! directly in dvi
121 c.writeEPSfile("test_text
", paperformat=document.paperformat.A4)