in reply to font measurement
You need to obtain a TK::Font object for the font you wish to use, then call the measure( $text ) method:
#! perl -slw use strict; use Tk; use Tk::Font; my $mw = MainWindow->new(); for my $name ( 'system' ) { #$mw->fontNames print "Using font $name"; my $font = $mw->fontCreate( $name ); for my $text ( 'The quick brown fox jumps over the lazy dog', 'THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG' ) { printf "$text measures %d pixels\n", $font->measure( $text ); } } __END__ C:\test>junk44 Using font system The quick brown fox jumps over the lazy dog measures 302 pixels THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG measures 409 pixels
See the Tk::Font POD for (a little) more info, then google for more.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: font measurement
by preahkumpii (Novice) on Jan 31, 2012 at 03:12 UTC | |
by BrowserUk (Patriarch) on Jan 31, 2012 at 05:46 UTC | |
by preahkumpii (Novice) on Jan 31, 2012 at 14:25 UTC | |
by BrowserUk (Patriarch) on Jan 31, 2012 at 17:05 UTC |