Prev: Hierarchical data structure from a multi-dimensional array
Next: Tk on MacOSX: menu -accelerator issue
From: Gerhard Reithofer on 18 Jul 2010 09:19 On Sat, 17 Jul 2010, Joe English wrote: > Gerhard Reithofer wrote: > > once more I found a tcl script which fails due to new "standard" tk* > > font names. > > > > Example: > > pack [text .t] > > set cfont [.t cget -font] > > .t insert end "Hello World!" > > .t configure -font "$cfont bold" > > > > This works in Tcl 8.4 but fails in Tcl 8.5 with the error message: > > expected integer but got "bold" > > Note that this would also have failed under Tk 8.4 > if (for instance) the user had set something like: > > *Text.font: -adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1 I'm rather sure, that this is no "default font", isn't it? > in the X resource database. > > The recommended way to generate modified versions of other fonts is: > > set newFont [dict replace [font actual $oldFont] -weight bold] > > (or, for pre-8.5 versions, the obvious dict-free equivalent > using [array set] / [array get]) Thanks (also to Aric Bills) for the description how it should be used. > This works no matter how the font was originally specified -- > named fonts, platform-specific fonts, XLFD fonts, "shorthand" > "family ?size? ?style...?" specifications and -option/-value lists. > [set newFont "$oldFont bold"] has always been fragile; it > only used to work by accident. That's what I wanted to hear, thank you. > > The reason is, that 8.4 text default font is "Courier -12" in my > > Linux environment and in 8.5 it's "TkFixedFont" without size value. > > Alternately, if you know you want "Courier -12 bold", you could > just say "Courier -12 bold"... I (personaly) didn't want a specific font but this "buggy method" I've seen several times for switching the "current font" to bold. Thanks for all the answers - I'm more wise again after asking here ;) -- Gerhard Reithofer Tech-EDV Support Forum - http://support.tech-edv.co.at |