Version 4 of font

Updated 2001-11-07 16:57:24

http://purl.org/tcl/home/man/tcl8.4/TkCmd/font.htm


This command encapsulates a huge amount of knowledge that's difficult to locate otherwise. The newsgroup thread [L1 ] explains several key points about practices under Microsoft Windows which we'll eventually transcribe here.


Here's how to change a font to italic without having to specify it in full (e.g. if you otherwise want to use the default settings):

 button .b ;# as guinea pig for testing
 array set attributes [font actual [.b cget -font]]
 set attributes(-slant) italic
 set font [eval font create [array get attributes]] 
 .b configure -font $font 

Found by Pat Thoyts in the Tcl chatroom. I think you can even bypass the "font create" bit and directly say

 .b configure -font [array get $attributes] ;# RS

Tk syntax help - Arts and crafts of Tcl-Tk programming

Category Command