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\char0
")
56 c.text(0, 9, r"\sffamily
\fontsize{30}{35}\selectfont VF test
: \"o\ss ffl \char0\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 from pyx.dvi import mapfile
66 fontmap = mapfile.readfontmap(["download35
.map"])
67 c.text(0, 12, r"usechar
test (``fl
'' should be typed
):")
68 myrunner = text.texrunner()
69 myrunner.preamble(r"\font\pyxfont
=phvr8t\pyxfont
")
70 c.insert(myrunner.text(5.5, 12, r"\char
'035", fontmap=fontmap))
72 myrunner2 = text.texrunner()
73 myrunner2.preamble(r"\font\pyxfont=ptmr8t\pyxfont")
74 c.insert(myrunner2.text(6.5, 12, r"\char'035", fontmap=fontmap))
76 # test for ligatures/kerning in virtual fonts
77 c.text(0, 13, r"usechar
test (``affa
'' should be typed
):")
78 myrunner = text.texrunner()
79 myrunner.preamble(r"\font\pyxfont
=ptmr7t\pyxfont
")
80 c.insert(myrunner.text(6.0, 13, r"affa
", fontmap=fontmap))
83 c.stroke(c.text(10, 2, r"Hello
, \color{green}world
!", [trafo.slant(1)]).path())
84 c.insert(c.text(10, 0, r"\begin{rotate}{90}\parbox{5cm}
{rotated
\\ in \LaTeX
}\end{rotate}
"))
87 d.stroke(path.rect(0,0, 1,1))
88 d.stroke(path.line(0,0, 1,1))
89 d.stroke(path.line(1,0, 0,1))
90 d.writeEPSfile("eps
/sample
")
91 c.insert(c.text(10, 0, r"""
92 \textcolor{col0}{col0}
93 \textcolor{col1}{col1}
94 \textcolor{col2}{col2}
95 \textcolor{col3}{col3}
96 \textcolor{col4}{col4}
97 \textcolor{col5}{col5}
98 \textcolor{col6}{col6}
99 \textcolor{col7}{col7}%
100 """, [text.parbox(3.5)]))
101 c.insert(c.text(15, 0, r"""
102 \colorbox{col1}{ColorBox}\\
103 \fcolorbox{col5}{col6}{FColorBox}"""))
105 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
!")
108 sc = canvas.canvas(attrs=[trafo.mirror()])
109 p = path.path(path.moveto(-2, 0), path.curveto(-1, 0, -1, 1, 0, 1), path.curveto(1, 1, 1, 0, 2, 0))
110 sc.stroke(p, [deco.curvedtext("\PyX
{} is fun
!", textattrs=[trafo.mirror(), trafo.scale(0.5)]),
111 deco.curvedtext("left
", textattrs=[text.halign.left, text.vshift.mathaxis, trafo.mirror(), color.rgb.red], arclenfrombegin=0.5, exclude=0.1),
112 deco.curvedtext("r
{\color
[rgb
]{1,0,0}igh
}t
", textattrs=[text.halign.right, text.vshift.mathaxis, trafo.mirror(), trafo.scale(1.2)], arclenfromend=0.5, exclude=0.1)])
113 c.insert(sc, [trafo.translate(12, 12)])
115 c.writePDFfile("test_text
", page_paperformat=document.paperformat.A4)
116 c.writeSVGfile("test_text
", page_paperformat=document.paperformat.A4)
118 c.insert(c.text(10, 4, r"""%
119 \fbox{\includegraphics[%
120 %type=eps, %% type of the file ... should not change anything --
121 % BUG!!!!!! size and filename information gets
122 % wrong when this is used ===> not supported!
123 %command=..., %% not supported!
124 bb = 0 0 25 25, %% bounding box in original size
125 hiresbb=, %! read high resolution in original file (if not bb)
126 %viewport= 0 0 15 15, %% bounding box with respect to bb
127 %trim=1 1 1 1, %% correction of the bounding box with respect to bb
128 width=1in, %! final width
129 height=2in, %! final height
130 %totalheight=3in, %% final height+depth
131 %keepaspectratio=, %! keep aspect ratio, but do not exceed width nor height
132 angle=30, %! wraps around include
133 origin=tr, %% one or two chars of 'lrtcbB' (B for baseline)
134 %scale=2, %! wraps around rotating and include
135 %draft=, %% do not print anything,
136 clip=]% %! directly in dvi
138 c.writeEPSfile("test_text
", page_paperformat=document.paperformat.A4)