console -font?

Zipguy (2012-08-21) - I was getting a little blind after I've been using TCLkit for a while, on Windows. You can find out my email address by clicking on Zipguy. That's because I'm on a laptop which has a large screen, is pretty cheap and works great. But the font was smaller in TCLkit vs Wish.

I've been creating TCL programs, mostly starkits, and working on them. What was really annoying was the tclkit I've been using, tclkit-8.5.8.exe, and sdx. It's console has a really small font as it appears on my screen.

Here's the built in console in full blown Wish:

http://www.geocities.ws/thezipguy/tcl/console/console_wish.jpg

and here's the console in tclkit-8.5.8.exe:

http://www.geocities.ws/thezipguy/tcl/console/console_starkit.jpg

So I was right, it did have a smaller font. I poked around in the manual, wiki, and found this in console under discussion:


2005-04-23 Derek Peschel Evidently the discussion goes here and the code goes on the console for UNIX page. See my questions in Ask, and it shall be given # 2. I've put these items here because they aren't questions.

Brian Theado and I and maybe others have changed the console for UNIX script as part of the TkOutline project [L1 ]. After someone helps answer two questions I have, I think the changes should be propagated back here. They are:

  1. The script has a few more comments. I also changed the punctuation of the comments for no other reason than personal taste.
  2. It uses the $_ variable when evaluating the library console.tcl file as well as when checking it for readability. I changed the name of the library file (so I could have my own version with a bigger font) and wasted some time wondering why my changes weren't being read.
  3. Maybe more; I haven't looked in detail.

Brian Theado - I'm pretty sure my console.tcl code is verbatim from console for UNIX--I've made no changes to it. I don't think anyone would object to enhancing the comments in the code on that page.

As mentioned in private email, I recommend against having your own copy of the library console.tcl and instead use the [console eval] command to get access to the console's interpreter and change the font. i.e.

 console eval {.console configure -font {Courier 14}}

This is a one liner that lets you increase the size of your font! I didn't know this, nor how to do this, but it does work great.

Thank you Brian Theado and Derek Peschel!

I changed it to this, now that I found how to do this.

 console eval {.console config -font {{Courier New} 9} }

and it looks like this:

http://www.geocities.ws/thezipguy/tcl/console/console_starkit_font.jpg

Which is a lot more like Wish's full blown than this

http://www.geocities.ws/thezipguy/tcl/console/console_starkit.jpg

I thought it might make others happier to know about this, and thus this page.


RLE (2012-08-22): On the windows tclkit's I've been using, the "Edit" menu on the console contains two entries, "increase font size" and "decrease font size" that perform the corresponding operation when selected. Does your windows tclkit lack these two menu entries?

Zipguy (2012-08-23) - I've been using a file I copied and shortened the name from tclkit-8.5.8-win32-x86_64.exe to to tclkit-8.5.8.exe because I use it in Windows "Properies" for "Shortcut"s. I got the tclkit from this wiki, from SDX -> http://www.equi4.com/pub/sk/sdx.kit -> http://code.google.com/p/tclkit/downloads/list , where I downloaded tclkitsh-8.5.8-win32-x86_64.zip, which I unzipped and have been using it. I also have a 8.5.9 version but haven't unzipped it, nor looked at it yet because 8.5.8 works good.

I never looked in the "Edit" menu on the console because it is so simple and almost never changes. I did look, in my tclkit-8.5.8.exe, and it does have it there! Thanks RLE

http://www.geocities.ws/thezipguy/tcl/console/console_edit_tclkit.jpg

Wish's full blown console does not have it:

http://www.geocities.ws/thezipguy/tcl/console/console_edit_wish.jpg

How come no one has said anything about this? I like it. So I tried it and it didn't work!

I did figure out why, so I made a change, and it did work. What I did was I commented out the line that this page is about!

 console eval {.console config -font {{Courier New} 9} }

Now I feel real stupid for looking for it when it was under the "Edit" menu all the time, and wasting time looking elsewhere. Even worse, if you do change it by the line above, then it becomes somehow locked.

I wish you could use the line above, or something like it, without causing the "Edit" menu font functions to stop working.

If you could, that would be great, because you could change it to a size setting that is better than stock, for most people rather than the default size in tclkit, then they could re-size the font to their hearts delight. Going to try some things.


RLE (2012-08-23): Just checked with one of my Windows tclkits (an 8.6b1 package) and if you change the font this way:

 console eval { font configure TkConsoleFont -size 12 }

Then the "Edit" menu entries continue to work. To see what font face is in use, do:

 console eval { font actual TkConsoleFont }

And using font configure you can change any of the properties of the font, and the "Edit" menu still functions.

Zipguy (2012-09-07) - I love your change! Thank You RLE! It works flawlessly. You can still adjust the size of the font. I happen to like it at

    console eval { font configure TkConsoleFont -size 10 }

which makes it a little bit bigger than -size 8, but the user can resize it to whatever they want. Here's what it looks like:

http://www.geocities.ws/thezipguy/tcl/console/console_modified.jpg

instead of:

http://www.geocities.ws/thezipguy/tcl/console/console_stock.jpg

The thing that is a little wierd is that it says above that the family is "Consolas" which means it's Spanish? Doesn't matter.

Don't know where you found TkConsoleFont in, but I love it and thanks again RLE.

RLE (2012-09-07): I found it by doing: "console eval { font names }" and looking through the list of font names that came back. TkConsoleFont stood out as an obvious item to test at that point.

"Consolas" is the name of a font shipped with recent Windows systems (I do not know when it was added). It happens to be what the console code chooses for its font family if it finds it available on a Windows system.


SeS (2012-08-24): To my surprise, this 'console eval' command is also able to handle bindings...this enables some more possibilities: If one is really in a hurry, one could change the font-size on-the-fly with the Control-key and Mousewheel (aka webbrowser style and also as implemented in the Source Editor of tG² v1.06.01.42 ):

console eval {
  bind .console <Control-MouseWheel> {
    set fnt [.console cget -font]
    switch [llength $fnt] {
      "1" {set style ""; set size 10}
      "2" {set style ""; set size [lindex $fnt 1]}
      "3" {set style "[lindex $fnt end]"; set size [lindex $fnt 1]}
    }
    if {%D>0} {
      if {($size+1)<=19} {
        .console configure -font "{[lindex $fnt 0]} [expr {$size+1}] $style"
      }
    } {
      if {($size-1)>=5} {
        .console configure -font "{[lindex $fnt 0]} [expr {$size-1}] $style"
      }
    }
  }
}

note: tested on ActiveState ActiveTcl 8.4.19.3 wish console, Win7 OS.


RLE (2012-08-24): Another variant of <MouseWheel> font sizing (uses no global variables, but requires Tcl 8.5+ for the apply command):

console eval {

  bind .console <Control-MouseWheel> { apply { {w} {
    set font [ $w cget -font ]
    set size [ expr abs([ font configure $font -size ]) ]
    expr { %D > 0 ? [incr size] : [incr size -1] }
    font configure $font -size [ expr max(5,min(19,$size)) ]
  } } %W } 

}

Zipguy (2013-03-03) - I tried asking the font size by

  console eval { font actual TkConsoleFont }

above, then I got the font real small, in fact ridiculously small, and back to a good size.

The good size is presented below:

http://www.geocities.ws/thezipguy/misc/console_nice_size.png

and the ridiculously small size is given for example also:

http://www.geocities.ws/thezipguy/misc/console_ridiculous_size.png

Too small to read, even with a magnifying glass (for you phone people). No smoke and mirrors here. I did it by using "Control_-" and "Control_+", which are over on the right hand side of the keyboard (in the numeric pad area). Also I used the down arrow, once I'd typed in the command, to call it back, and the return key to run it again.

You can see that the -size was as low as 1 (as seen above), and the -size that I like was 10.

What if you ask for an even smaller size? I tried that also. It goes back to -size 12. It did that above. You can see that I used the command 16 times. :)