1. 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…


  2. pipeline frontend development

    March 14, 2008 by jerome

    ‘lo, update before uploading the site, finished coding main views.

    pipeline

    pipeline2.jpg