# HG changeset patch # User boulanni # Date 1266649649 18000 # Node ID a4e5128ef2cb140ba2c4cf9e52e4a37cea8ed944 # Parent 25b7c1f20949e0ab3a5acb1457b803d8902e3919 Adapted ttf2jpg to get fonts in /Tmp/allfonts local folder diff -r 25b7c1f20949 -r a4e5128ef2cb transformations/ttf2jpg.py --- a/transformations/ttf2jpg.py Sat Feb 20 02:06:38 2010 -0500 +++ b/transformations/ttf2jpg.py Sat Feb 20 02:07:29 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):