font setting in matplotlib 1.3.1

Hi all,
after upgrading to matplotlib 1.3.1, I noticed some display errors on
the plots with regard to accented characters (such as carons etc.).
As I recall, I had similar problem in the past and could work around
them by modifying rcParams, however, this fix doesn't work as expected
in 1.3.1. (with python 2.7.6, 32bit on Win 7, Czech - with both WXAgg
and TKAgg backends).

From the usual Czech diacritics áčďéěíňóřšťúůýž some are not

displayed (ďěňřťů) - replacement squares are shown instead.

Simply prepending a suitable font at the beginning of the list
rcParams['font.sans-serif'] doesn't help in 1.3.1.
I eventually found out, that "Bitstream Vera Sans" (which is not
installed on this computer) is somehow offending - as long as this
item is in the list (even at the end), the mentioned characters aren't
displayed.

The problem can be observed in the following simple pylab script:

···

==============
#! Python
# -*- coding: utf-8 -*-

# with implicit fonts "ďěňřťů" are not displayed properly in the plot title
from matplotlib import rcParams
rcParams['font.family'] = 'sans-serif'
if "Bitstream Vera Sans" in rcParams['font.sans-serif']:
    rcParams['font.sans-serif'].remove("Bitstream Vera Sans")

# after appending the "offending" font even at the end of the list (by
uncommenting the following line), ďěňřťů are not displayed again
# rcParams['font.sans-serif'].append("Bitstream Vera Sans")

import pylab
pylab.title(u"abcd áčďéěíňóřšťúůýž äöüß ê xyz")
pylab.show()

Is there something special in the resolution of the font items in rcParams?
This individual issue seems to be fixed with removing the single font,
but I'd like to understand this more generally, as the installed fonts
on different computers differ.

Thanks in advance
              Vlastimil Brom

Thanks for this Vlastimil, looks like there is either a subtlety beyond my font knowledge or a bug here - mdboom, did you have any ideas? Otherwise I think we need a github issue for this.

Cheers,

···

On 4 January 2014 19:37, Vlastimil Brom <vlastimil.brom@…287…> wrote:

Hi all,

after upgrading to matplotlib 1.3.1, I noticed some display errors on

the plots with regard to accented characters (such as carons etc.).

As I recall, I had similar problem in the past and could work around

them by modifying rcParams, however, this fix doesn’t work as expected

in 1.3.1. (with python 2.7.6, 32bit on Win 7, Czech - with both WXAgg

and TKAgg backends).

From the usual Czech diacritics áčďéěíňóřšťúůýž some are not

displayed (ďěňřťů) - replacement squares are shown instead.

Simply prepending a suitable font at the beginning of the list

rcParams[‘font.sans-serif’] doesn’t help in 1.3.1.

I eventually found out, that “Bitstream Vera Sans” (which is not

installed on this computer) is somehow offending - as long as this

item is in the list (even at the end), the mentioned characters aren’t

displayed.

The problem can be observed in the following simple pylab script:

==============

#! Python

-- coding: utf-8 --

with implicit fonts “ďěňřťů” are not displayed properly in the plot title

from matplotlib import rcParams

rcParams[‘font.family’] = ‘sans-serif’

if “Bitstream Vera Sans” in rcParams[‘font.sans-serif’]:

rcParams['font.sans-serif'].remove("Bitstream Vera Sans")

after appending the “offending” font even at the end of the list (by

uncommenting the following line), ďěňřťů are not displayed again

rcParams[‘font.sans-serif’].append(“Bitstream Vera Sans”)

import pylab

pylab.title(u"abcd áčďéěíňóřšťúůýž äöüß ê xyz")

pylab.show()

==============

Is there something special in the resolution of the font items in rcParams?

This individual issue seems to be fixed with removing the single font,

but I’d like to understand this more generally, as the installed fonts

on different computers differ.

Thanks in advance

          Vlastimil Brom

Rapidly troubleshoot problems before they affect your business. Most IT

organizations don’t have a clear picture of how application performance

affects their revenue. With AppDynamics, you get 100% visibility into your

Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!

http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Thanks for the report.

Indeed, you are correct in that the root of this problem is that "Bitstream Vera Sans" does not contain these characters, yet it is being selected erroneously.

It does appear that there is a bug in the font selection algorithm, that "Bitstream Vera Sans" gets selected as a perfect match even when it is not the first font in the requested list. Vera Sans ships with matplotlib and is the "default fallback font", even though it is not installed as a system font on your computer.

I have a fix here: Fix font family lookup calculation by mdboom · Pull Request #2771 · matplotlib/matplotlib · GitHub

In the meantime, the solution you arrived at is the probably the best we can do for now.

Mike

···

On 01/27/2014 11:21 AM, Phil Elson wrote:

Thanks for this Vlastimil, looks like there is either a subtlety beyond my font knowledge or a bug here - mdboom, did you have any ideas? Otherwise I think we need a github issue for this.

Cheers,

