font_manager

I took a look at font_manager.py today and can see that John and Paul have
done a good job but I wonder - is it a case of reinventing the wheel, or
perhaps parallel development?

There is the fontconfig library (written in C) which has very similar
functionality. It works with FreeType, supports W3C CSS2, is used by
Mozilla, pango/gtk+, Qt and is available for Windows, and provides
caching of font information.

Was fontconfig considered when font_manager was written and a decision
made not to use it?

fontconfig seems to have become the standard font config and font matching
method for many systems and applications, should matplotlib consider
using it?
(It would involve creating a Python binding for it, but that should be
possible)

Steve

Steve Chaplin wrote:

I took a look at font_manager.py today and can see that John and Paul have done a good job but I wonder - is it a case of reinventing the wheel, or perhaps parallel development?

There is the fontconfig library (written in C) which has very similar functionality. It works with FreeType, supports W3C CSS2, is used by Mozilla, pango/gtk+, Qt and is available for Windows, and provides
caching of font information.

Was fontconfig considered when font_manager was written and a decision made not to use it?

fontconfig seems to have become the standard font config and font matching method for many systems and applications, should matplotlib consider
using it?
(It would involve creating a Python binding for it, but that should be
possible)

I guess that I wasn't aware of it at the time. I believe (John may want to correct me if I'm wrong) that there was also a desire to have it coded in Python for reasons of simplicity and portability, since in early 2004 MPL was not as mature as it is now and did not contain as much C/C++ code. I see no reason not to use fontconfig if it provides the same functionality as the current font_manager and the wrapper software can be easily done.

What obvious benefits do you see to using fontconfig instead of font_manager? Does it provide access to individual font glyphs? This feature would allow embedded fonts and mathtext to be included in the SVG backend. I guessing that it almost certainly provides unicode support. Anything else?

-- Paul

···

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

I guess that I wasn't aware of it at the time. I believe (John may want
to correct me if I'm wrong) that there was also a desire to have it
coded in Python for reasons of simplicity and portability, since in
early 2004 MPL was not as mature as it is now and did not contain as
much C/C++ code. I see no reason not to use fontconfig if it provides
the same functionality as the current font_manager and the wrapper
software can be easily done.

What obvious benefits do you see to using fontconfig instead of
font_manager?

- speed from being coded in C.
- speed from caching font info, and avoiding the need to traverse the
filesystem reading font filenames and directories.
- fontconfig is widely used, so its code has become well tested and
mature.

- integration with freetype
You could say that fontconfig is a utility designed to help you use
freetype, so if you require freetype (as mpl does) why not use
fontconfig too? Many systems that have freetype installed will already
have fontconfig installed as well.

- consistency with other applications - if you are using gtk+/GNOME,
Qt/KDE, Mozilla or other applications that use fontconfig then using
fontconfig from matplotlib means you are using the same font-matching
library and have access to exactly the same font files as your other
applications.

Does it provide access to individual font glyphs? This
feature would allow embedded fonts and mathtext to be included in the
SVG backend. I guessing that it almost certainly provides unicode
support. Anything else?

Fontconfig does the font-matching and font configuration, to access to
individual font glyphs I think you use freetype directly (after
fontconfig has selected the desired font).

"Font Configuration and Customization for Open Source Systems" written
in 2002 describes the origial design of fontconfig -
http://keithp.com/~keithp/talks/guadec2002/

This is the main fontconfig site http://www.fontconfig.org/wiki/

Steve

···

On Fri, 2005-05-13 at 20:46 -0400, Paul Barrett wrote: