What are SYSTEM_FONT and DEFAULT_GUI_FONT?


Among the things you can get with the GetStockObject function are two fonts called SYSTEM_FONT and DEFAULT_GUI_FONT. What are they?

They are fonts nobody uses any more.

Back in the old days of Windows 2.0, the font used for dialog boxes was a bitmap font called System. This is the font that SYSTEM_FONT retrieves, and it is still the default dialog box font for compatibility reasons. Of course, nobody nowadays would ever use such an ugly font for their dialog boxes. (Among other things, it's a bitmap font and therefore does not look good at high resolutions, nor can it be anti-aliased.)

DEFAULT_GUI_FONT has an even less illustrious history. It was created during Windows 95 development in the hopes of becoming the new default GUI font, but by July 1994, Windows itself stopped using it in favor of the various fonts returned by the SystemParametersInfo function. Its existence is now vestigial.

One major gotcha with SYSTEM_FONT and DEFAULT_GUI_FONT is that on a typical US-English machine, they map to bitmap fonts that do not support ClearType.

Comments (22)
  1. stock says:

    I think a lot of people use DEFAULT_GUI_FONT after creating their windows with CreateWindowEx.

  2. Mike J says:

    What the Font used in XP for GUI ?

  3. AC says:

    But what font should one use?

    lfMessageFont you get from SPI_GETNONCLIENTMETRICS?

  4. Adrian says:

    That sound you just heard was my jaw bouncing off my keyboard. DEFAULT_GUI_FONT seemed the best way to get an appropriate font regardless of the locale and version of Windows in use. So by the late 1990s, when I first discovered DEFAULT_GUI_FONT and started using it far and wide, it had already been deprecated for several years!?

    Even though the documentation for GetStockObject has been updated for each version of Windows since, the explanation of SYSTEM_FONT is still wrong.

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_1t10.asp

    And as long as somebody is in there fixing the docs for SYSTEM_FONT, it would be nice if they’d indicate the deprecated status of DEFAULT_GUI_FONT and point us poor programmers to SystemParametersInfo SPI_GETNONCLIENTMETRICS, assuming that’s now the "right" place to go for a font that matches the one used by the system.

    Now I’ve gotta go fix some code…

  5. Yes I filed doc correction request for that page.

    The phrase "the font used by the system" is underspecified. As you can plainly see, the system uses several fonts. There’s the menu font, the icon label font, the caption font, the message box font, the status bar font, multiple dialog box fonts… Choose the font for what you want.

  6. Kevin Dente says:

    Unfortunately, it seems no one told the original .NET team – they used DEFAULT_GUI_FONT for the standard Windows Forms dialog font, which results in apps that look wrong when run on XP (don’t use Tahoma). And they still haven’t fixed it in 2.0 – I blogged about it.

    http://weblogs.asp.net/kdente/archive/2005/03/13/394499.aspx

  7. stock says:

    Please tell us which font we should use for child-windows.

  8. I can’t tell you; your question is still too vague. What is your child window being used for? If your child window is a status bar, use the status bar font. If it shows icons or a list of items, use the icon label font. If it’s a dialog, use one of the dialog box fonts. If it’s none of the above, then you get to decide for yourself whether your scenario matches one of the scenarios covered by the system fonts or is something entirely different and deserves its own special font. Clearly no single rule for fonts will cover all programs. (Maybe you’re a mapping program and need fonts at different sizes depending on the population of the city you are labelling.)

  9. stock says:

    I mean for example a simple button like Ok or Cancel!

    I think the dialog box fonts would be right! But how can i retrieve them? Its not in NONCLIENTMETRICS.

  10. If you want it to look like a dialog box button, then use a dialog box font. I discussed dialog box fonts earlier this year.

  11. mike says:

    I’ve read the articles about dialog boxes. But is there a way (that preferrably works on all versions of windows) to find out the name of that dialog font used when DS_SHELLFONT is set (without using dialog boxes)?

  12. You shouldn’t care what the name is. Just create MS Shell Dlg (or Dlg 2) and let it decide. If you really want to know the name, see the MSDN documentation for MS Shell Dlg.

  13. MSDN Article "MS Shell Dlg" starts from:

    "MS Shell Dlg is a mapping mechanism that enables U.S. English Windows to support locales that have characters that are not contained in code page 1252…."

    (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_4qcn.asp)

    I’ve found this article a bit scarry as e.g. we are sitting in Canada at it seems that MS Shell Dlg is not for us :)

    I am using DEFAULT_GUI_FONT in

    Harmonia Framework

    http://www.terrainformatica.com/wiki/pmwiki.php?pagename=Harmonia.Harmonia.

    to retrieve exactly "default GUI font".

    I did not find more reliable way to retrieve dialog font from the system (Win95..WinXP).

    My intention is to use as much OS agnostic code as possible so I would like to avoid

    ( os >= WinXP )? "MS Shell Dlg 2":"MS Shell Dlg" …

    Andrew.

  14. MSDN Article "MS Shell Dlg" starts from:

    "MS Shell Dlg is a mapping mechanism that enables U.S. English Windows to support locales that have characters that are not contained in code page 1252…."

    (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_4qcn.asp)

    I’ve found this article a bit scarry as e.g. we are sitting in Canada at it seems that MS Shell Dlg is not for us :)

    I am using DEFAULT_GUI_FONT in

    Harmonia Framework

    http://www.terrainformatica.com/wiki/pmwiki.php?pagename=Harmonia.Harmonia.

    to retrieve exactly "default GUI font".

    I did not find more reliable way to retrieve dialog font from the system (Win95..WinXP).

    My intention is to use as much OS agnostic code as possible so I would like to avoid

    ( os >= WinXP )? "MS Shell Dlg 2":"MS Shell Dlg" …

    Andrew.

  15. A says:

    Just create MS Shell Dlg (or Dlg 2) and let it decide.

    There are two problems with the CreateFont(…, "MS Shell Dlg") approach:

    – The "MS Shell Dlg" mapping doesn’t exist on some Far East editions of Windows (e.g. Japanese Windows 98).

    – On systems where the "MS Shell Dlg" mapping does exist, you don’t know the correct point size to pass when creating the font. (Hard-coding 8 produces less-than-ideal results on Far East editions of Windows.)

    GetStockObject(DEFAULT_GUI_FONT) doesn’t suffer from these problems. However, as noted previously, it won’t return Tahoma on 2000/XP.

    • "However, as noted previously, it won’t return Tahoma on 2000/XP."

      Yep, but:

      LOGFONT lf;

      ::GetObject(::GetStockObject(DEFAULT_GUI_FONT),sizeof(lf),&lf);

      returns "MS Shell Dlg" in font name field and valid font size on WinXP.

  16. jfo's coding says:

    It all stems back to a rather unfortunate implementation of Control.DefaultFont.   Raymond…

  17. And people wonder why user interface consistency is so difficult to achieve….. What are SYSTEM_FONT and DEFAULT_GUI_FONT. In everything I’ve produced, software wise, I’ve at least tried to keep a consistent look and feel from window to window, with particular…

  18. You don’t want to ever use DEFAULT_GUI_FONT. Just like the thread locale, AVICAP32.DLL, and SetLocaleInfo,…

  19. Last time around, I suggested, "Let’s see if I can talk about something other than rendering text next…

  20. When you call the WM_GETFONT message to get the font from a control, the documentation says: The return

Comments are closed.

Skip to main content