Permalink
Browse files

Set correct system font on Windows 8 and higher in JclFont.pas.

Changed the logic so that new Windows versions will be assigned the same font as the latest known Windows version.
  • Loading branch information...
1 parent 8b9cd7b commit 36512aa3bc7b62e25607ba119d0747a143d4a40b @Wormnest Wormnest committed Nov 18, 2013
Showing with 32 additions and 28 deletions.
  1. +32 −28 jcl/source/vcl/JclFont.pas
View
@@ -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;
@@ -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.