Mercurial > ift6266
diff transformations/ttf2jpg.py @ 144:c958941c1b9d
merge
author | XavierMuller |
---|---|
date | Tue, 23 Feb 2010 18:16:55 -0500 |
parents | a4e5128ef2cb |
children |
line wrap: on
line diff
--- a/transformations/ttf2jpg.py Tue Feb 23 18:08:11 2010 -0500 +++ b/transformations/ttf2jpg.py Tue Feb 23 18:16:55 2010 -0500 @@ -15,7 +15,7 @@ def __init__(self, font_file = ''): self.w = 32 self.h = 32 - self.font_dir = '/data/lisa/data/ift6266h10/fonts/windows7/' + self.font_dir = '/Tmp/allfonts/' self.font_file = font_file self.image_dir = './images/' self.pattern = '*.ttf' @@ -26,6 +26,8 @@ self.char_list.append(chr(ord('A') + i) ) for i in range(0,26): self.char_list.append(chr(ord('a') + i) ) + files = os.listdir(self.font_dir) + self.font_files = fnmatch.filter(files, '*.ttf') + fnmatch.filter(files, '*.TTF') # get font name def get_settings_names(self): @@ -42,10 +44,8 @@ # set a random font for character generation def set_random_font(self): - files = os.listdir(self.font_dir) - font_files = fnmatch.filter(files, self.pattern) - i = random.randint(0, len(font_files) - 1) - self.font_file = self.font_dir + font_files[i] + i = random.randint(0, len(self.font_files) - 1) + self.font_file = self.font_dir + self.font_files[i] # return a picture array of "text" with font "font_file" def create_image(self, text):