Tk Source Code

View Ticket
Login
Ticket UUID: 1171961
Title: "font measure" parsed incorrectly
Type: Bug Version: obsolete: 8.4.9
Submitter: nemethi Created on: 2005-03-28 17:02:35
Subsystem: 44. Generic Fonts Assigned To: hobbs
Priority: 7 High Severity:
Status: Closed Last Modified: 2026-10-22 17:22:34
Resolution: Duplicate Closed By: serhiy.storchaka
    Closed on: 2026-09-24 18:58:48
Description:
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.
User Comments: serhiy.storchaka added on 2026-09-24 18:58:48:

Duplicate of [1833775fff], fixed in 8.5.0 by [9ba3de8465]: -displayof is only recognized when there are enough arguments. Tests font-9.6 and font-9.7.


hobbs added on 2005-05-31 10:55:33:
Logged In: YES 
user_id=72656

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.

hobbs added on 2005-03-29 01:22:15:
Logged In: YES 
user_id=72656

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.