@@ -19,7 +19,7 @@ interface
1919 // Delphi
2020 Classes, Graphics,
2121 // Project
22- UBaseObjects;
22+ UBaseObjects, UStructs ;
2323
2424
2525type
@@ -45,6 +45,11 @@ TFontHelper = class(TNoConstructObject)
4545 @param List [in] Receives list of font sizes. Cleared before sizes
4646 added.
4747 }
48+ // / <summary>Checks if given font size falls within range of common font
49+ // / sizes.</summary>
50+ // / <remarks>Common font size range is between smallest and largest font
51+ // / sizes returned by ListCommonFontSizes method.</remarks>
52+ class function IsInCommonFontSizeRange (const FontSize: Integer): Boolean;
4853 class procedure SetDefaultFont (const Font: TFont);
4954 { Sets a font to be the default UI font for the underlying operating
5055 system.
@@ -92,6 +97,11 @@ TFontHelper = class(TNoConstructObject)
9297
9398 DefaultMonoFontName = ' Courier New' ; // Default mono font name
9499 DefaultMonoFontSize = 8 ; // Default mono font size
100+
101+ public
102+ const
103+ // Range of common font sizes
104+ CommonFontSizes: TRange = (Min: 7 ; Max: 32 );
95105 end ;
96106
97107
@@ -148,6 +158,12 @@ class function TFontHelper.FontExists(const FontName: string): Boolean;
148158 Result := Screen.Fonts.IndexOf(FontName) >= 0 ;
149159end ;
150160
161+ class function TFontHelper.IsInCommonFontSizeRange (
162+ const FontSize: Integer): Boolean;
163+ begin
164+ Result := CommonFontSizes.Contains(FontSize);
165+ end ;
166+
151167class procedure TFontHelper.ListCommonFontSizes (const List: TStrings);
152168 { Lists all commonly used font sizes.
153169 @param List [in] Receives list of font sizes. Cleared before sizes added.
@@ -157,7 +173,7 @@ class procedure TFontHelper.ListCommonFontSizes(const List: TStrings);
157173begin
158174 Assert(Assigned(List), ClassName + ' .ListCommonFontSizes: List is nil' );
159175 List.Clear;
160- for FontSize := 7 to 32 do
176+ for FontSize := CommonFontSizes.Min to CommonFontSizes.Max do
161177 List.Add(IntToStr(FontSize));
162178end ;
163179
0 commit comments