Skip to content

Commit 4887bd1

Browse files
committed
Add new methods to get default font sizes.
1 parent a4c927f commit 4887bd1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Src/UFontHelper.pas

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ TFontHelper = class(TNoConstructObject)
8080
@return Handle to cloned font. Caller is responsible for releasing the
8181
handle.
8282
}
83+
class function GetDefaultFontSize: Integer;
84+
class function GetDefaultContentFontSize: Integer;
8385
strict private
8486
const
8587
FallbackFontName = 'Arial'; // Fallback font name
@@ -158,6 +160,32 @@ class function TFontHelper.FontExists(const FontName: string): Boolean;
158160
Result := Screen.Fonts.IndexOf(FontName) >= 0;
159161
end;
160162

163+
class function TFontHelper.GetDefaultContentFontSize: Integer;
164+
var
165+
Font: TFont;
166+
begin
167+
Font := TFont.Create;
168+
try
169+
SetContentFont(Font);
170+
Result := Font.Size;
171+
finally
172+
Font.Free;
173+
end;
174+
end;
175+
176+
class function TFontHelper.GetDefaultFontSize: Integer;
177+
var
178+
Font: TFont;
179+
begin
180+
Font := TFont.Create;
181+
try
182+
SetDefaultFont(Font);
183+
Result := Font.Size;
184+
finally
185+
Font.Free;
186+
end;
187+
end;
188+
161189
class function TFontHelper.IsInCommonFontSizeRange(
162190
const FontSize: Integer): Boolean;
163191
begin

0 commit comments

Comments
 (0)