2 from pdflib_py
import *
6 PDF_open_file(p
, "fonts.pdf")
8 PDF_set_parameter(p
, "usercoordinates", "true")
10 PDF_set_info(p
, "Creator", "smalltext.py")
11 PDF_begin_page(p
, 612, 600)
14 fonts
+= [PDF_load_font(p
, "Times-Roman", "host", "")]
15 fonts
+= [PDF_load_font(p
, "Times-Italic", "host", "")]
16 fonts
+= [PDF_load_font(p
, "Times-Bold", "host", "")]
17 fonts
+= [PDF_load_font(p
, "Times-BoldItalic", "host", "")]
18 fonts
+= [PDF_load_font(p
, "Helvetica", "host", "")]
19 fonts
+= [PDF_load_font(p
, "Helvetica-Oblique", "host", "")]
20 fonts
+= [PDF_load_font(p
, "Helvetica-Bold", "host", "")]
21 fonts
+= [PDF_load_font(p
, "Helvetica-BoldOblique", "host", "")]
22 fonts
+= [PDF_load_font(p
, "Courier", "host", "")]
23 fonts
+= [PDF_load_font(p
, "Courier-Oblique", "host", "")]
24 fonts
+= [PDF_load_font(p
, "Courier-Bold", "host", "")]
25 fonts
+= [PDF_load_font(p
, "Courier-BoldOblique", "host", "")]
26 #fonts += [PDF_load_font(p, "Symbol", "host", "")]
27 #fonts += [PDF_load_font(p, "ZapfDingbats", "host", "")]
29 words
= list(open("/usr/share/dict/words", "rb").readlines())
32 # the idea is to overflow the placetext matrix once, so that
33 # we have at least two different ty values
34 for y
in range(3000 / 24):
37 font
= fonts
[random
.randint(0,len(fonts
)-1)]
38 fontsize
= 10+14*random
.random()
39 PDF_setfont(p
, font
, fontsize
)
40 PDF_set_text_pos(p
, x
, y
*24+(24-fontsize
)/2);
41 text
= words
[random
.randint(0,len(words
)-1)]
42 x
+= PDF_stringwidth(p
, text
, font
, fontsize
)