1. Friendfeed IM reader quick hack

    May 24, 2008 by pierre

    Tommi recently showed me a service called Friendfeed, it is an rss aggregator for everything that you post on a bunch of online services and your personal rss feeds. It is very well integrated with those services and building a profile is quick. You can then subscribe to other people profile, and see an overview of their updates in a “friends” tab on the main page.

    We were recently discussing about this site with Jérôme and he mentioned that it would be nice to have it in IM, I did a quick search of existing solutions or possibilities.

    Post: there is posting bot provided by imified for Friendfeed.

    Read new posts: you can use an IM feedreader, I tried with inezha.com. Once you have an account on inezha (anothr), you can subscribe to your “friends” activity feed (the feed’s link on Friendfeed is in the page header or at the bottom of the friends tab) and regularly receive IM updates of the content that appears in this feed.

    These are two immediate solutions, it worked ok in a few minutes. The output of inezha.com bot is a bit ascii-arty but I guess it won’t be difficult to have something more minimal for ex. preprocessing the Friendfeed feed in yahoo pipes.

    A more complete solution would be to use the Freindfeed API. There are wrappers in Python and PHP for it. It has a read method (/api/feed/home) for your homepage view (friends updates) and one (/api/share) for creating new entries. I know three python jabber modules, words, based on the twisted framework, and then there is xmpp.py and jabber.py. I think the most lively one is xmpp.py (last updated in 2007). Php has a xmpphp package.


  2. Fontlab 5, Python and Robofab setup

    May 17, 2008 by pierre

    This is a small summary more than a proper “how-to”, about setting up FontLab 5, Python and Robofab on a Mac running OS 10.5. I hope that if your install is not working this might help you.

    Currently FontLab installer will put python 2.3 in your “Frameworks” directory. This is where all python versions should live in a standard setup (/Library/Frameworks/Python.framework/Versions), if you “cd” to this dir you should see python 2.5 there too.

    The path to python version 2.3 seems hardcoded into FontLab 5, there is a note on the FontLab website that explains how to trick it to use 2.4 or 2.5. This is mainly usefull if you are working with python in general and want to use modules that are in your 2.5 install without duplicating them otherwise using 2.3 is fine.

    To install robofab you will need to copy it where python (the version you are using with FontLab) can see it, in other words you need to copy Robofab in python “module search path“: a list of directories that python search for aditional modules to load.

    Currently there are two installers provided with robofab which will do this for you. The first one is a mac installer from Erik van Blokland. The second one is a install.py script that you can get from the current SVN repos.

    If you want to do this manually, find out where python look for modules, either by echoing the PYTHONPATH env. variable, or running this code:

    from distutils.sysconfig import get_python_lib
    print get_python_lib()

    and copy Robofab in the relevant folder. Then you need to restart FontLab and you can try to:

    import robofab


  3. playbill programming

    March 19, 2008 by pierre

    First steps toward Anthony Ellis playbill application (a small text editor that typeset the words typed in the font with the closest matching name - e.g. the word “film” rendered in “filosfia” ).

    Points 1 and 2 below are programming details, point 3 is an example of what we can do now, 4. is what we need to do next.

    1. Interface with the operating system, list all available fonts.

    We can use Objective-C object called NSFontManager and and a method called availableFonts(). Using python’s bridge to Objective-c included in NodeBox.

    from AppKit import NSFontManager
    def fonts():
    	return NSFontManager.sharedFontManager().availableFonts()

    We can now modify this function to make it return a filtered list of fonts name that match a certain string of characters:

    from AppKit import NSFontManager
    def fonts(s):
        return [f for f in NSFontManager.sharedFontManager().availableFonts() if f.lower().startswith(s.lower())]

    2. Find a w[ord]’s first match in the list of font names.

    In python for example, lets say “write()” is an imaginary function that write a string in specified typeface, “fonts()” is the function already defined that take a string and return a list of matching typeface names, and “s” is just a string that we want to typeset.

     

    from string import letters, whitespace, punctuation
    
    s_buff, f_buff = '', ''
    
    for c in s:
        if c in letters:
            s_buff += c
            if fonts(s_buff) != []:
                f_buff = fonts(s_buff)[0]
        elif c in whitespace or c in punctuation:
            write(c)
            write(s_buff, f_buff)
            s_buff, f_buff= '', ''

    We have a small datastructure that contains the two things we are matching, strings and font names (s_buff and f_buff), we then conditionally fill and empty theses buffers as we scan the input string.

    3. Example

    picture-1.jpg

    download the code: playbill-0.txt

    4. Next step

    The next step is to integrate this typesetting process in a small text editor. The text field will need to support multiple fonts in the same field, and it will need to return “key” events that we can use as input stream for what we already programmed. As Jérôme pointed out, another solution is to make an infinite loop in parallel of the editor that “poll” it regularly for new characters.

    In what typeface should we typeset the punctuation? I’m not sure if it is a good idea but we could imagine replicating Anthony idea at the scale of a typeface using glyphs names: you take a punctuation sign name, like “comma”, “dot” and find the closest match in the font list : comma => commic sans, dot => dogma, etc…