use poppler version of jbig2stream (fixes segv)
[swftools.git] / spec / fonts.py
1 from sys import * 
2 from pdflib_py import * 
3 import md5
4 import random
5 p = PDF_new() 
6 PDF_open_file(p, "fonts.pdf")
7
8 PDF_set_parameter(p, "usercoordinates", "true")
9
10 PDF_set_info(p, "Creator", "smalltext.py")
11 PDF_begin_page(p, 612, 600)
12
13 fonts = []
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", "")]
28
29 words = list(open("/usr/share/dict/words", "rb").readlines())
30
31 i = 0
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):
35     x = 0
36     while x < 612:
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)
43         PDF_show(p, text)
44
45 PDF_end_page(p)
46 PDF_close(p)
47 PDF_delete(p);