#1881 "font measure" parsed incorrectly

obsolete: 8.4.9

The command

font measure "Courier -12" "-display"

should return the width of the string "-display" in
pixels. Instead, it raises an error, because the string
"-display" is interpreted as the abbreviation of the
optional "-displayof" switch. This is a very
long-standing bug in parsing the "font measure"
command, whose syntax is

font measure font ?-displayof window? text

If the "font" argument is followed by a single string
then the correct behavior should be to interpret that
string as the "text" argument, regardless of what
string was passed to the command.


  • Jeffrey Hobbs

    Jeffrey Hobbs - 2005-03-28
    • priority: 5 --> 7
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2005-03-28

    Logged In: YES

    Tcl varies on whether it tries to parse all options as long
    as -* exists or limits itself when it knows other args
    should exist. This one can easily be limited, so I think
    that change should be made.

  • Jeffrey Hobbs

    Jeffrey Hobbs - 2005-05-31

    Logged In: YES

    The code in generic/tkFont.c is a bit tricky as it abstracts
    the extraction of '-displayof window' outside each function.
    It will have to be extended to know to leave a variable #
    of minimum args.