122122MSFolders = \
123123 r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'
124124
125- MSFontDirectories = [
125+
126+ MSFontDirectories = [
126127 r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts' ,
127128 r'SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts' ]
128129
129- X11FontDirectories = [
130+
131+ X11FontDirectories = [
130132 # an old standard installation point
131133 "/usr/X11R6/lib/X11/fonts/TTF/" ,
132134 "/usr/X11/lib/X11/fonts" ,
156158 path = os .path .join (home , '.fonts' )
157159 X11FontDirectories .append (path )
158160
161+
159162def get_fontext_synonyms (fontext ):
160163 """
161164 Return a list of file extensions extensions that are synonyms for
@@ -165,6 +168,7 @@ def get_fontext_synonyms(fontext):
165168 'otf' : ('ttf' , 'otf' ),
166169 'afm' : ('afm' ,)}[fontext ]
167170
171+
168172def list_fonts (directory , extensions ):
169173 """
170174 Return a list of all fonts matching any of the extensions,
@@ -174,6 +178,7 @@ def list_fonts(directory, extensions):
174178 for ext in extensions ])
175179 return cbook .listFiles (directory , pattern )
176180
181+
177182def win32FontDirectory ():
178183 """
179184 Return the user-specified font directory for Win32. This is
@@ -186,21 +191,22 @@ def win32FontDirectory():
186191 try :
187192 from six .moves import winreg
188193 except ImportError :
189- pass # Fall through to default
194+ pass # Fall through to default
190195 else :
191196 try :
192197 user = winreg .OpenKey (winreg .HKEY_CURRENT_USER , MSFolders )
193198 try :
194199 try :
195200 return winreg .QueryValueEx (user , 'Fonts' )[0 ]
196201 except OSError :
197- pass # Fall through to default
202+ pass # Fall through to default
198203 finally :
199204 winreg .CloseKey (user )
200205 except OSError :
201- pass # Fall through to default
206+ pass # Fall through to default
202207 return os .path .join (os .environ ['WINDIR' ], 'Fonts' )
203208
209+
204210def win32InstalledFonts (directory = None , fontext = 'ttf' ):
205211 """
206212 Search for fonts in the specified font directory, or use the
@@ -246,6 +252,7 @@ def win32InstalledFonts(directory=None, fontext='ttf'):
246252 winreg .CloseKey (local )
247253 return None
248254
255+
249256def OSXInstalledFonts (directories = None , fontext = 'ttf' ):
250257 """
251258 Get list of font files on OS X - ignores font suffix by default.
@@ -297,6 +304,7 @@ def get_fontconfig_fonts(fontext='ttf'):
297304 if os .path .splitext (fname )[1 ][1 :] in fontext ]
298305
299306
307+
300308def findSystemFonts (fontpaths = None , fontext = 'ttf' ):
301309 """
302310 Search for fonts in the specified font paths. If no paths are
@@ -338,6 +346,7 @@ def findSystemFonts(fontpaths=None, fontext='ttf'):
338346
339347 return [fname for fname in fontfiles if os .path .exists (fname )]
340348
349+
341350def weight_as_number (weight ):
342351 """
343352 Return the weight property as a numeric value. String values
@@ -419,7 +428,6 @@ def ttfFontProperty(font):
419428 else :
420429 style = 'normal'
421430
422-
423431 # Variants are: small-caps and normal (default)
424432
425433 # !!!! Untested
@@ -451,8 +459,8 @@ def ttfFontProperty(font):
451459 # Relative stretches are: wider, narrower
452460 # Child value is: inherit
453461
454- if sfnt4 .find ('narrow' ) >= 0 or sfnt4 .find ('condensed' ) >= 0 or \
455- sfnt4 .find ('cond' ) >= 0 :
462+ if ( sfnt4 .find ('narrow' ) >= 0 or sfnt4 .find ('condensed' ) >= 0 or
463+ sfnt4 .find ('cond' ) >= 0 ) :
456464 stretch = 'condensed'
457465 elif sfnt4 .find ('demi cond' ) >= 0 :
458466 stretch = 'semi-condensed'
0 commit comments