Updated 2007-06-29 13:44:02 by LV

if 0 {Richard Suchenwirth 2002-02-25 - The Tk 8.4a2 port for Windows/CE e.g. on the iPAQ has the bug that the font families command does look up the available fonts (as gets evident when installing a new one), but returns only the first letter of each font name, e.g. T C F B. These abbreviations can however not be used in configuring a Tk widget - instead, the fallback Tahoma is used. So this important introspection feature basically does not work.

As I still wanted to use my installed fonts e.g. in the BWidget font selector, I came up with the following workaround, which overloads the font command to let font families return the hard-coded correct list, while other subcommands are redirected to the original, which was renamed into the tk namespace. The list must of course be manually maintained (check the font selector e.g. in PocketWord).

The code tests whether the renamed command exists already, so does no harm if sourced repeatedly (otherwise the original would be lost, and both font and ::tk::font would contain a copy of the proc below, which, if not called with families, would call itself until the return stack busts).

BWidget appears to cache the font family names, so be sure to source this file before package-requiring BWidget. The screenshot demonstrates that the SelectFont dialog now knows and handles the existing fonts well. Its geometry might still be tweaked to better match the small screen, though... }
 if ![llength [info command ::tk::font]] {
    rename font ::tk::font
    proc font {cmd args} {
       switch -- $cmd {
          f - fa - fam - families {
            list Bookdings {Courier New}\
              {Frutiger Linotype} Tahoma\
              {Bitstream Cyberbit}\
              {MS Gothic} Sorawin
          default {
             eval ::tk::font $cmd $args

RS 2003-03-10: Fixed bug that {Frutiger Linotype} was just called Frutiger and hence not found. Now the font selector shows that it's different from Tahoma, though both are sans-serif.

Arts and crafts of Tcl-Tk programming Category Characters