I'll try out your code (assuming it's tested) Yes, it's well tested standard code. If you want to zoom text, you can configure the font object to use a scaled up
point size. Rebuilding the font, just as you rebuild a new image.
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
require Tk::Font;
#by originally by Chris Lamprecht
my $MAIN = new MainWindow;
my $canvas = $MAIN->Canvas()->pack(-expand => 'yes',
-fill =>'both');
my $initial_fontsize = 24;
my $scaling_factor = 1;
my $l_text = "current scaling_factor : $scaling_factor";
my $helveticaStd = $MAIN->Font(-family=> 'Arial', -size => $initial_
+fontsize);
my $text = 'This is some text';
$canvas->createText(50,50,
-text => $text,
-anchor => 'nw',
-font => $helveticaStd);
$canvas->createRectangle(47,47,290,87);
for my$fac (0.8,1.2){
$MAIN->Button(-text => "Scale by $fac",
-command => [\&scaling,$fac]
)->pack;
}
$MAIN->Label(-textvariable=>\$l_text)->pack;
MainLoop;
sub scaling{
$scaling_factor *= $_[0];
$canvas->scale('all',0,0,$_[0],$_[0]);
$helveticaStd->configure(-size=>$initial_fontsize * $scaling_factor
+);
$l_text = "current scaling_factor : $scaling_factor";
}
__END__
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.