|
From: <md...@us...> - 2008-10-22 15:27:31
|
Revision: 6294
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6294&view=rev
Author: mdboom
Date: 2008-10-22 15:27:24 +0000 (Wed, 22 Oct 2008)
Log Message:
-----------
Fix buglet in font_manager.py
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/font_manager.py
Modified: trunk/matplotlib/lib/matplotlib/font_manager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/font_manager.py 2008-10-22 13:27:22 UTC (rev 6293)
+++ trunk/matplotlib/lib/matplotlib/font_manager.py 2008-10-22 15:27:24 UTC (rev 6294)
@@ -1005,7 +1005,7 @@
verbose.report('\tfindfont failed %(name)s, %(style)s, %(variant)s'%locals(), 'debug')
return None
- if weight in font:
+ if weight not in font:
setWeights(font)
if weight not in font:
return None
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-10-28 19:36:20
|
Revision: 6343
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6343&view=rev
Author: mdboom
Date: 2008-10-28 19:36:07 +0000 (Tue, 28 Oct 2008)
Log Message:
-----------
Add short circuit for font lookup
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/font_manager.py
Modified: trunk/matplotlib/lib/matplotlib/font_manager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/font_manager.py 2008-10-28 18:10:51 UTC (rev 6342)
+++ trunk/matplotlib/lib/matplotlib/font_manager.py 2008-10-28 19:36:07 UTC (rev 6343)
@@ -1211,6 +1211,8 @@
if score < best_score:
best_score = score
best_font = font
+ if score == 0:
+ break
if best_font is None or best_score > 10.0:
verbose.report('findfont: Could not match %s. Returning %s' %
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-10-29 17:15:42
|
Revision: 6347
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6347&view=rev
Author: mdboom
Date: 2008-10-29 17:15:32 +0000 (Wed, 29 Oct 2008)
Log Message:
-----------
Fix caching of findfont results.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/font_manager.py
Modified: trunk/matplotlib/lib/matplotlib/font_manager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/font_manager.py 2008-10-29 16:43:05 UTC (rev 6346)
+++ trunk/matplotlib/lib/matplotlib/font_manager.py 2008-10-29 17:15:32 UTC (rev 6347)
@@ -705,7 +705,9 @@
return parse_fontconfig_pattern(pattern)
def __hash__(self):
- return hash(repr(self.__dict__))
+ l = self.__dict__.items()
+ l.sort()
+ return hash(repr(l))
def __str__(self):
return self.get_fontconfig_pattern()
@@ -1192,7 +1194,7 @@
font_cache = self.ttf_lookup_cache
fontlist = self.ttflist
- cached = font_cache.get(prop)
+ cached = font_cache.get(hash(prop))
if cached:
return cached
@@ -1223,7 +1225,7 @@
(prop, best_font.name, best_font.fname, best_score))
result = best_font.fname
- font_cache[prop] = result
+ font_cache[hash(prop)] = result
return result
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-10-30 15:26:58
|
Revision: 6358
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6358&view=rev
Author: mdboom
Date: 2008-10-30 15:26:48 +0000 (Thu, 30 Oct 2008)
Log Message:
-----------
Fix bug in font_manager.py that was printing math junk on the docbuild machine.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/font_manager.py
Modified: trunk/matplotlib/lib/matplotlib/font_manager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/font_manager.py 2008-10-30 14:58:47 UTC (rev 6357)
+++ trunk/matplotlib/lib/matplotlib/font_manager.py 2008-10-30 15:26:48 UTC (rev 6358)
@@ -1200,6 +1200,7 @@
best_score = 1e64
best_font = None
+
for font in fontlist:
# Matching family should have highest priority, so it is multiplied
# by 10.0
@@ -1216,7 +1217,7 @@
if score == 0:
break
- if best_font is None or best_score > 10.0:
+ if best_font is None or best_score >= 10.0:
verbose.report('findfont: Could not match %s. Returning %s' %
(prop, self.defaultFont))
result = self.defaultFont
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-11-12 20:09:14
|
Revision: 6400
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6400&view=rev
Author: mdboom
Date: 2008-11-12 20:09:10 +0000 (Wed, 12 Nov 2008)
Log Message:
-----------
[ 2269684 ] mathtext broken in the cairo backend
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/font_manager.py
Modified: trunk/matplotlib/lib/matplotlib/font_manager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/font_manager.py 2008-11-12 20:00:11 UTC (rev 6399)
+++ trunk/matplotlib/lib/matplotlib/font_manager.py 2008-11-12 20:09:10 UTC (rev 6400)
@@ -397,7 +397,7 @@
self.size = size
-def ttfFontProperty(fontpath, font):
+def ttfFontProperty(font):
"""
A function for populating the :class:`FontKey` by extracting
information from the TrueType font file.
@@ -489,7 +489,7 @@
# !!!! Incomplete
size_adjust = None
- return FontEntry(fontpath, name, style, variant, weight, stretch, size)
+ return FontEntry(font.fname, name, style, variant, weight, stretch, size)
def afmFontProperty(fontpath, font):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-11-17 14:38:33
|
Revision: 6407
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6407&view=rev
Author: mdboom
Date: 2008-11-17 14:38:27 +0000 (Mon, 17 Nov 2008)
Log Message:
-----------
Fix minor bug in findfont -- None input should return default font.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/font_manager.py
Modified: trunk/matplotlib/lib/matplotlib/font_manager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/font_manager.py 2008-11-17 14:37:14 UTC (rev 6406)
+++ trunk/matplotlib/lib/matplotlib/font_manager.py 2008-11-17 14:38:27 UTC (rev 6407)
@@ -1180,6 +1180,8 @@
for a description of the font finding algorithm.
"""
debug = False
+ if prop is None:
+ return self.defaultFont
if is_string_like(prop):
prop = FontProperties(prop)
fname = prop.get_file()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-11-25 15:23:32
|
Revision: 6446
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6446&view=rev
Author: mdboom
Date: 2008-11-25 15:23:28 +0000 (Tue, 25 Nov 2008)
Log Message:
-----------
Fix mathtext (bug has existed since r6400 11/12/2008)
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/font_manager.py
Modified: trunk/matplotlib/lib/matplotlib/font_manager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/font_manager.py 2008-11-25 04:03:59 UTC (rev 6445)
+++ trunk/matplotlib/lib/matplotlib/font_manager.py 2008-11-25 15:23:28 UTC (rev 6446)
@@ -592,7 +592,7 @@
verbose.report("Cannot handle unicode filenames")
#print >> sys.stderr, 'Bad file is', fpath
continue
- try: prop = ttfFontProperty(fpath, font)
+ try: prop = ttfFontProperty(font)
except: continue
fontlist.append(prop)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jo...@us...> - 2009-11-12 17:57:21
|
Revision: 7955
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7955&view=rev
Author: jouni
Date: 2009-11-12 17:57:13 +0000 (Thu, 12 Nov 2009)
Log Message:
-----------
Fix previous EINTR fix in case fc-list cannot be run
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/font_manager.py
Modified: trunk/matplotlib/lib/matplotlib/font_manager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/font_manager.py 2009-11-12 17:31:19 UTC (rev 7954)
+++ trunk/matplotlib/lib/matplotlib/font_manager.py 2009-11-12 17:57:13 UTC (rev 7955)
@@ -295,8 +295,13 @@
fontext = get_fontext_synonyms(fontext)
fontfiles = {}
- pipe = subprocess.Popen(['fc-list', '', 'file'], stdout=subprocess.PIPE)
- output = pipe.communicate()[0]
+ try:
+ pipe = subprocess.Popen(['fc-list', '', 'file'], stdout=subprocess.PIPE)
+ output = pipe.communicate()[0]
+ except OSError:
+ # Calling fc-list did not work, so we'll just return nothing
+ return fontfiles
+
if pipe.returncode == 0:
for line in output.split('\n'):
fname = line.split(':')[0]
@@ -1242,8 +1247,11 @@
def fc_match(pattern, fontext):
fontexts = get_fontext_synonyms(fontext)
ext = "." + fontext
- pipe = subprocess.Popen(['fc-match', '-sv', pattern], stdout=subprocess.PIPE)
- output = pipe.communicate()[0]
+ try:
+ pipe = subprocess.Popen(['fc-match', '-sv', pattern], stdout=subprocess.PIPE)
+ output = pipe.communicate()[0]
+ except OSError:
+ return None
if pipe.returncode == 0:
for match in _fc_match_regex.finditer(output):
file = match.group(1)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2010-04-30 14:41:47
|
Revision: 8290
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8290&view=rev
Author: mdboom
Date: 2010-04-30 14:41:40 +0000 (Fri, 30 Apr 2010)
Log Message:
-----------
Use case-insensitive matching for font names in family set lists (rcParams font.serif, font.sans-serif etc.)
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/font_manager.py
Modified: trunk/matplotlib/lib/matplotlib/font_manager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/font_manager.py 2010-04-29 21:43:53 UTC (rev 8289)
+++ trunk/matplotlib/lib/matplotlib/font_manager.py 2010-04-30 14:41:40 UTC (rev 8290)
@@ -1056,15 +1056,18 @@
No match will return 1.0.
"""
+ family2 = family2.lower()
for i, family1 in enumerate(families):
- if family1.lower() in font_family_aliases:
+ family1 = family1.lower()
+ if family1 in font_family_aliases:
if family1 == 'sans':
family1 == 'sans-serif'
options = rcParams['font.' + family1]
+ options = [x.lower() for x in options]
if family2 in options:
idx = options.index(family2)
return 0.1 * (float(idx) / len(options))
- elif family1.lower() == family2.lower():
+ elif family1 == family2:
return 0.0
return 1.0
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2010-05-12 14:55:34
|
Revision: 8311
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8311&view=rev
Author: mdboom
Date: 2010-05-12 14:55:27 +0000 (Wed, 12 May 2010)
Log Message:
-----------
Support "sans serif" as an alias for "sans-serif" in font family names.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/font_manager.py
Modified: trunk/matplotlib/lib/matplotlib/font_manager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/font_manager.py 2010-05-12 14:50:24 UTC (rev 8310)
+++ trunk/matplotlib/lib/matplotlib/font_manager.py 2010-05-12 14:55:27 UTC (rev 8311)
@@ -401,8 +401,8 @@
return "<Font '%s' (%s) %s %s %s %s>" % (
self.name, os.path.basename(self.fname), self.style, self.variant,
self.weight, self.stretch)
-
+
def ttfFontProperty(font):
"""
A function for populating the :class:`FontKey` by extracting
@@ -1065,7 +1065,7 @@
for i, family1 in enumerate(families):
family1 = family1.lower()
if family1 in font_family_aliases:
- if family1 == 'sans':
+ if family1 in ('sans', 'sans serif'):
family1 == 'sans-serif'
options = rcParams['font.' + family1]
options = [x.lower() for x in options]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2010-05-12 15:15:28
|
Revision: 8312
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8312&view=rev
Author: mdboom
Date: 2010-05-12 15:15:19 +0000 (Wed, 12 May 2010)
Log Message:
-----------
[2963827] FontProperties does not seem to be working...
1. Warn when a font family can not be found
2. Fallback to the correct variant of Vera Sans (rather than always non-bold upright) when the font family lookup fails
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/font_manager.py
Modified: trunk/matplotlib/lib/matplotlib/font_manager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/font_manager.py 2010-05-12 14:55:27 UTC (rev 8311)
+++ trunk/matplotlib/lib/matplotlib/font_manager.py 2010-05-12 15:15:19 UTC (rev 8312)
@@ -42,7 +42,7 @@
see license/LICENSE_TTFQUERY.
"""
-import os, sys, glob, subprocess
+import os, sys, glob, subprocess, warnings
try:
set
except NameError:
@@ -974,7 +974,7 @@
# Increment this version number whenever the font cache data
# format or behavior has changed and requires a existing font
# cache files to be rebuilt.
- __version__ = 5
+ __version__ = 6
def __init__(self, size=None, weight='normal'):
self._version = self.__version__
@@ -1001,6 +1001,9 @@
# Load TrueType fonts and create font dictionary.
self.ttffiles = findSystemFonts(paths) + findSystemFonts()
+ self.defaultFamily = {
+ 'ttf': 'Bitstream Vera Sans',
+ 'afm': 'Helvetica'}
self.defaultFont = {}
for fname in self.ttffiles:
@@ -1164,7 +1167,8 @@
return 1.0
return abs(sizeval1 - sizeval2) / 72.0
- def findfont(self, prop, fontext='ttf', directory=None):
+ def findfont(self, prop, fontext='ttf', directory=None,
+ fallback_to_default=True):
"""
Search the font list for the font that most closely matches
the :class:`FontProperties` *prop*.
@@ -1181,6 +1185,10 @@
The result is cached, so subsequent lookups don't have to
perform the O(n) nearest neighbor search.
+ If `fallback_to_default` is True, will fallback to the default
+ font family (usually "Bitstream Vera Sans" or "Helvetica") if
+ the first lookup hard-fails.
+
See the `W3C Cascading Style Sheet, Level 1
<http://www.w3.org/TR/1998/REC-CSS2-19980512/>`_ documentation
for a description of the font finding algorithm.
@@ -1229,12 +1237,25 @@
break
if best_font is None or best_score >= 10.0:
- verbose.report('findfont: Could not match %s. Returning %s' %
- (prop, self.defaultFont[fontext]))
- result = self.defaultFont[fontext]
+ if fallback_to_default:
+ warnings.warn(
+ 'findfont: Font family %s not found. Falling back to %s' %
+ (prop.get_family(), self.defaultFamily[fontext]))
+ default_prop = prop.copy()
+ default_prop.set_family(self.defaultFamily[fontext])
+ return self.findfont(default_prop, fontext, directory, False)
+ else:
+ # This is a hard fail -- we can't find anything reasonable,
+ # so just return the vera.ttf
+ warnings.warn(
+ 'findfont: Could not match %s. Returning %s' %
+ (prop, self.defaultFont[fontext]),
+ UserWarning)
+ result = self.defaultFont[fontext]
else:
- verbose.report('findfont: Matching %s to %s (%s) with score of %f' %
- (prop, best_font.name, best_font.fname, best_score))
+ verbose.report(
+ 'findfont: Matching %s to %s (%s) with score of %f' %
+ (prop, best_font.name, best_font.fname, best_score))
result = best_font.fname
font_cache[hash(prop)] = result
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2010-05-12 17:58:26
|
Revision: 8315
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8315&view=rev
Author: mdboom
Date: 2010-05-12 17:58:17 +0000 (Wed, 12 May 2010)
Log Message:
-----------
Minor improvement to font_manager -- don't cache directory-specific results.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/font_manager.py
Modified: trunk/matplotlib/lib/matplotlib/font_manager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/font_manager.py 2010-05-12 15:28:12 UTC (rev 8314)
+++ trunk/matplotlib/lib/matplotlib/font_manager.py 2010-05-12 17:58:17 UTC (rev 8315)
@@ -1193,10 +1193,7 @@
<http://www.w3.org/TR/1998/REC-CSS2-19980512/>`_ documentation
for a description of the font finding algorithm.
"""
- debug = False
- if prop is None:
- prop = FontProperties()
- if is_string_like(prop):
+ if not isinstance(prop, FontProperties):
prop = FontProperties(prop)
fname = prop.get_file()
if fname is not None:
@@ -1210,9 +1207,10 @@
font_cache = self.ttf_lookup_cache
fontlist = self.ttflist
- cached = font_cache.get(hash(prop))
- if cached:
- return cached
+ if directory is None:
+ cached = font_cache.get(hash(prop))
+ if cached:
+ return cached
best_score = 1e64
best_font = None
@@ -1258,7 +1256,8 @@
(prop, best_font.name, best_font.fname, best_score))
result = best_font.fname
- font_cache[hash(prop)] = result
+ if directory is None:
+ font_cache[hash(prop)] = result
return result
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2010-05-20 14:59:40
|
Revision: 8327
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8327&view=rev
Author: mdboom
Date: 2010-05-20 14:59:33 +0000 (Thu, 20 May 2010)
Log Message:
-----------
Minor bug in accepting "sans serif" as a font family alias.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/font_manager.py
Modified: trunk/matplotlib/lib/matplotlib/font_manager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/font_manager.py 2010-05-20 14:01:32 UTC (rev 8326)
+++ trunk/matplotlib/lib/matplotlib/font_manager.py 2010-05-20 14:59:33 UTC (rev 8327)
@@ -106,6 +106,7 @@
font_family_aliases = set([
'serif',
'sans-serif',
+ 'sans serif',
'cursive',
'fantasy',
'monospace',
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2010-05-20 16:33:44
|
Revision: 8329
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8329&view=rev
Author: mdboom
Date: 2010-05-20 16:33:38 +0000 (Thu, 20 May 2010)
Log Message:
-----------
Fix font manager bug.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/font_manager.py
Modified: trunk/matplotlib/lib/matplotlib/font_manager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/font_manager.py 2010-05-20 16:19:53 UTC (rev 8328)
+++ trunk/matplotlib/lib/matplotlib/font_manager.py 2010-05-20 16:33:38 UTC (rev 8329)
@@ -1070,7 +1070,7 @@
family1 = family1.lower()
if family1 in font_family_aliases:
if family1 in ('sans', 'sans serif'):
- family1 == 'sans-serif'
+ family1 = 'sans-serif'
options = rcParams['font.' + family1]
options = [x.lower() for x in options]
if family2 in options:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|