'''[font actual]''' ''font ?-'''''displayof''''' window? ?option?'' '''[font configure]''' ''fontname ?option? ?value option value ...?'' '''[font create]''' ''?fontname? ?option value ...?'' '''[font delete]''' ''fontname ?fontname ...?'' '''[font families]''' ''?-'''''displayof''''' window?'' '''[font measure]''' ''font ?-'''''displayof''''' window? text'' '''[font metrics]''''' font ?-'''''displayof''''' window? ?option?'' '''[font names]''' ---- http://purl.org/tcl/home/man/tcl8.4/TkCmd/font.htm ---- [LV] What resources are used to determine what fonts are reported by ''fonts families''? Are they hard coded? [[Later]] Apparently not. From looking at Tk source code, the determination of fonts available is (window) system specific. For unix, there are two possible routes taken, depending on whether the [FreeType] support was configured into the system. ---- ''If you want background details on what a font really is, see [Introduction to Fonts].'' ---- The way I understand the above doc and various writing on the subject, the font command is a way to abstract out font information. You create a font ''object'' that then can be used with your various [widget]s. By manipulating the font object, you can influence the fonts used in all widgets using that font object. Does anyone have some sample code that uses the Tk [option] command and font objects to set various widgets? How does one deal with '''language''' issues along with fonts - so that the user can change languages, and the appropriate fonts are used? Are there color objects as well? ---- This command encapsulates a huge amount of knowledge that's difficult to locate otherwise. The newsgroup thread [http://groups.google.com/groups?hl=en&frame=right&th=da7154f3dad32ca9] explains several key points about practices under Microsoft Windows that 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 [KPV] I think you can actually do this in one line: $w configure -font "[font actual [$w cget -font]] -slant italic" ---- A frequently-asked question: how do I specify a default menu (for example) font? The answer: use the [option database], as in option add *Menu.font $my_preferred_font ---- [MG] April 23rd 2004 - A little script that shows an example on all the fonts installed on the computer, in a Tk text widget. Move the mouse over a font to see it's name at the bottom, and click with Button-1 to see an example of the font in bold/italic/underline. Tested in Tcl/Tk 8.4 on Win XP only, but I don't see any reason it wouldn't work elsewhere... package require Tk set typeThis "The quick brown fox jumps over the lazy dog." entry .l -textvariable typeThis -width 30 pack .l button .go -command "go" -text "Go!" -width 6 -underline 0 bind . {go} bind . {go} pack .go proc go {} { global typeThis fontOver bind . {} bind . {} destroy .l destroy .go frame .t pack .t -expand 1 -fill both text .t.t -yscrollcommand {.t.sb set} -undo 1 pack .t.t -side left -expand 1 -fill both scrollbar .t.sb -command {.t.t yview} pack .t.sb -side right -fill y label .l -textvariable ::fontOver set fontOver "Loading Fonts. Please Wait..." pack .l frame .demo pack .demo label .demo.d1 -text "Click a font for a demo" pack .demo.d1 -side left label .demo.d2 pack .demo.d2 -side left label .demo.d3 pack .demo.d3 -side left label .demo.d4 pack .demo.d4 -side left update set i 0 foreach x [lsort [font families]] { .t.t tag configure tag$i -font [list $x 12 {}] .t.t insert end "$typeThis\n" tag$i .t.t tag bind tag$i "set ::fontOver [list $x]" .t.t tag bind tag$i "demoOf [list $x]" .t.t tag bind tag$i {set ::fontOver ""} incr i } set fontOver "" };# go proc demoOf {x} { .demo.d1 configure -text "Font: $x" .demo.d2 configure -text "In Bold..." -font [list $x 12 bold] .demo.d3 configure -text "In Italics..." -font [list $x 12 italic] .demo.d4 configure -text "In Underline..." -font [list $x 12 underline] };# demoOf ---- See also: * [Introduction to Fonts] * [Practical Guide to Choosing Fonts] * [Changing all fonts in an application] * [How does one change the font in the wish widgets] * [font measure] * [font scaling] * [A little font chooser] * "25 Best License-Free Quality Fonts" [http://www.alvit.de/blog/article/20-best-license-free-official-fonts] ---- [Arts and Crafts of Tcl-Tk Programming] [Category Command] - [Tk syntax help] - [Category Characters]