in reply to font measurement
See Re: Tk: Set text size in a widget and "perldoc Tk::Font" and "perldoc Tk::X11Font", but using the Canvas is always a good bet.
I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = new MainWindow; $mw->fontCreate('big', -family=>'arial', -weight=>'bold', -size=> 28 ); my $c = $mw->Canvas(-bg=>'white')->pack; #---determine font spacing by making a capital W--- my $fonttest = $c->createText(100,100, -fill => 'black', -text => 'W', -font => 'big' ); my ($bx,$by,$bx1,$by1) = $c->bbox($fonttest); $c->{'f_width'} = $bx1 - $bx; $c->{'f_height'} = $by1 - $by; print 'width ',$c->{'f_width'},' ',$c->{'f_height'},"\n"; MainLoop;
I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: font measurement
by preahkumpii (Novice) on Jan 30, 2012 at 15:47 UTC | |
by zentara (Archbishop) on Jan 30, 2012 at 17:58 UTC |
In Section
Seekers of Perl Wisdom