» Help

Code Snippets Database

Control Box
 
 

Requested snippet

This page displays the requested SetVistaFont snippet.

You can choose a category, perform a search or generate a Pascal unit containing the snippet by using the Control Box.

SetVistaFont
Sets a given font to the Vista default font and adjusts the font's size accordingly. Does nothing if (1) the operating system is not at least Vista, (2) default Vista font is not available or (3) the font is already the Vista default font.
procedure SetVistaFont(const AFont: Graphics.TFont);
const
  VistaFont = 'Segoe UI'; // name of main Vista font
begin
  if (SysUtils.Win32MajorVersion >= 6) 
    and not SysUtils.SameText(AFont.Name, VistaFont)
    and FontExists(VistaFont) then
  begin
    AFont.Size := AFont.Size + 1;
    AFont.Name := VistaFont;
  end;
end;
Kind of Snippet: Routine
Required units: SysUtils, Graphics.
Required snippets: FontExists.
Supported Compilers:
 D2   D3   D4   D5   D6   D7  D2005
(Win32)
D2006
(Win32)
D2007 D2009
(Win32)
D2010
(Win32)
Free
Pascal
Red LED Red LED Red LED Grey LED Green LED Green LED Green LED Green LED Green LED Green LED Green LED Red LED
Adapted from code from the article Creating Windows Vista Ready Applications with Delphi.