Skip to content

Commit

Permalink
Set correct system font on Windows 8 and higher in JclFont.pas.
Browse files Browse the repository at this point in the history
Changed the logic so that new Windows versions will be assigned the same font as the latest known Windows version.
  • Loading branch information
Wormnest committed Nov 18, 2013
1 parent 8b9cd7b commit 36512aa
Showing 1 changed file with 32 additions and 28 deletions.
60 changes: 32 additions & 28 deletions jcl/source/vcl/JclFont.pas
Original file line number Diff line number Diff line change
Expand Up @@ -49,45 +49,47 @@ implementation
{$ENDIF ~HAS_UNITSCOPE}
JclSysUtils, JclSysInfo;

// Save Windows version that way we will only determine it once here.
// Might be even better if this variable was declared in JclSysInfo since
// it is determined there anyway at startup.
var
WindowsVersion: TWindowsVersion;

procedure SetCaptionFont(const AObjectFont: TFont);
begin
if IsWinVista or IsWinServer2008 or IsWin7 or IsWinServer2008R2 then
begin
case WindowsVersion of
wvWin95..wvWinNT4:
begin
AObjectFont.Name := 'MS Sans Serif';
AObjectFont.Size := 8;
end;
wvWin2000..wvWin2003R2:
begin
AObjectFont.Name := 'Tahoma';
AObjectFont.Size := 8;
end;
else
AObjectFont.Name := 'Segoe UI';
AObjectFont.Size := 9;
end
else if IsWinXP or IsWin2k or IsWin2003 then
begin
// MS Shell Dlg 2
AObjectFont.Name := 'Tahoma';
AObjectFont.Size := 8;
end
else
begin
// MS Shell Dlg
AObjectFont.Name := 'MS Sans Serif';
AObjectFont.Size := 8;
end;
end;

procedure SetContentFont(const AObjectFont: TFont);
begin
if IsWinVista or IsWinServer2008 or IsWin7 or IsWinServer2008R2 then
begin
case WindowsVersion of
wvWin95..wvWinNT4:
begin
AObjectFont.Name := 'MS Sans Serif';
AObjectFont.Size := 8;
end;
wvWin2000..wvWin2003R2:
begin
AObjectFont.Name := 'Verdana';
AObjectFont.Size := 8;
end;
else
AObjectFont.Name := 'Calibri';
AObjectFont.Size := 9;
end
else if IsWinXP or IsWin2k or IsWin2003 then
begin
// MS Shell Dlg 2
AObjectFont.Name := 'Verdana';
AObjectFont.Size := 8;
end
else
begin
// MS Shell Dlg
AObjectFont.Name := 'MS Sans Serif';
AObjectFont.Size := 8;
end;
end;

Expand Down Expand Up @@ -121,4 +123,6 @@ procedure SetObjectFontToSystemFont(const AObject: TObject; const FontType: TFon
end;
end;

initialization
WindowsVersion := GetWindowsVersion;
end.

0 comments on commit 36512aa

Please sign in to comment.