#!perl -w # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' use strict; use vars qw( $loaded $clip $actual ); ######################### We start with some black magic to print on failure. BEGIN { $| = 1; print "1..2\n"; } END {print "not ok 1\n" unless $loaded;} use Win32::GUI; $loaded = 1; print "ok 1\n"; ######################### End of black magic. # -------------------------------------------------------------------------- # Test Win32::GUI::Font::GetMetrics() returning the default system font for # a window created with a custom font size. # # Dan Dascalescu # dandv@users.sourceforge.net # -------------------------------------------------------------------------- # Create a font of a custom height my $win_font = Win32::GUI::Font->new( -name => 'Times New Roman', -height => 23, ); # $win_main should be created with a font height of 23 my $win_main = Win32::GUI::Window->new( -font => $win_font, ); # The Label will inherit $win_main's font my $dummy_label = $win_main->AddLabel(); # Get the height of the $win_main's font my $font = Win32::GUI::GetFont($win_main); # !!! BUG! Returns a wrong font, with a height of 16 my %font_metrics = Win32::GUI::Font::GetMetrics($font); my $win_font_height = $font_metrics{-height}; # print 'Window font height from Win32::GUI::GetFont($win_main): ', $win_font_height, "\n"; # Get the height of the label's font $font = Win32::GUI::GetFont($dummy_label); # this is the correct font %font_metrics = Win32::GUI::Font::GetMetrics($font); my $label_font_height = $font_metrics{-height}; # print 'Window font height from $win_main->GetFont: ', $label_font_height, "\n"; print +($win_font_height == $label_font_height) ? "" : "not "; print "ok 2\n"; # -------------------------------------------------------------------------- # End test # --------------------------------------------------------------------------