On Sat, Sep 13, 2008 at 4:35 AM, sa6113 <[EMAIL PROTECTED]> wrote:
>
> I want to set all font system to my texts, but I can't set all the fonts. I
> am using this code:
>
> font    = FontProperties(   size='small' ,fname = 'Tahoma'      )
> self.ax.legend(        line,       label,  legend , prop = font )
>
> It raises this error :
> font = FT2Font(str(fname))
> RuntimeError: Could not open facefile Tahoma; Cannot_Open_Resource
>
> Should I add a font family for that before? How?

I doubt that "Tahoma" is the filename, which is what the fname
argument is looking for.  You need to pass a full path (eg a file
ending in .ttf' if you want to explicitly set the font.  Eg::

    import matplotlib.font_manager as fm
    import matplotlib.pyplot as plt

    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot([1,2,3], label='test')

    ax.legend(prop=fm.FontProperties(fname='c:/windows/fonts/tahoma.ttf'))
    plt.show()

But usually you would rather set the font family properties globally,
for example using the rc params setting as in the following::

    from matplotlib import rcParams
    rcParams['font.sans-serif'] = ['Tahoma']
    import matplotlib.pyplot as plt

    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot([1,2,3], label='test')

    ax.legend()
    plt.show()

When you run the scripts, you can pass --verbose-debug to the command
line to get additional information about what fonts are being loaded,
eg

   C:\> c:/python25/python font_family.py --verbose-debug

JDH

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to