(Talking to myself :) but I hope others read this, too!)
At 08:17 2001-05-09 +0200, Marjolein Katsma wrote:
>I've been running into problems getting and setting correct font sizes.
>Since I'm new to this list, I searched the archives, but could find no
>reference. What I did find was a problem with GetTextExtentPoint32( STRING,
>[FONT] ) reported to always deliver values that were too large. I didn't
>investigate, but it might be related to what I'm seeing.
Well, yes - same problem here as one of the problems I found with fonts: I've
now tested the output of GetTextExtentPoint32( STRING, [FONT] ) and (on my
system) it's too large; the size correction is the same in principle as that
for a Font - screens are often assumed to be 72 pixels per inch - but for PCs
that is actually (supposed to be) 96 pixels per inch. I've compared the output
of the method with actual pixels measured on a screen capture.
Here's what I use to get a Label's actual size in pixels (using the default
font):
# Calculate a label's actual size
sub calc_labelsize {
# NOTE: as with Font size/height, to get the actual size in pixels, the
difference
# between 72 pixels/inch and 96 pixels/inch has to be taken into account
my ($Label) = @_;
my ($lw, $lh) = $W->GetTextExtentPoint32( $Label->Text() );
$lw = int( $lw*72/96+0.5 );
$lh = int( $lh*72/96+0.5 );
return ($lw, $lh)
}
>I don't know if it's platform dependent (I'm working on Win2000 SP1) but I
>hope not: if so, my workaround would not work on other platfoms (Win95/98/ME?).
It works for me on Win2K - I would appreciate if some people could test my
workarounds on other versions of Windows (95/98/me/NT) and report back!
Thanks for any feedback.
Cheers,
Marjolein Katsma
HomeSite Help - http://hshelp.com/ - Extensions, Tips and Tools