From: <md...@us...> - 2007-08-08 16:48:49
|
Revision: 3685 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3685&view=rev Author: mdboom Date: 2007-08-08 09:48:48 -0700 (Wed, 08 Aug 2007) Log Message: ----------- Removing accidentally committed debugging output. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/font_manager.py Modified: trunk/matplotlib/lib/matplotlib/font_manager.py =================================================================== --- trunk/matplotlib/lib/matplotlib/font_manager.py 2007-08-08 16:46:54 UTC (rev 3684) +++ trunk/matplotlib/lib/matplotlib/font_manager.py 2007-08-08 16:48:48 UTC (rev 3685) @@ -850,13 +850,6 @@ break verbose.report('loaded ttfcache file %s'%ttfcache) - def flatten(d, path): - if isinstance(d, dict): - for key, val in d.items(): - flatten(val, path + [key]) - elif isinstance(d, str): - print path, os.path.basename(d) - flatten(self.ttfdict, []) #self.ttfdict = createFontDict(self.ttffiles) # Load AFM fonts for PostScript @@ -935,14 +928,12 @@ fname = None font = fontdict - print font.keys() if font.has_key(name): font = font[name] else: verbose.report('\tfindfont failed %(name)s'%locals(), 'debug') return None - print font.keys() if font.has_key(style): font = font[style] elif style == 'italic' and font.has_key('oblique'): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-10 18:45:46
|
Revision: 3698 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3698&view=rev Author: mdboom Date: 2007-08-10 11:45:44 -0700 (Fri, 10 Aug 2007) Log Message: ----------- Add ~/.fonts as search directory on Linux Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/font_manager.py Modified: trunk/matplotlib/lib/matplotlib/font_manager.py =================================================================== --- trunk/matplotlib/lib/matplotlib/font_manager.py 2007-08-10 18:06:16 UTC (rev 3697) +++ trunk/matplotlib/lib/matplotlib/font_manager.py 2007-08-10 18:45:44 UTC (rev 3698) @@ -85,6 +85,8 @@ # user fonts on OSX path = os.path.join(home, 'Library', 'Fonts') OSXFontDirectories.append(path) + path = os.path.join(home, '.fonts') + X11FontDirectories.append(path) def win32FontDirectory(): """Return the user-specified font directory for Win32.""" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-13 12:55:29
|
Revision: 3703 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3703&view=rev Author: mdboom Date: 2007-08-13 05:55:27 -0700 (Mon, 13 Aug 2007) Log Message: ----------- Grab list of fonts from fontconfig if fontconfig is installed. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/font_manager.py Modified: trunk/matplotlib/lib/matplotlib/font_manager.py =================================================================== --- trunk/matplotlib/lib/matplotlib/font_manager.py 2007-08-13 12:46:26 UTC (rev 3702) +++ trunk/matplotlib/lib/matplotlib/font_manager.py 2007-08-13 12:55:27 UTC (rev 3703) @@ -51,8 +51,8 @@ 'xx-large': 1.728} weight_dict = {'light': 200, 'normal': 400, 'regular': 400, 'book': 400, - 'medium': 500, 'roman': 500, 'semibold': 600, 'demibold': 600, - 'demi': 600, 'bold': 700, 'heavy': 800, 'extra bold': 800, + 'medium': 500, 'roman': 500, 'semibold': 600, 'demibold': 600, + 'demi': 600, 'bold': 700, 'heavy': 800, 'extra bold': 800, 'black': 900} # OS Font paths @@ -185,16 +185,37 @@ pass return fontpaths +def get_fontconfig_fonts(fontext='ttf'): + """Grab a list of all the fonts that are being tracked by fontconfig. + This is an easy way to grab all of the fonts the user wants to be made + available to applications, without knowing where all of them reside.""" + try: + import commands + except ImportError: + return {} + + fontfiles = {} + status, output = commands.getstatusoutput("fc-list file") + if status == 0: + for line in output.split('\n'): + fname = line.split(':')[0] + if (os.path.splitext(fname)[1] == "." + fontext and + os.path.exists(fname)): + fontfiles[fname] = 1 + + return fontfiles + def findSystemFonts(fontpaths=None, fontext='ttf'): """ - Search for fonts in the specified font paths, or use the system - paths if none given. A list of TrueType fonts are returned by default - with AFM fonts as an option. + Search for fonts in the specified font paths. If no paths are + given, will use a standard set of system paths, as well as the + list of fonts tracked by fontconfig if fontconfig is installed and + available. A list of TrueType fonts are returned by default with + AFM fonts as an option. """ fontfiles = {} if fontpaths is None: - if sys.platform == 'win32': fontdir = win32FontDirectory() @@ -210,7 +231,10 @@ if sys.platform == 'darwin': for f in OSXInstalledFonts(): fontfiles[f] = 1 - + + for f in get_fontconfig_fonts(fontext): + fontfiles[f] = 1 + elif isinstance(fontpaths, (str, unicode)): fontpaths = [fontpaths] @@ -447,12 +471,12 @@ seen = {} for fpath in fontfiles: verbose.report('createFontDict: %s' % (fpath), 'debug') - fname = fpath.split('/')[-1] + fname = os.path.split(fpath)[1] if seen.has_key(fname): continue else: seen[fname] = 1 if fontext == 'afm': try: - fh = open(fpath) + fh = open(fpath, 'r') except: verbose.report("Could not open font file %s" % fpath) continue This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-09-06 12:10:58
|
Revision: 3795 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3795&view=rev Author: mdboom Date: 2007-09-06 05:09:08 -0700 (Thu, 06 Sep 2007) Log Message: ----------- Fix set_name call. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/font_manager.py Modified: trunk/matplotlib/lib/matplotlib/font_manager.py =================================================================== --- trunk/matplotlib/lib/matplotlib/font_manager.py 2007-09-05 21:50:01 UTC (rev 3794) +++ trunk/matplotlib/lib/matplotlib/font_manager.py 2007-09-06 12:09:08 UTC (rev 3795) @@ -637,7 +637,7 @@ self.__props.__dict__.update(_init) return - if isinstance(family, str): + if is_string_like(family): # Treat family as a fontconfig pattern if it is the only # parameter provided. if (style is None and @@ -720,8 +720,11 @@ if family is None: self.__props.__dict__.pop('family', None) else: + if is_string_like(family): + family = [family] self.__props.family = family - + set_name = set_family + def set_style(self, style): """Set the font style. Values are: normal, italic or oblique.""" if style is None: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-09-20 12:31:27
|
Revision: 3861 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3861&view=rev Author: mdboom Date: 2007-09-20 05:31:26 -0700 (Thu, 20 Sep 2007) Log Message: ----------- Fix font.size from being saved in the fontManager.cache Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/font_manager.py Modified: trunk/matplotlib/lib/matplotlib/font_manager.py =================================================================== --- trunk/matplotlib/lib/matplotlib/font_manager.py 2007-09-19 19:48:17 UTC (rev 3860) +++ trunk/matplotlib/lib/matplotlib/font_manager.py 2007-09-20 12:31:26 UTC (rev 3861) @@ -773,6 +773,7 @@ else: if is_string_like(size): parent_size = fontManager.get_default_size() + print "parent_size", parent_size, size scaling = font_scalings.get(size) if scaling is not None: size = parent_size * scaling @@ -843,10 +844,9 @@ """ def __init__(self, size=None, weight='normal'): - if not size : size = rcParams['font.size'] - self.__default_size = size self.__default_weight = weight - + self.default_size = size + paths = [os.path.join(rcParams['datapath'],'fonts','ttf'), os.path.join(rcParams['datapath'],'fonts','afm')] @@ -899,7 +899,9 @@ def get_default_size(self): "Return the default font size." - return self.__default_size + if self.default_size is None: + return rcParams['font.size'] + return self.default_size def set_default_weight(self, weight): "Set the default font weight. The initial value is 'normal'." @@ -1085,6 +1087,7 @@ try: fontManager = pickle_load(_fmcache) + fontManager.default_size = None verbose.report("Using fontManager instance from %s" % _fmcache) except: _rebuild() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-09-20 12:40:43
|
Revision: 3862 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3862&view=rev Author: mdboom Date: 2007-09-20 05:40:41 -0700 (Thu, 20 Sep 2007) Log Message: ----------- Removing debugging output in last commit. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/font_manager.py Modified: trunk/matplotlib/lib/matplotlib/font_manager.py =================================================================== --- trunk/matplotlib/lib/matplotlib/font_manager.py 2007-09-20 12:31:26 UTC (rev 3861) +++ trunk/matplotlib/lib/matplotlib/font_manager.py 2007-09-20 12:40:41 UTC (rev 3862) @@ -773,7 +773,6 @@ else: if is_string_like(size): parent_size = fontManager.get_default_size() - print "parent_size", parent_size, size scaling = font_scalings.get(size) if scaling is not None: size = parent_size * scaling This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-09 13:19:40
|
Revision: 4179 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4179&view=rev Author: mdboom Date: 2007-11-09 05:19:38 -0800 (Fri, 09 Nov 2007) Log Message: ----------- Fix font caching bug on OSX Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/font_manager.py Modified: trunk/matplotlib/lib/matplotlib/font_manager.py =================================================================== --- trunk/matplotlib/lib/matplotlib/font_manager.py 2007-11-09 13:10:12 UTC (rev 4178) +++ trunk/matplotlib/lib/matplotlib/font_manager.py 2007-11-09 13:19:38 UTC (rev 4179) @@ -172,7 +172,7 @@ pass return fontpaths -def OSXInstalledFonts(directory=None, fontext=None): +def OSXInstalledFonts(directory=None, fontext='ttf'): """Get list of font files on OS X - ignores font suffix by default""" if directory is None: directory = OSXFontDirectory() @@ -251,7 +251,7 @@ fontpaths = x11FontDirectory() # check for OS X & load its fonts if present if sys.platform == 'darwin': - for f in OSXInstalledFonts(): + for f in OSXInstalledFonts(fontext=fontext): fontfiles[f] = 1 for f in get_fontconfig_fonts(fontext): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-06 19:10:16
|
Revision: 4653 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4653&view=rev Author: mdboom Date: 2007-12-06 11:10:12 -0800 (Thu, 06 Dec 2007) Log Message: ----------- [ 1841933 ] font_manager.win32FontDirectory() fails as Vista service Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/font_manager.py Modified: trunk/matplotlib/lib/matplotlib/font_manager.py =================================================================== --- trunk/matplotlib/lib/matplotlib/font_manager.py 2007-12-06 18:49:35 UTC (rev 4652) +++ trunk/matplotlib/lib/matplotlib/font_manager.py 2007-12-06 19:10:12 UTC (rev 4653) @@ -105,14 +105,16 @@ try: import _winreg except ImportError: - return os.path.join(os.environ['WINDIR'], 'Fonts') + pass # Fall through to default else: user = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, MSFolders) try: return _winreg.QueryValueEx(user, 'Fonts')[0] + except OSError: + pass # Fall through to default finally: _winreg.CloseKey(user) - return None + return os.path.join(os.environ['WINDIR'], 'Fonts') def win32InstalledFonts(directory=None, fontext='ttf'): """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-10 15:34:35
|
Revision: 4685 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4685&view=rev Author: mdboom Date: 2007-12-10 07:34:29 -0800 (Mon, 10 Dec 2007) Log Message: ----------- Fix syntax for pre-Python 2.5 Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/font_manager.py Modified: trunk/matplotlib/lib/matplotlib/font_manager.py =================================================================== --- trunk/matplotlib/lib/matplotlib/font_manager.py 2007-12-10 15:23:08 UTC (rev 4684) +++ trunk/matplotlib/lib/matplotlib/font_manager.py 2007-12-10 15:34:29 UTC (rev 4685) @@ -109,9 +109,10 @@ else: user = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, MSFolders) try: - return _winreg.QueryValueEx(user, 'Fonts')[0] - except OSError: - pass # Fall through to default + try: + return _winreg.QueryValueEx(user, 'Fonts')[0] + except OSError: + pass # Fall through to default finally: _winreg.CloseKey(user) return os.path.join(os.environ['WINDIR'], 'Fonts') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |