New font manager.

First of all, amazing work. It's very impressive that you made so
many changes from the frontend to the backend to the config file and
everything still works!

    > I've committed a new font manager to CVS. It is based on
    > the W3C Cascading Style Sheet, Level 1 (CSS1) design. It is
    > still rather basic, but does seem to work for most of the
    > backends. Therefore, FontTools, ttfquery, and
    > ttf_font_manager are no longer needed by matplotlib.

Excellent to hear - that was a maintenance nightmare. I'll put in an
admin request to finally get those dir trees purged from CVS.

BTW, I added the agg2 tree to CVS so you should be able to build
matplotlib cleanly with a CVS checkout. No need to copy files and
dirs anymore. I also remove gtkgd, which was never more than a
proof-of-concept backend.

    > The font manager currently handle only TrueType fonts, but
    > should be generalizable to other font types.

    > The text object now has a fontproperties attribute which
    > describes the basic aspects of the font, such as family,
    > style, weight and size. This attribute replaces the
    > fontname, fontangle, fontweight, and fontsize attributes.

    > In future, I would suggest using font name sizes, such as
    > small, medium, and large, to specify font sizes, instead of
    > point sizes. This should make it easier for font sizes to
    > be consistent across backends. It will also make it easier
    > to change all the fonts just by changing the default font
    > size that is associated with the medium font name. The
    > default value for this is 12.

    > The other interface issue to be aware of is the font family.
    > This is a list of font names in order of decreasing
    > priority. This should make it easier to match similar fonts
    > across the various platforms.

I printed out the code so I'll take it home and give it a close
reading tonight. Here are a few things I noticed while poking around

* we should cite the ttfquery license since some of font_manager code
   appears to be borrowed from it. I added license/LICENSE_TTFQUERY
   to CVS so you can just refer to that file in the font_manager
   header

* the default file .matplotlibrc in the matplotlib root dir needs to
   be updated with the properties you added to rcParams. With
   comments and commented examples would be most useful. I noticed
   that in the rc params in matplotlib.__init__.py you specify default
   sizes in points rather than relative sizes - what's the logic here?

* Could you write some tutorial and/or user documentation? The two
   most important files are htdocs/fonts.html.template and
   htdocs/backends.html.template. Also, a blurb for "what's new" for
   the next release would be great. It might also be nice to have
   something along the lines of a FAQ "Hey my fonts have changed, how
   can I get the old ones back?" in htdocs/faqs.html.template

* It does not appear you are cacheing the results anywhere. On my
   modern linux system with not so many fonts, I don't notice any
   performance hit. I wonder if this might be a problem for a win32
   user with lots of ttf files and a not so speedy computer.

* I have some concern about the finder algorithm, at least in
   combination with setting a default font in matplotlibrc. Eg, if I
   untar the following dir on my linux system (which contains a lot of
   ttf fonts) http://nitace.bsd.uchicago.edu:8080/files/share/ttf.tar
   and then point to them with my TTFPATH, and set
   text.fontname : Vera in matplotlibrc, I don't get Vera.
   This may be answered by the FAQ above :slight_smile:

Many thanks!
John Hunter

John Hunter wrote:

I printed out the code so I'll take it home and give it a close
reading tonight. Here are a few things I noticed while poking around

* we should cite the ttfquery license since some of font_manager code
   appears to be borrowed from it. I added license/LICENSE_TTFQUERY
   to CVS so you can just refer to that file in the font_manager
   header

I had thought about this and will add it to my to-do list.

* the default file .matplotlibrc in the matplotlib root dir needs to
   be updated with the properties you added to rcParams. With
   comments and commented examples would be most useful. I noticed
   that in the rc params in matplotlib.__init__.py you specify default
   sizes in points rather than relative sizes - what's the logic here?

In my previous message, the active word is 'basic'. I just wanted to get some code in that worked, so you could evaluate and comment on it. Also, I thought it best to make a minimal set of changes initially, since this module affects so many other modules. A large set of changes might have caused lots of problems. In future, I should be able to make more modifications to one or two files at a time.

I haven't had a chance to go through all the code yet to make sure it is all consistent. So the short answer is: I left it as is, because it worked. :slight_smile: This is on my list of things to-do.

* Could you write some tutorial and/or user documentation? The two
   most important files are htdocs/fonts.html.template and
   htdocs/backends.html.template. Also, a blurb for "what's new" for
   the next release would be great. It might also be nice to have
   something along the lines of a FAQ "Hey my fonts have changed, how
   can I get the old ones back?" in htdocs/faqs.html.template

Yes, the user docs are also on my to-do list, but I'll also add the tutorial and FAQ documentation.

* It does not appear you are cacheing the results anywhere. On my
   modern linux system with not so many fonts, I don't notice any
   performance hit. I wonder if this might be a problem for a win32
   user with lots of ttf files and a not so speedy computer.

The issue of cacheing the most recently used fonts had crossed my mind. I'll look into it, particularly for Windows systems.

* I have some concern about the finder algorithm, at least in
   combination with setting a default font in matplotlibrc. Eg, if I
   untar the following dir on my linux system (which contains a lot of
   ttf fonts) http://nitace.bsd.uchicago.edu:8080/files/share/ttf.tar
   and then point to them with my TTFPATH, and set text.fontname : Vera in matplotlibrc, I don't get Vera. This may be answered by the FAQ above :slight_smile:

I'll make sure to describe this issue in the documentation. However, in reply to your comment, it is my opinion that the fontname attribute should be depricated in favor of fontfamily, which is a list of named fonts. The font manager has a preliminary list of recommended font families that the user can use. Vera is one of the named fonts in the 'sans' family, though not high on the list, since there are potentlially nicer fonts that can be used.

The font manager prepends the list of fonts indicated by TTFPATH to the list of system fonts that it finds. So if Vera is in TTFPATH, then it should be available. If not, then I'll look into it.

Please let me know what changes you would like to this module. In the mean time, I'll continue to make modifications.

  -- Paul

···

--
Paul Barrett, PhD Space Telescope Science Institute
Phone: 410-338-4475 ESS/Science Software Branch
FAX: 410-338-4767 Baltimore, MD 21218