This is the mail archive of the cygwin-apps@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Setup.exe: Font issue


Hi Gary,


Thanks for getting back to me.

"Gary R. Van Sickle" <g.r.vansickle@worldnet.att.net> writes:
> I don't quite follow.  MS Sans Serif claims to be TT, is Shell Dlg
> bitmap or something?  And how would that be affected by dpi anyway?
> Are dialog units actually determined from the dialog's title font?
> (That would not surprise me in the least BTW ;-))

Actually, "MS Sans Serif" is a bitmapped font on my system (with a
limited selection of actual sizes, of course) and "MS Shell Dlg" is an
alias for "Microsoft Sans Serif" here which is a TTF font.

Anyway, Microsoft and the user can create all kinds of confusion in
this area, font mapping is implemented in Windows on several levels
(historical reasons).  Any tweaker tool or new Windows version can use
these abilities at will.

And yes, dialog units are determined by the base font of a dialog
(which is separate from the title font, though).  You probably know
this already, but just to recapitulate: Positioning and size of a
dialog and of the controls on the dialog is measured in dialog units
instead of in pixels, so that it works for different display
resolutions.  In the vertical it's 8 dialog units to the font height
and in the horizontal it's 4 dialog units to the average character
width.  See the docs for GetDialogBaseUnits().

> I'm also doing some runtime font changing stuff too (the bolded
> headers within the pages), so that could come into play here as
> well.

I've seen that, and this should probably be aligned, too.  But it's
not a functional problem AFAICS, because it doesn't change the base
font of the window, but only the font of specific controls.

>Benjamin.Riefenstahl@epost.de wrote:
>> If there is interest I can at least provide the code that I used to
>> check the font that the main window is using and to write that to
>> the log file.
>
> I'm definitely interested in figuring out what's going on here and
> fixing it once and for all.

Attached is the code that I have used to see how the system
synthesizes the property sheet main window.  It parses the details in
the DLGTEMPLATE that is passed in the PSCB_PRECREATE message.


so long, benny

--- propsheet.cc.~2.4.~	2002-05-01 13:13:16.000000000 +0200
+++ propsheet.cc	2003-05-22 17:48:17.000000000 +0200
@@ -18,8 +18,11 @@
 // It's named PropSheet instead of PropertySheet because the latter conflicts with
 // the Windows function of the same name.
 
+#include <iostream>
+
 #include "propsheet.h"
 #include "proppage.h"
+#include "LogSingleton.h"
 
 //#include <shlwapi.h>
 // ...but since there is no shlwapi.h in mingw yet:
@@ -110,12 +113,90 @@
 	if (((LPDLGTEMPLATEEX) lParam)->signature == 0xFFFF)
 	  {
 	    ((LPDLGTEMPLATEEX) lParam)->style |= WS_MINIMIZEBOX;
+
+	    const WORD * more = (const WORD*) (((LPDLGTEMPLATEEX) lParam) +1);
+
+	    // Skip menu resource id.
+	    if( 0xFFFF == *more )
+		more += 2;
+	    else
+		more += lstrlenW((const WCHAR*)more) +1;
+
+	    // Skip window class id.
+	    if( 0xFFFF == *more )
+		more += 2;
+	    else
+		more += lstrlenW((const WCHAR*)more) +1;
+
+	    // Skip window title.
+	    more += lstrlenW((const WCHAR*)more) +1;
+
+	    // Save font size.
+	    int pointsize = *more;
+	    ++more;
+
+	    // Skip font weight and slant.
+	    more += 2;
+
+	    // Get the font name.
+	    char font [100];
+	    WideCharToMultiByte(CP_ACP, 0, (const WCHAR*)more, -1,
+				font, sizeof(font), NULL, NULL);
+
+	    log (LOG_BABBLE) << "PSCB_PRECREATE(EX): font "
+			     << "isset="
+			     << (0 != (((LPDLGTEMPLATEEX) lParam)->style
+				       & DS_SETFONT))
+			     << ", name='" << font << "'"
+			     << ", size=" << pointsize
+			     << endLog;
 	  }
 	else
 	  {
 	    ((LPDLGTEMPLATE) lParam)->style |= WS_MINIMIZEBOX;
+
+	    // Default values
+	    int pointsize = 0;
+	    char font [100] = "<not specified>";
+
+	    if( ((LPDLGTEMPLATE) lParam)->style & DS_SETFONT )
+	      {
+		const WORD * more =
+		  (const WORD*) (((LPDLGTEMPLATE) lParam) +1);
+
+		// Skip menu resource id.
+		if( 0xFFFF == *more )
+		  more += 2;
+		else
+		  more += lstrlenW((const WCHAR*)more) +1;
+
+		// Skip window class id.
+		if( 0xFFFF == *more )
+		  more += 2;
+		else
+		  more += lstrlenW((const WCHAR*)more) +1;
+
+		// Skip window title.
+		more += lstrlenW((const WCHAR*)more) +1;
+
+		// Save font size.
+		pointsize = *more;
+		++more;
+
+		// Get the font name.
+		WideCharToMultiByte(CP_ACP, 0, (const WCHAR*)more, -1,
+				    font, sizeof(font), NULL, NULL);
+	      }
+	    log (LOG_BABBLE) << "PSCB_PRECREATE(NON-EX): font "
+			     << "isset="
+			     << (0 != (((LPDLGTEMPLATE) lParam)->style
+				       & DS_SETFONT))
+			     << ", name='" << font << "'"
+			     << ", size=" << pointsize
+			     << endLog;
 	  }
       }
+
       return TRUE;
     }
   return TRUE;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]