1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

getting font list from MacOS

Posted by Giorgio on Mar 15, 2007

Hello again,

Is there a way to dinamically populate a list with all the active fonts on a given system?
I use FontExplorer to activate fonts... Do you think is gonna be a problem?

The idea is to try to produce a range of font 'treatments' and to quickly check the results on wide variety of fonts. From the moment that I was told that this kind of stuff it's possible with Nodebox I stopped struggling with Processing trying to achieve the same goal with 100 times the effort. Really thanks for this terrific project.

ciaociao
Giorgio



Posted by Mark on Mar 16, 2007

Giorgio,

I'm not sure if PyObjC is installed by default with OS X these days, but I think it is. If it is, you can access all sorts of goodness including the font manager.

This does what you'd expect when I run it in nodebox

size(800, 800)
fontsize(18)
 
from AppKit import *
fontManager = NSFontManager.sharedFontManager()
 
fonts = fontManager.availableFonts()
# fonts is now a list with the names of all the fonts
 
for i in range(10):
     # I only want the first ten since I have alot of fonts installed 
    font(fonts[i])
    text(fonts[i], 10, 40*i)


Hope this works for you.



Posted by Giorgio on Mar 16, 2007

Hello Mark,

Perfect, it works!

Really Thanks
ciao




Posted by Tom De Smedt on Mar 16, 2007

AppKit is bundled in the NodeBox download.



Posted by Fabio on Mar 16, 2007

interesting!
I didn't figure out this sort of integration.



Posted by Tom De Smedt on Mar 16, 2007

Yes, you get AppKit and Foundation (and Numeric) for free.
So you can basically access anything from CIImage to NSSpeechRecognizer... let me see if I can whip up some good PyObjC examples...



Posted by Fabio on Mar 16, 2007

Tom, it would be great!



Posted by Tom De Smedt on Mar 17, 2007

There are some examples in the tutorial:
http://nodebox.net/code/index.php/PyObjC