diff transformations/ttf2jpg.py @ 109:9c45e0071b52

Adapté le générateur d'images de fontes pour utiliser en amont du pipeline
author boulanni <nicolas_boulanger@hotmail.com>
date Tue, 16 Feb 2010 13:10:06 -0500
parents 05145f4fb609
children a4e5128ef2cb
line wrap: on
line diff
--- a/transformations/ttf2jpg.py	Mon Feb 15 16:17:48 2010 -0500
+++ b/transformations/ttf2jpg.py	Tue Feb 16 13:10:06 2010 -0500
@@ -15,17 +15,17 @@
     def __init__(self, font_file = ''):
         self.w = 32
         self.h = 32
-        self.font_dir = '/usr/share/fonts/truetype/ttf-liberation/'
+        self.font_dir = '/data/lisa/data/ift6266h10/fonts/windows7/'
         self.font_file = font_file
         self.image_dir = './images/'
         self.pattern = '*.ttf'
         self.char_list = []
+        for i in range(0,10):
+            self.char_list.append(chr(ord('0') + i) )
+        for i in range(0,26):
+            self.char_list.append(chr(ord('A') + i) )
         for i in range(0,26):
             self.char_list.append(chr(ord('a') + i) )
-        for i in range(0,26):
-            self.char_list.append(chr(ord('A') + i) )
-        for i in range(0,10):
-            self.char_list.append(chr(ord('0') + i) )
 
     # get font name
     def get_settings_names(self):
@@ -85,7 +85,7 @@
     def generate_image(self):
         self.set_random_font()
         i = random.randint(0, len(self.char_list) - 1)
-        return self.generate_image_from_char(self.char_list[i])
+        return self.generate_image_from_char(self.char_list[i]), i
 
     # test method, create character images for all fonts in "font_dir" in dir "image_dir"
     def test(self):
@@ -117,5 +117,5 @@
 
     myttf2jpg = ttf2jpg()
     #myttf2jpg.test()
-    image = myttf2jpg.generate_image()
-    myttf2jpg.save_image(image, '')
\ No newline at end of file
+    image, i = myttf2jpg.generate_image()
+    myttf2jpg.save_image(image, '')