[cairo] Postscript fonts

David Goldenberg goldenberg at biology.utah.edu
Thu May 3 15:29:15 UTC 2018


Eric,
    Thanks very much for your reply, and your compliment regarding the diagram on the front of my book.  That diagram and a very large number of similar ones in the book were created using Perl scripts that I wrote to directly write PostScript files.  What I am doing now is trying to put together a Python module that will do the same thing more elegantly, with the idea of eventually distributing it. Cairo seems to be a good way to do that.

I am using a Mac, and, though it is a Unix flavor underneath, it doesn’t have a /usr/share/fonts directory. From my limited searching and experimenting, the functionally equivalent directory is /System/Library/Fonts.  This contains the fonts that are critical for the OS. Of the fonts that are in this directory, only those with the extension .dfont seem to work with Cairo.  These are “data-fork” fonts, as explained here:
http://www.peachpit.com/articles/article.aspx?p=31702&seqNum=9

The ones that are available (at least on my system, macOS 10.13) are:
Courier.dfont		Helvetica.dfont		Monaco.dfont
Geneva.dfont		HelveticaNeue.dfont	Times.dfont

I also found this at http://pycairo.readthedocs.io/en/latest/reference/context.html#cairo.Context.select_font_face
which says:

> Cairo provides no operation to list available family names on the system (this is a "toy", remember), but the standard CSS2 generic family names, ("serif", "sans-serif", "cursive", "fantasy", "monospace"), are likely to work as expected.

Indeed these family names seem to work as expected.

Figuring out how to actually use these names, and other font attributes, took some more digging and fooling around, but I think that I am almost there.  The toy API will be fine for my purposes.

Thanks again,
David


--
Department of Biology
University of Utah
257 South 1400 East
Salt Lake City, UT  84112-0840

Telephone: (801) 581-3885
Fax:  (801) 581-2174

E-mail: goldenberg at biology.utah.edu
Web page: http://goldenberg.biology.utah.edu



More information about the cairo mailing list