On 4 January 2014 19:37, Vlastimil Brom <vlastimil.brom@...287... > <mailto:vlastimil.brom@…287…>> wrote:

    Hi all,
    after upgrading to matplotlib 1.3.1, I noticed some display errors on
    the plots with regard to accented characters (such as carons etc.).
    As I recall, I had similar problem in the past and could work around
    them by modifying rcParams, however, this fix doesn't work as expected
    in 1.3.1. (with python 2.7.6, 32bit on Win 7, Czech - with both WXAgg
    and TKAgg backends).
    >From the usual Czech diacritics �c(d(�e(�n(�r(s(t(�u*�z( some
    are not
    displayed (d(e(n(r(t(u*) - replacement squares are shown instead.

    Simply prepending a suitable font at the beginning of the list
    rcParams['font.sans-serif'] doesn't help in 1.3.1.
    I eventually found out, that "Bitstream Vera Sans" (which is not
    installed on this computer) is somehow offending - as long as this
    item is in the list (even at the end), the mentioned characters aren't
    displayed.

    The problem can be observed in the following simple pylab script:
    ==============
    #! Python
    # -*- coding: utf-8 -*-

    # with implicit fonts "d(e(n(r(t(u*" are not displayed properly in
    the plot title
    from matplotlib import rcParams
    rcParams['font.family'] = 'sans-serif'
    if "Bitstream Vera Sans" in rcParams['font.sans-serif']:
        rcParams['font.sans-serif'].remove("Bitstream Vera Sans")

    # after appending the "offending" font even at the end of the list (by
    uncommenting the following line), d(e(n(r(t(u* are not displayed again
    # rcParams['font.sans-serif'].append("Bitstream Vera Sans")

    import pylab
    pylab.title(u"abcd �c(d(�e(�n(�r(s(t(�u*�z( ���� � xyz")
    pylab.show()
    ==============

    Is there something special in the resolution of the font items in
     rcParams?
    This individual issue seems to be fixed with removing the single font,
    but I'd like to understand this more generally, as the installed fonts
    on different computers differ.

    Thanks in advance
                  Vlastimil Brom

    ------------------------------------------------------------------------------
    Rapidly troubleshoot problems before they affect your business.
    Most IT
    organizations don't have a clear picture of how application
    performance
    affects their revenue. With AppDynamics, you get 100% visibility
    into your
    Java,.NET, & PHP application. Start your 15-day FREE TRIAL of
    AppDynamics Pro!
    http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
    _______________________________________________
    Matplotlib-users mailing list
    Matplotlib-users@lists.sourceforge.net
    <mailto:Matplotlib-users@lists.sourceforge.net>
    matplotlib-users List Signup and Options

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
                    _

\/|o _|_ _. _ | | \.__ __|__|_|_ _ _ ._ _
>>(_| |(_|(/_| |_/|(_)(/_|_ |_|_)(_)(_)| | |

Many thanks for the fix as well as for the info!
I didn't know, there are built in fonts like this in matplotlib; this
would explain the issue - the character support of Bitstream Vera Sans
is indeed rather limited;
morover the special "defaulting" status of this font hopefully means,
that this shouldn't happen with other fonts, hence, I won't need to
account for other unknown fonts, as I was worried about initially.
Thanks again and regards
   vbr

2014-01-27 Michael Droettboom <mdroe@...86...>:

···

Thanks for the report.

Indeed, you are correct in that the root of this problem is that "Bitstream
Vera Sans" does not contain these characters, yet it is being selected
erroneously.

It does appear that there is a bug in the font selection algorithm, that
"Bitstream Vera Sans" gets selected as a perfect match even when it is not
the first font in the requested list. Vera Sans ships with matplotlib and
is the "default fallback font", even though it is not installed as a system
font on your computer.

I have a fix here: Fix font family lookup calculation by mdboom · Pull Request #2771 · matplotlib/matplotlib · GitHub

In the meantime, the solution you arrived at is the probably the best we can
do for now.

Mike

On 01/27/2014 11:21 AM, Phil Elson wrote:

Thanks for this Vlastimil, looks like there is either a subtlety beyond my
font knowledge or a bug here - mdboom, did you have any ideas? Otherwise I
think we need a github issue for this.

Cheers,

On 4 January 2014 19:37, Vlastimil Brom <vlastimil.brom@...287...> wrote:

Hi all,
after upgrading to matplotlib 1.3.1, I noticed some display errors on
the plots with regard to accented characters (such as carons etc.).
As I recall, I had similar problem in the past and could work around
them by modifying rcParams, however, this fix doesn't work as expected
in 1.3.1. (with python 2.7.6, 32bit on Win 7, Czech - with both WXAgg
and TKAgg backends).
>From the usual Czech diacritics áčďéěíňóřšťúůýž some are not
displayed (ďěňřťů) - replacement squares are shown instead.

Simply prepending a suitable font at the beginning of the list
rcParams['font.sans-serif'] doesn't help in 1.3.1.
I eventually found out, that "Bitstream Vera Sans" (which is not
installed on this computer) is somehow offending - as long as this
item is in the list (even at the end), the mentioned characters aren't
displayed.

The problem can be observed in the following simple pylab script:

#! Python
# -*- coding: utf-8 -*-

# with implicit fonts "ďěňřťů" are not displayed properly in the plot
title
from matplotlib import rcParams
rcParams['font.family'] = 'sans-serif'
if "Bitstream Vera Sans" in rcParams['font.sans-serif']:
    rcParams['font.sans-serif'].remove("Bitstream Vera Sans")

# after appending the "offending" font even at the end of the list (by
uncommenting the following line), ďěňřťů are not displayed again
# rcParams['font.sans-serif'].append("Bitstream Vera Sans")

import pylab
pylab.title(u"abcd áčďéěíňóřšťúůýž äöüß ê xyz")
pylab.show()

Is there something special in the resolution of the font items in
rcParams?
This individual issue seems to be fixed with removing the single font,
but I'd like to understand this more generally, as the installed fonts
on different computers differ.

Thanks in advance
              Vlastimil Brom

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
Pro!

http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
                   _
>\/|o _|_ _. _ | | \.__ __|__|_|_ _ _ ._ _
> >>(_| |(_|(/_| |_/|(_)(/_|_ |_|_)(_)(_)| | |

http://www.droettboom.com

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options