Dear Lazyweb, what's the pythonic cross-platform fc-match?
Here's what fc-match does:
$ fc-match "Droid Sans" DroidSans.ttf: "Droid Sans" "Regular"
Or even:
$ fc-match "Droid Sans" -v | grep file: file: "/usr/share/fonts/TTF/DroidSans.ttf"
So, how does one do that, going from a font family name or font name to a font file, where there's no fontconfig?
I found code for this in matplotlib's font_manager module but it looks hard to untangle, and requiring matplotlib is a bit over the top.
If there's no portable solution, I would be happy enough with three standalone solutions instead, and promise to publish an abstraction layer over them ;-)
So, dear windows and mac pythonistas, any pointers?
You need to use PyObjC and NSFont to get an NSFont object from a name, but a cursory search doesn't indicate a way to get a font file from an NSFont object...
That's on OSX, right?
Yes, OSX. Why do you need access to the font files themselves? If you have drawing to do OSX has very nice font mechanisms, perhaps you can use these directly.
I need the file to embed in a PDF.
The closest I can see is this:
http://www.cocoabuilder.com...
Though this probably won't be accessible through PyObjC.
The reason there's no API is that an NSFont instance does not always map to a file (could be mapped to memory, could be in another application bundle) and so on.
Annoying, isn't it? Perhaps you can use Quartz (Core Graphics) to construct the PDF. Then things should work... (Note: I'm not a PDF expert).
Oh, well. I think I found a way for windows, mac users are probably not the target for this app anyway.
De la versión en inglés te quedó un "Or even:"
Gracias Juanjo, corregido!
pygame.font does this (goes from a font name to a filename). A few years back its Linux version was actually calling fc-match in a subprocess.
In windows, I believe you have to scan the registry looking for the font file thats providing your face name.
Which solution did you find for Windows? I'd like to know.
How about this solution which should work for Windows, Mac and Linux?
http://www.seul.org/viewcvs...
This was also suggested by Marius Gedminas, but taking you to the file makes it more easy.
@stani I get a 404.
I did check Marius solution, it's the best so far. I'll try to extract it from pygame in a day or two.