Maintaining text size across different Windows Operating Systems

View: New views
2 Messages — Rating Filter:   Alert me  

Maintaining text size across different Windows Operating Systems

by John Whitney-5 :: Rate this Message:

| View Threaded | Show Only this Message

Hello:

My Win32::GUI app has text in the window, and when run on Windows 7, versus
98 or XP, the size of the text in pixels changes.  Is there a way to keep
the text size consistant, pixel wise, across the different operating
systems?  Here is an image showing how it differs, Windows 7 vs Win98...

   http://www.johnwhitney.com/tmp/tmp.jpg

Here is my code for my test program...

#!perl -w
#  Perl text size test 1

use strict ; use warnings ; use Win32::GUI 1.05 qw () ; use constant
G_VERSION => 'Ver 1.1' ;

# Define fonts
my $font1 = new Win32::GUI::Font ( -name => 'Arial'         , -size => 10 )
;
my $font2 = new Win32::GUI::Font ( -name => 'Verdana'       , -size => 10 )
;
my $font3 = new Win32::GUI::Font ( -name => 'Courier New'   , -size => 10 )
;

my $window_main = Win32::GUI::Window -> new ( -title => "Perl text size
tests: " . G_VERSION , -pos => [ 300 , 300 ] , -size => [ 500 , 300 ]
, -background => 0xffffff ) ;

my $window_main_t1 = new Win32::GUI::Label ( $window_main , -text => "Text
1" , -name => 'window_main_t1' , -font => $font1 , -size => [ 100 , 18 ]
, -background => 0xd0d0d0 , -pos => [ 17 , 38 ] ) ;
my $window_main_t2 = new Win32::GUI::Label ( $window_main , -text => "Text
2" , -name => 'window_main_t2' , -font => $font2 , -size => [ 100 , 18 ]
, -background => 0xd0d0d0 , -pos => [ 17 , 58 ] ) ;
my $window_main_t3 = new Win32::GUI::Label ( $window_main , -text => "Text
3" , -name => 'window_main_t3' , -font => $font3 , -size => [ 100 , 18 ]
, -background => 0xd0d0d0 , -pos => [ 17 , 78 ] ) ;

# Add m1...
my $window_main_m1 = new Win32::GUI::Label ( $window_main , -text => ' '
, -name => 'window_main_m1' , -font => $font1 , -size => [ 50 , 18 ]
, -background => 0x808080 , -pos => [  17 , 18 ] ) ;
my $window_main_m2 = new Win32::GUI::Label ( $window_main , -text => ' '
, -name => 'window_main_m2' , -font => $font1 , -size => [ 50 , 18 ]
, -background => 0x909090 , -pos => [  67 , 18 ] ) ;
my $window_main_m3 = new Win32::GUI::Label ( $window_main , -text => ' '
, -name => 'window_main_m3' , -font => $font1 , -size => [ 50 , 18 ]
, -background => 0xA0A0A0 , -pos => [ 117 , 18 ] ) ;
my $window_main_m4 = new Win32::GUI::Label ( $window_main , -text => ' '
, -name => 'window_main_m4' , -font => $font1 , -size => [ 50 , 18 ]
, -background => 0xB0B0B0 , -pos => [ 167 , 18 ] ) ;
my $window_main_m5 = new Win32::GUI::Label ( $window_main , -text => ' '
, -name => 'window_main_m5' , -font => $font1 , -size => [ 50 , 18 ]
, -background => 0xC0C0C0 , -pos => [ 217 , 18 ] ) ;
my $window_main_m6 = new Win32::GUI::Label ( $window_main , -text => ' '
, -name => 'window_main_m6' , -font => $font1 , -size => [ 50 , 18 ]
, -background => 0xD0D0D0 , -pos => [ 267 , 18 ] ) ;

$window_main -> Show () ;

Win32::GUI::Dialog () ;
$window_main -> Hide () ;
exit ( 0 ) ;

John :-)
john@...
801 815 9265




------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@...
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

Re: Maintaining text size across different Windows Operating Systems

by Linda W-7 :: Rate this Message:

| View Threaded | Show Only this Message

John Whitney wrote:
> Hello:
>
> My Win32::GUI app has text in the window, and when run on Windows 7, versus
> 98 or XP, the size of the text in pixels changes.  Is there a way to keep
> the text size consistant, pixel wise, across the different operating
> systems?  Here is an image showing how it differs, Windows 7 vs Win98..
>  

Your only hope is to have the DPI set correctly for each monitor and use
that value to set the character size in point, not pixels.

But starting in Win7, and HTML5, because programmers used pixels all the
time rather than points, the HTML5 designers redefined a pixel to be exactly
1/100th of an inch.  To get at real hardware values you have to look at some
other setting in a browser.  

Win7 has both types of magnification -- one that is XP compat which changes
the DPI number (which most apps ignored), and another which changes the size
of the pixel (which works for all apps, but may cause other problems --
like the
app not fitting on the screen or such.

Providing your Win7 isn't using global magnification -- you might try
getting
at the DPI value...

I grab it in a BASH script on windows with
  dpi=$(regtool -d get '/HKLM/Software/Microsoft/Windows
NT/CurrentVersion/FontDPI/LogPixels')
  # check for insane values
  ((dpi<50||dpi>>400)) && dpi=96
  echo "$dpi"

(I also added some sanity checking in case the number was really weird.

Another thing -- that looks different between the two -- one looks like
it has
LCD font smoothing turned on, (Cleartype), the XP version looks like it
might
be using anti aliasing, or maybe not even that....

I don't know where you can poke at those settings programatically...

Linda


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@...
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/