SourceForge logo
SourceForge logo
Menu

Re: [matplotlib-devel] New font manager.

From: Paul B. <ba...@st...> - 2004年03月18日 21:14:44
John Hunter wrote:
> 
> I did a little more experimenting; I think some of the problems I was
> having yesterday were from residual effects of text.fontname. To
> clarify and simplify, I removed text.fontname from matplotlibrc and
> matplotlib.__init__ rcParams. The ttf_microsoft fonts referred to
> below are in the ttf.tar file referred to earlier; the results below
> show my matplotlibrc entry and the filename returned by findfont
> 
> # ok, verdana san serif
> font.family : san-serif /home/jdhunter/src/ttf_microsoft/verdana.ttf
> 
> # ok this is a serif font
> font.family : serif /usr/X11R6/lib/X11/fonts/TTF/luxirr.ttf
> 
> # what's happening here? fail silently? cour.ttf is in ttf_microsoft
> font.family : Courier /home/jdhunter/src/ttf_microsoft/verdana.ttf
Yes, the current behaviour is to fail silently. Let me know if you want this 
changed.
You are correct that Courier is one of the available fonts. However, the actual 
font name (from the font file) is 'Courier New'. The list of fonts that I have 
suggested for font family has both names listed, 'Courier New' and 'Courier', 
for this reason. From my reading of the CSS1 document there is no easy way to 
distinguish between different font families, except by an explicit list of font 
names.
> I think the ability to define a family and let the system choose the
> best match is good, but there are cases where this may not be
> desirable.
> 
> * If you are an application developer and want your app to look just
> the same across platforms, you may distribute it with a font file
> and you want to make sure that file is chosen. 
In this case the user or developer should provide his own font family list, e.g. 
['Vera', 'sans-serif']. If Vera is always supplied with the application, then 
it will be found first, before the default 'sans-serif'. However, in the case 
where, for some reason, it could not be found, the default font will be used.
> * The majority of users will probably be more familiar with the names
> Courier and Times than with font families monospace and serif.
> Should we provide a mechanism so that users can specify fonts this
> way? Eg, you may know you have Courier on your system and you
> don't care about portability. Is there a way in the current setup,
> for example, a user who wants to specify Courier?
Courier and Times are listed in the sans-serif font family. However, they are 
currently not very high on the list though.
I suppose there are two ways to handle this. One is to expose the font families 
that comes with matplotlib. The user can then just say use the 'sans-serif' 
font family for my text. The second way is to use set_fontname() to prepend the 
specified font to the font family, so that it is always found first during the 
search.
> For the first of these two cases, one idea is to allow a user to
> specify a filename
> 
> font.family = Vera.ttf # search path for Vera.ttf
> 
> Users who distribute apps with matplotlib and want a guaranteed font
> (such as myself!) can use one of the fonts that are distributed with
> matplotlib and rely on the normal environment vars (MATPLOTLIBDATA and
> TTFPATH) to provide the dirs those fonts will reside in. Since no
> legitimate family name or font name will match the pattern *.ttf, we
> can safely do this. What do you think? If this is not sufficiently
> elegant, we could consider font.file as an additional attribute which
> defaults to None.
As previously noted all files found in TTFPATH are prepended to the list of 
system fonts, so they should be accessible. I think that the issue is the use 
of a personal version of the font family that specifies your prefered fonts, so 
that they are searched first. I would think that the font.family variable in 
matplotlibrc could be used to override those supplied by the application at 
start-up. Interactively, font family can be changed by supplying a list of font 
names to FontProperties.set_fontfamily().
The font family list that I have supplied is only a suggestion, so you may want 
to change it at this point.
> For the second of the two cases, I'm not sure....
> 
> So fontname plays no legitimate role anymore?
Not currently, but it can, as I suggest above.
> On an unrelated note, I don't think we need any of fontname,
> fontstyle, fontangle, fontvariant or fontweight in the Text __init__
> method, but we should preserve the getters and setters as discussed
> earlier for user interface compatibity (the __init__ function is not
> in the user interface but the text methods are).
Good, I change that.
 -- Paul
-- 
Paul Barrett, PhD Space Telescope Science Institute
Phone: 410-338-4475 ESS/Science Software Branch
FAX: 410-338-4767 Baltimore, MD 21218

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /