fixed segv for files with wrong font types
[swftools.git] / spec / textselectspaces.py
blob737744f970be9b3304bce298cb642204606d0385
1 from sys import *
2 from pdflib_py import *
3 p = PDF_new()
4 PDF_open_file(p, "textselectspaces.pdf")
6 PDF_set_parameter(p, "usercoordinates", "true")
8 PDF_set_info(p, "Creator", "smalltext.py")
9 PDF_begin_page(p, 612, 200)
10 font = PDF_load_font(p, "Helvetica", "host", "")
12 PDF_setfont(p, font, 18.0)
14 x = 40
15 y = 100
16 def write_word(s, d):
17 global x,y
18 w = PDF_stringwidth(p, s, font, 18.0)
19 PDF_show(p, s)
20 x+=w+d
21 PDF_set_text_pos(p, x, y)
23 x,y = 40,160
24 PDF_set_text_pos(p, x, y)
25 write_word("The", 20)
26 write_word("quick", 20)
27 write_word("brown", 20)
28 write_word("fox", 20)
30 x,y = 40,130
31 PDF_set_text_pos(p, x, y)
32 write_word("The", 10)
33 write_word("quick", 10)
34 write_word("brown", 10)
35 write_word("fox", 10)
37 x,y = 40,100
38 PDF_set_text_pos(p, x, y)
39 write_word("The", 1)
40 write_word("quick", 1)
41 write_word("brown", 1)
42 write_word("fox", 1)
44 PDF_setmatrix(p, 2.5, 0, 0, 1.0, 0, 0)
45 x,y = 16,70
46 PDF_set_text_pos(p, x, y)
47 write_word("The", 0.5)
48 write_word("quick", 0.5)
49 write_word("brown", 0.5)
50 write_word("fox", 0.5)
52 PDF_setmatrix(p, 2.5, 0, 0, 1.0, 0, 0)
53 x,y = 16,40
54 PDF_set_text_pos(p, x, y)
55 write_word("The", 5)
56 write_word("quick", 5)
57 write_word("brown", 5)
58 write_word("fox", 5)
61 PDF_end_page(p)
62 PDF_close(p)
63 PDF_delete(p);