1

Is there a way to change the default Font for all of the Components on a Form?

In win8, the default "MS Sans Serif" looks thin and washed out. There is a new Font shown just above it in the list and I assume MSoft added it for win8 for some reason. It is called "Microsoft Sans Serif" and is a much cleaner and lightly Bold-ed Font.

I used this link to change the default for Forms, thinking (hoping) that all components would use the Parent-Font, but sadly, no. The only thing that Registry tweak changed was the Title Font for the Form. The body of the Form and thus the components on it are still using the skinny old "MS Sans Serif."

Is there some way to force all components to use the newer Font, other than changing the Form's body-Font every time?

user2566616
  • 103
  • 1
  • 5
  • For Windows 8? Nah. Microsoft Sans Serif, the TrueType font, was added in Windows 2000, and actually *isn't* distributed with Windows 8. – Rob Kennedy Aug 22 '13 at 01:37
  • 2
    http://stackoverflow.com/q/10588660/62576 – Ken White Aug 22 '13 at 01:42
  • Follow Ken's link and read my answer there. In summary, set Application.DefaultFont. – David Heffernan Aug 22 '13 at 08:48
  • 1
    DefaultFont is not available in Delphi 5, which he indicates he is using in his Subject line. – MikeD Aug 22 '13 at 09:45
  • Are you sure the registry setting didn't work? Create a new form and see what font it uses. Perhaps the setting only applies to new forms, which haven't had their fonts set already. For old forms, can't you just set the `Font` property? It should automatically apply to all the other controls, too, except for the ones where `ParentFont` is false. – Rob Kennedy Aug 22 '13 at 12:25
  • @RobKennedy The registry setting is only for creating new forms in the IDE. – Jeroen Wiert Pluimers Aug 22 '13 at 12:29
  • @RobKennedy Umm, try not to be too superior Rob, then how did it get into the list of Fonts in a two-day old copy of win8 on a new laptop? – user2566616 Aug 22 '13 at 14:45
  • @DavidHeffernan Thanks David, but 'Application.DefaultFont' declares an "Undeclared Identifier," error in D5. I assume I add that in the first Form OnCreate event? Is there anywhere I can change the Font in the Form .pas file and rebuild? This is the D5-Ent version with source. – user2566616 Aug 22 '13 at 15:21
  • As others have said, your very old delphi doesn't have DefaultFont. What you should do is make all your forms have a common ancestor. And set the font there. – David Heffernan Aug 22 '13 at 15:23
  • I'm sorry. I didn't read Wikipedia carefully enough before I posted. Microsoft Sans Serif is included with Windows 8, but it's a different version of the font than what came with Windows 2000. Regardless, it's not a *new* font. Windows 2000 used Tahoma, and I think it was Vista that introduce Segoe UI. Consider using one of those instead. Or check out [MS Shell Dlg](http://msdn.microsoft.com/en-us/library/dd374112.aspx). – Rob Kennedy Aug 22 '13 at 16:55
  • @RobKennedy I think that initially Tahoma was only bundled with Office. Somewhere around Windows XP it got bundled with Windows. – Jeroen Wiert Pluimers Aug 22 '13 at 20:40
  • @Jeroen, Wikipedia says it was distributed with Windows 95 and was the default font for Windows 2000. – Rob Kennedy Aug 22 '13 at 21:36
  • @RobKennedy I just checked some of my VMs and some online references. In the pre-Windows 2000 era, Tahoma wasn't part of Windows itself: you needed Office 97+ or the Word 97+ Viewer to get it installed. Some interesting reads http://stackoverflow.com/questions/6057239/which-font-is-the-default-for-mfc-dialog-controls/6057761#6057761 and http://support.microsoft.com/kb/163277. The Microsoft Typography site used to have for each font family a list of products that it was shipped in, but that is broken right now: http://www.microsoft.com/typography/fonts/family.aspx?FID=19 – Jeroen Wiert Pluimers Aug 23 '13 at 07:49
  • Hi sorry @RobKennedy I thought I'd just ask a very similar question here rather than start a new thread. I too have D5 applications and my Sans Serif looks thin and dated on Win7/Win8. I changed to MS Reference Sans Serif which looks bolder and cleaner. However many client PCs don't seem to have this installed as default. What do you guys recommend a best practice future-proofed Font? Thanks – notidaho Sep 30 '13 at 10:19
  • Post a new question, @Notidaho. Your question is not the same as this one; you're not asking how to change the default font of a form. You're asking for font recommendations, and your question really has nothing to do with Delphi. By asking in a comment, your question will be seen by very few people, and nobody can vote on the answers you get. – Rob Kennedy Sep 30 '13 at 13:56

1 Answers1

1

Delphi 5 has no support for the DefaultFont property.

You could work around it by setting the ParentFont property of all your forms and controls to true.

With or without DefaultFont: all fonts in your application (especially Name, Height, and Style) would have to be the same to make this work.

An alternative way to approach your problem is by writing a method that recursively visits all controls, and replaces the Name property of Fonts on Forms/Controls into the name of a font that is installed. This would work in all Delphi versions.

So the answer is yes you can.

Edit: example of how such a method could look like: Font consistency throughout Project?

Community
  • 1
  • 1
Jeroen Wiert Pluimers
  • 23,965
  • 9
  • 74
  • 154
  • 1
    I was not aware that 20th century delphi had no DefaultFont. Without that the way forward is to derive all forms from a common base. – David Heffernan Aug 22 '13 at 13:16