in reply to Huge font in perl Tk

Fixed is a bitmapped font and only supports a few predetermined sizes. It will select the size that is closest to the requested size. The largest size supported seems to be about 70. On my (WinXP) system, once you get above 121, it turns to Helvetica.

Here's a little utility I wrote to mess around with fonts and sizes. Use the up and down arrows to change the size quickly.

#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::BrowseEntry; my $fontname = 'Times'; my $fontsize = 200; my $top = MainWindow->new; my $cframe = $top->Frame->pack(-anchor => 'w'); my $label = $top->Label( -text => 'This is a label', -font => "{$fontname} $fontsize", )->pack; my $sizelabel = $cframe->Label( -text => $fontsize )->grid(-row => 1, -column => 3, -padx => 2); my $fontlist = $cframe->BrowseEntry( -label => 'Font', -browsecmd => sub{ fontconfig($label, $fontname, $fontsize) }, -variable => \$fontname, )->grid(-row => 1, -column => 1, -padx => 8); $fontlist->insert ('end', sort $top->fontFamilies); my $smaller = $cframe->Button( -text => 'Smaller', -command => sub{ $fontsize--; fontconfig($label, $fontname, $fontsize); $sizelabel->configure(-text => $fontsize); }, )->grid(-row => 1, -column => 2, -padx => 2); my $bigger = $cframe->Button( -text => 'Bigger', -command => sub{ $fontsize++; fontconfig($label, $fontname, $fontsize); $sizelabel->configure(-text => $fontsize); }, )->grid(-row => 1, -column => 4, -padx => 2); $top->bind('<Up>' => sub{$bigger->invoke}); $top->bind('<Down>' => sub{$smaller->invoke}); $top->focus; MainLoop; sub fontconfig{ my ($widget, $fontname, $fontsize) = @_; $widget->configure(-font => "{$fontname} $fontsize"); } __END__

Replies are listed 'Best First'.
Re^2: Huge font in perl Tk
by nyk (Novice) on Oct 19, 2005 at 09:07 UTC
    Thanks a lot for this program! It showed me that there are actually 3 fonts on my system that can be scaled to any size: bitstream, luxi and utopia. That's great, so my countdown works now! I could not have found the working fonts without your program!
    I also installed freefonts, but didn't get any more hugely scalable fonts in the font-selector by thundergnat even after restarting X. But those three are enough for me anyway...
Re^2: Huge font in perl Tk
by paulchernoch (Acolyte) on Jul 31, 2009 at 21:21 UTC
    Your test program was very helpful. I am porting a Perl Tk program from MAC to Windows and the fonts were causing me problems.