On 03/26/2012 04:36 PM, Martin Mokrejs wrote:
> Hi,
>    I wondered why the matplotlib.font_manager.rcParams contains sometimes
> escaped minus signs in font names:
>>>> font_manager.rcParams['mathtext.sf']
> 'sans\\-serif'
>>>> font_manager.findfont('sans-serif')
> Traceback (most recent call last):
>    File "<stdin>", line 1, in<module>
>    File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 
> 1327, in findfont
>      font = fontManager.findfont(prop, **kw)
>    File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 
> 1172, in findfont
>      prop = FontProperties(prop)
>    File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 
> 673, in __init__
>      self.set_fontconfig_pattern(family)
>    File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 
> 893, in set_fontconfig_pattern
>      for key, val in self._parse_fontconfig_pattern(pattern).items():
>    File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 
> 685, in _parse_fontconfig_pattern
>      return parse_fontconfig_pattern(pattern)
>    File 
> "/usr/lib64/python2.7/site-packages/matplotlib/fontconfig_pattern.py", line 
> 127, in parse
>      raise ValueError("Could not parse font string: '%s'\n%s" % (pattern, e))
> ValueError: Could not parse font string: 'sans-serif'
> Expected end of text (at char 4), (line:1, col:5)
>>>> font_manager.findfont('sans\\-serif')
> '/usr/share/fonts/mathematica-fonts/Vera.ttf'
>
> And there is nothing to read in the help string for this function, definitely
> a place where the escaping should be explained.
>
>>>> help(font_manager.findfont)
>>>>
> Anyway, I think the requirement for the escaping should be removed, it should 
> be
> escaped internally in the routine. So why is it so? For historic reasons? ;-)

I've never seen this happen before.  Are you setting "mathtext.sf" in a 
matplotlibrc file or in Python code?  Can you provide either so I can 
see if I can reproduce the problem here?

>
>
>
>
> Isn't the escaping a cause for the seemingly missing fonts, like reported 
> here?
> http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg22860.html

No -- that appears to be caused by either using the wrong font name or 
having an outdated font cache.

>
>
> I am also getting:
>
> /usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1216: 
> UserWarning: findfont: Font family ['cmb10'] not found. Falling back to 
> Bitstream Vera Sans
>    (prop.get_family(), self.defaultFamily[fontext]))
> /usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1216: 
> UserWarning: findfont: Font family ['cmtt10'] not found. Falling back to 
> Bitstream Vera Sans
>    (prop.get_family(), self.defaultFamily[fontext]))
> /usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1216: 
> UserWarning: findfont: Font family ['cmss10'] not found. Falling back to 
> Bitstream Vera Sans
>    (prop.get_family(), self.defaultFamily[fontext]))
>
> The font to be used is assembled from several fields in the rcParams. I guess 
> from:
>
>>>> [x for x in font_manager.rcParams.keys() if x.startswith('font')]
> ['font.cursive', 'font.family', 'font.fantasy', 'font.monospace', 
> 'font.sans-serif', 'font.serif', 'font.size', 'font.stretch', 'font.style', 
> 'font.variant', 'font.weight']
>>>> [x for x in font_manager.rcParams.values() if x.startswith('cm')]
> /usr/lib64/python2.7/site-packages/matplotlib/__init__.py:658: UserWarning: 
> svg.embed_char_paths is deprecated and replaced with svg.fonttype; please use 
> the latter.
>    warnings.warn(self.msg_depr % (key, alt))
> Traceback (most recent call last):
>    File "<stdin>", line 1, in<module>
> AttributeError: 'int' object has no attribute 'startswith'
>>>> [x for x in font_manager.rcParams.items() if x[1]=='cm']
> [('mathtext.fontset', 'cm')]
> What else is used to give out the 'cmb10', 'cmtt10' and 'cmss10'?

These are hardcoded in the mathtext engine and used when 
`mathtext.fontset` is set to `cm`.

Have you tried deleting your font cache?  (~/.matplotlib/fontList.cache)

Mike

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to