font always the same in PNG

Hi all,

I've been trying in vain to get a better font on a plot than the fixed width
serif one that always appears. I've got lib-freetype6 installed (on Ubuntu
server), and ran fc-cache after. The .matplotlib/ttfont.cache contains entries
for the Free* fonts. The fonts themselves are
in /usr/share/fonts/truetype/freefont. The sample code below would seem (to
me) to have used FreeSans, but the png has the same bad looking fixed-serif
font.
When running the matplotlib examples/fonts_demo.py the result is the same font
all over that .png figure too (difference only in sizes).

I usually work on XP, and it all works fine there. Does using only Agg as the
backend make any difference whatsoever?

Paul

ubuntu 7.10
python 2.5
matplotlib 0.90.1

···

----
Some sample code;

import matplotlib
from matplotlib import rc
rc('font',**{'family':'sans-serif','sans-serif':['Arial','FreeSans']})
matplotlib.use('Agg')
from pylab import *

plot(arange(100))
ax=gca()
ax.set(xlabel='Useless',ylabel='Pointless')
draw()
show()
savefig('test')
l=ax.xaxis.get_label()
print 'font prop: ',l.get_font_properties()
print 'font name: ',l.get_fontname()

----
Produces this output;

font prop: (['Arial', 'FreeSans'], 'normal', 'normal', 'normal', 'normal', 12)
font name: FreeSans

The font lookup mechanism has been much improved in 0.91.2 -- you may want to try using that. In 0.90.x, often if you don't get a perfectly exact match for a font, it reverts back to the default "Vera Sans". Vera Sans, however, is not a fixed-width font. Can you provide the png file of fonts_demo.py so I can be sure of what is happening? One way to diagnose this is to do

  rc("verbose", level="debug-annoying")

which will print out a bunch of stuff related to font lookup. Attach the output here and I'll have a look at it to try to figure out what may be going wrong.

Cheers,
Mike

Paul Smith wrote:

···

Hi all,

I've been trying in vain to get a better font on a plot than the fixed width serif one that always appears. I've got lib-freetype6 installed (on Ubuntu server), and ran fc-cache after. The .matplotlib/ttfont.cache contains entries for the Free* fonts. The fonts themselves are in /usr/share/fonts/truetype/freefont. The sample code below would seem (to me) to have used FreeSans, but the png has the same bad looking fixed-serif font.
When running the matplotlib examples/fonts_demo.py the result is the same font all over that .png figure too (difference only in sizes).

I usually work on XP, and it all works fine there. Does using only Agg as the backend make any difference whatsoever?

Paul

ubuntu 7.10
python 2.5
matplotlib 0.90.1

----
Some sample code;

import matplotlib
from matplotlib import rc
rc('font',**{'family':'sans-serif','sans-serif':['Arial','FreeSans']})
matplotlib.use('Agg')
from pylab import *

plot(arange(100))
ax=gca()
ax.set(xlabel='Useless',ylabel='Pointless')
draw()
show()
savefig('test')
l=ax.xaxis.get_label()
print 'font prop: ',l.get_font_properties()
print 'font name: ',l.get_fontname()

----
Produces this output;

font prop: (['Arial', 'FreeSans'], 'normal', 'normal', 'normal', 'normal', 12)
font name: FreeSans

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA