GUI fonts for different windows versions

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

GUI fonts for different windows versions

Postby jtuchel » Fri Apr 11, 2008 11:03 pm

Hi there,

what do people do in order to have an application deployed on XP and Vista (with theme support) to make it look good on both Windows versions?

Let's start with GUI fonts, before we cover the hard things, like widget placement...
In Vista with Aero enabled, the default font is Segoe UI 9pt, in XP we use MS Sans 9pt to make it look like a native app. (Never mind that users can change the fonts in System settings and VA ST apps won't reflect that - or is there a way to respect such settings?).

How can we change the default fonts for all GUIs at application start time depending on the system we run on?

Those days thigs were a lot easier, when we had packaged different runtimes for Linux and Windows and had different GUI parts for each system. Nowadays, even Windows is pretty different between XP and Vista with/without Aero...

Thanks for any pointers

Joachim
jtuchel
[|]
 
Posts: 245
Joined: Fri Oct 05, 2007 1:05 am
Location: Ludwigsburg, Germany

Re: GUI fonts for different windows versions

Postby crenz » Fri Apr 18, 2008 2:32 am

Maybe
Code: Select all
(OSHfont getStockObject: DefaultGuiFont)
could be a starting point?
Code: Select all
OSWidget class>>#initializeSystemFonts
also seems to play a certain part in setting up the fonts used for the widgets.
crenz
 
Posts: 10
Joined: Tue May 29, 2007 4:56 am
Location: Stuttgart, Germany

Re: GUI fonts for different windows versions

Postby jtuchel » Mon Apr 21, 2008 12:51 am

Chris,

Thank you for the pointers. There are some problems to this: the constant DefaultGuiFont is not defined in a fresh 7.5 image, so I guess you have some application that defines it on load.

It seems like - even though OSWidget class>>#initializeSystemFonts reads as if it does what I want by default - somewhere along the lines of building an ABT layer GUI all these settings get overridden.

I browsed the image and had a look at CgFontStruct, CgDisplay, CgLogicalFontDescription etc. and there are numerous places where the image seems to ask the OS for system fonts. But these requests never answer the font I use as the default font on my windows desktop...

Do you have a working example and could share some code?
cu

Joachim
jtuchel
[|]
 
Posts: 245
Joined: Fri Oct 05, 2007 1:05 am
Location: Ludwigsburg, Germany

Re: GUI fonts for different windows versions

Postby Bob Whitefield » Thu May 01, 2008 8:30 pm

Joachim,

Here's some code to get the Windows dialog font, the one for the "Message Box" item in the Advanced Appearance dialog (Display Properties > Appearance tab > Advanced button):

Code: Select all
   cgFont := OSWidget abtDefaultDialogFont.
   cgFontStruct := cgFont queryFont.
   cwFontList := CwFontList fontStruct: cgFontStruct.

The font list is what CwWidgets need. I haven't tested this on Vista, but would be surprised if it worked any differently.

Here's a method to scale, bold and/or italicize a CwFontStruct, I use this to create different versions of whatever font the user has chosen in Display Properties:

Code: Select all
!CgFontStruct publicMethods !

scaled: scaleFactor bold: isBold italic: isItalic
   "Answer a version of the receiver modified by scaling its point size, and/or changing
   bold and italic attributes. A nil parameter leaves the attribute unchanged."

   | fontDescription wildcardDescription matchingNames |
   fontDescription := self logicalFontDescription.

   (wildcardDescription := CgLogicalFontDescription wildCard)
      fontFamily: fontDescription fontFamily.

   scaleFactor isNil
      ifTrue: [wildcardDescription points: fontDescription points]
      ifFalse: [wildcardDescription points: (fontDescription points asNumber * scaleFactor) rounded printString].

   isBold isNil
      ifTrue: [wildcardDescription weight: fontDescription weight]
      ifFalse: [wildcardDescription weight: (isBold ifTrue: ['bold'] ifFalse: ['medium'])].

   isItalic isNil
      ifTrue: [wildcardDescription slant: fontDescription slant]
      ifFalse: [wildcardDescription slant: (isItalic ifTrue: ['i'] ifFalse: ['r'])].

   matchingNames := CgDisplay default listFonts: wildcardDescription name maxnames: 1.

   ^matchingNames isEmpty
      ifTrue: [self]
      ifFalse: [CgDisplay default loadQueryFont: matchingNames first]! !

Hope that helps,
Bob
Bob Whitefield
[|]
 
Posts: 17
Joined: Thu May 01, 2008 7:41 pm


Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest