Mercurial > ift6266
comparison pycaptcha/Captcha/Visual/Text.py @ 132:25b7c1f20949
Adapted pycaptcha to get fonts in /Tmp/allfonts local folder
author | boulanni <nicolas_boulanger@hotmail.com> |
---|---|
date | Sat, 20 Feb 2010 02:06:38 -0500 |
parents | 4775b4195b4b |
children |
comparison
equal
deleted
inserted
replaced
131:5c79a2557f2f | 132:25b7c1f20949 |
---|---|
16 """Picks random fonts and/or sizes from a given list. | 16 """Picks random fonts and/or sizes from a given list. |
17 'sizes' can be a single size or a (min,max) tuple. | 17 'sizes' can be a single size or a (min,max) tuple. |
18 If any of the given files are directories, all *.ttf found | 18 If any of the given files are directories, all *.ttf found |
19 in that directory will be added. | 19 in that directory will be added. |
20 """ | 20 """ |
21 extensions = [".ttf"] | 21 extensions = [".ttf", ".TTF"] |
22 basePath = "fonts" | 22 basePath = "fonts" |
23 | 23 |
24 # arguments variables a modifier pour mettre le chemin vers les fontes. | 24 # arguments variables a modifier pour mettre le chemin vers les fontes. |
25 def __init__(self, sizes, *fileNames): | 25 def __init__(self, sizes, *fileNames): |
26 File.RandomFileFactory.__init__(self, *fileNames) | 26 File.RandomFileFactory.__init__(self, *fileNames) |
37 fileName = File.RandomFileFactory.pick(self) | 37 fileName = File.RandomFileFactory.pick(self) |
38 size = int(random.uniform(self.minSize, self.maxSize) + 0.5) | 38 size = int(random.uniform(self.minSize, self.maxSize) + 0.5) |
39 return (fileName, size) | 39 return (fileName, size) |
40 | 40 |
41 # Predefined font factories | 41 # Predefined font factories |
42 defaultFontFactory = FontFactory(25, "vera", "others") | 42 defaultFontFactory = FontFactory(25, "allfonts") |
43 #defaultFontFactory = FontFactory((30, 40), "vera") | 43 #defaultFontFactory = FontFactory((30, 40), "vera") |
44 | 44 |
45 class TextLayer(Visual.Layer): | 45 class TextLayer(Visual.Layer): |
46 """Represents a piece of text rendered within the image. | 46 """Represents a piece of text rendered within the image. |
47 Alignment is given such that (0,0) places the text in the | 47 Alignment is given such that (0,0) places the text in the |