1
Description: Add support for toilet's .tlf files.
2
There are .tlf files which are compatible with figlet.
3
Author: Stefano Rivera <stefano@rivera.za.net>
4
Forwarded: https://sourceforge.net/tracker/?func=detail&aid=2939616&group_id=200820&atid=975076
5
Last Update: 2010-01-25
13
- self.reMagicNumber = re.compile(r'^flf2.')
14
+ self.reMagicNumber = re.compile(r'^[ft]lf2.')
15
self.reEndMarker = re.compile(r'(.)\s*$')
19
a superclass to create different font sources.
21
def readFontFile(self):
22
- fontPath = '%s/%s.flf' % (self.dir, self.font)
23
- if os.path.exists(fontPath) is False:
24
+ for ext in ('flf', 'tlf'):
25
+ fontPath = '%s/%s.%s' % (self.dir, self.font, ext)
26
+ if os.path.exists(fontPath):
29
raise FontNotFound, "%s doesn't exist" % fontPath
36
- return [font[:-4] for font in os.walk(self.dir).next()[2] if font.endswith('.flf')]
37
+ return [font[:-4] for font in os.walk(self.dir).next()[2]
38
+ if font.endswith('.flf') or font.endswith('.tlf')]
43
if os.path.exists(self.zipfile) is False:
44
raise FontNotFound, "%s doesn't exist" % self.zipfile
46
- fontPath = 'fonts/%s.flf' % self.font
47
+ for ext in ('.flf', '.tlf'):
48
+ fontPath = 'fonts/%s.%s' % (self.font, ext)
51
- z = ZipFile(self.zipfile, 'r')
52
- files = z.namelist()
53
- if fontPath not in files:
54
- raise FontNotFound, '%s not found in %s' % (self.font, self.zipfile)
56
+ z = ZipFile(self.zipfile, 'r')
57
+ files = z.namelist()
58
+ if fontPath not in files:
59
+ raise FontNotFound, '%s not found in %s' % (self.font, self.zipfile)
61
- self.data = z.read(fontPath)
62
+ self.data = z.read(fontPath)
64
- except Exception, e:
65
- raise FontError, "couldn't open %s: %s" % (fontPath, e)
66
+ except Exception, e:
67
+ raise FontError, "couldn't open %s: %s" % (fontPath, e)
70
if os.path.exists(self.zipfile) is False:
71
raise FontNotFound, "%s doesn't exist" % self.zipfile
73
z = ZipFile(self.zipfile, 'r')
74
- return [font[6:-4] for font in z.namelist() if font.endswith('.flf')]
75
+ return [font[6:-4] for font in z.namelist()
76
+ if font.endswith('.flf') and font.endswith('.tlf')]