File: textengine.py

package info (click to toggle)
pyx3 0.17-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,328 kB
  • sloc: python: 27,656; makefile: 225; ansic: 130; sh: 17
file content (22 lines) | stat: -rw-r--r-- 792 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from pyx import *

# Set properties of the defaulttextengine, e.g. switch to LaTeX.
text.set(text.LatexEngine)

c = canvas.canvas()
# The canvas, by default, uses the defaulttextengine from the text module.
# This can be changed by the canvas method settextengine.
c.text(0, 0, r"This is \LaTeX.")

# If you want to use another textengine temporarily, you can just insert
# a text box manually
plaintex = text.TexEngine() # plain TeX engine
c.insert(plaintex.text(0, -1, r"This is plain \TeX."))

# There also is the UnicodeEngine to output text directly without TeX/LaTeX.
unicodetext = text.UnicodeEngine() # unicode engine
c.insert(unicodetext.text(0, -2, "Simple unicode output without TeX/LaTeX."))

c.writeEPSfile("textengine")
c.writePDFfile("textengine")
c.writeSVGfile("textengine")