Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix #2097) PGF: get fonts from fc-list, use builtin fonts for tests #2829

Merged
merged 1 commit into from Apr 17, 2014
Merged

(fix #2097) PGF: get fonts from fc-list, use builtin fonts for tests #2829

merged 1 commit into from Apr 17, 2014

Conversation

pwuertz
Copy link
Contributor

@pwuertz pwuertz commented Feb 21, 2014

Attempt to fix #2097 where font_manager.findSystemFonts() includes matplotlib bundled non-system fonts which are unavailable to latex. Instead, rely on the fonctonfig fc-list tool which is assumed to be present on Linux and OSX systems.
While this is probably safe for Linux, we still have to find out if this is a safe assumption for OSX.

@tacaswell
Copy link
Member

Who are the correct people to ping to get this tested on macs?

@tacaswell tacaswell added this to the v1.4.0 milestone Feb 21, 2014
@tacaswell
Copy link
Member

There are also a number of pep8 violations in this PR (mostly looks like missing spaces after trailing ','s in dicts in the test file).

@pwuertz
Copy link
Contributor Author

pwuertz commented Feb 25, 2014

Fixed pep8 violations and rebased PR on current master.

@tacaswell
Copy link
Member

@efiring @mdehoon I know nothing about OSX, can one of you comment on if this is safe to merge? I am inclined to merge as this seems to fix some cases where it used to be broken and does not sound like it breaks any thing that used to work.

@pwuertz
Copy link
Contributor Author

pwuertz commented Feb 26, 2014

I had another look around and found a few discussions about fc-list not being a standard in OSX, though it is present once X11 is installed.

So, still looking for other options. What about calling native routines?
http://stackoverflow.com/questions/1113040/list-of-installed-fonts-os-x-c

import Cocoa
manager = Cocoa.NSFontManager.sharedFontManager()
font_families = list(manager.availableFontFamilies())

Can we rely on that?

@mdboom
Copy link
Member

mdboom commented Feb 26, 2014

Stepping back, at the end of the day I think what you want is to know what fonts are available to xetex. Is that right? Maybe there's a way to have xetex tell us. (Apologies if I'm out-to-lunch on that suggestion).

@pwuertz
Copy link
Contributor Author

pwuertz commented Feb 26, 2014

@mdboom Exactly, but sadly I didn't find anything useful when I looked into that. There seems to be no way of getting a font-list from xetex itself. Also, there is no uniform way of telling which fonts xetex might find since it simply uses the native methods from whatever OS you are running it on. I found a few stackexchange questions concerning that issue, but eventually fc-list is the best/only answer you'll get.
http://tex.stackexchange.com/questions/12881/how-to-get-a-list-of-all-available-ttf-fonts-with-xetex

luatex on the other hand uses it's scripting engine for font handling, which you can indeed use for getting the list of available fonts.
http://tex.stackexchange.com/questions/14162/how-do-i-get-a-list-of-all-available-fonts-for-luaotfload

So, back to question. I guess we should use the Cocoa module for mimicking what xetex does on OSX, or manually search the default font directories if it is determined that one cannot rely on Cocoa being installed. The most important thing at this point is finding someone with OSX experience and testing capability to comment on all this..

@tacaswell
Copy link
Member

@mdboom @pwuertz Should we merge this or punt?

@mdboom
Copy link
Member

mdboom commented Apr 17, 2014

I think that as this stands, the fonts that matplotlib includes will be no longer included in the font list by default, which is not great, given that many users who install from source expect to have access to the STIX and Bakoma fonts etc.

An alternative here might be to add an additional font cache file based on fc-list that is used by the PGF backend only.

@pwuertz
Copy link
Contributor Author

pwuertz commented Apr 17, 2014

I think this patch is safe to merge, at least for windows and linux it should provide the improvement of not including the matplotlib-shipped fonts, which are unknown to latex. @mdboom please note that this PR only affects the font-lookup within backend_pgf, not the generic matplotlib getSystemFonts function. Furthermore, the pgf unit tests do not depend on system fonts any more and rely on the defaults from the installed latex distribution. Still no clue what will happen to OSX users since we never got any input concerning the presence of fontconfig or the python cocoa bindings.

@mdboom
Copy link
Member

mdboom commented Apr 17, 2014

@pwuertz: Thanks for jogging my memory. If this only affects the PGF backend, then I agree this is fine.

tacaswell added a commit that referenced this pull request Apr 17, 2014
(fix #2097) PGF: get fonts from fc-list, use builtin fonts for tests
@tacaswell tacaswell merged commit c64c73c into matplotlib:master Apr 17, 2014
@pwuertz pwuertz deleted the fix_2097 branch July 9, 2015 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PGF-related test failures on Mac OS-X
4 participants