Choose first available font

EKB This is a little proc to choose the first font in a list that is available on a system, similar to the options in CSS.

 proc firstfont {fontlist default} {
    set avail {}
    foreach f [font families] {
        lappend avail [string tolower $f]
    }
    foreach try $fontlist {
        if {[lsearch $avail [string tolower $try]] != -1} {
            return $try
        }
    }
    return $default
 }

The "default" should be one of the font families that Tk guarantees it will supply a font for on any system (Courier, Times, and Helvetica). Here's an example:

 set fontfam [firstfont {{Palatino Linotype} {Times New Roman}} \
        Times]
 font create body -family $fontfam -size 11
 font create title -family $fontfam -size 16