Querida web, cual es el equivalente pitónico de fc-match?
$ fc-match "Droid Sans" DroidSans.ttf: "Droid Sans" "Regular"
O inclusive:
$ fc-match "Droid Sans" -v | grep file: file: "/usr/share/fonts/TTF/DroidSans.ttf"
¿Entonces, como hago eso, ir de un nombre de fuente a un archivo de fuente, si no tengo fontconfig?
Encontré código para eso en el módulo font_manager de matplotlib pero parece dificil de separar y requerir matplotlib es demasiado...
Si no hay una solución portable, me alcanza con tres soluciones independientes y prometo publicar una capa de abstracción sobre ellas ;-)
Entonces, queridos pitonistas en windows y mac... ¿alguna pista?
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.