Skip to content

Commit f148513

Browse files
committed
Update font size checks in Syntax Highlighter preferences
Syntax Highlighter tab of Preferences dialogue box now checks that entered font sizes are within the range of common font sizes and displays an error where they are not.
1 parent cae80a7 commit f148513

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

Src/FrHiliterPrefs.pas

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ implementation
215215

216216
// Error messages
217217
sErrBadFontSize = 'Invalid font size';
218+
sErrBadFontRange = 'Font size out of range. '
219+
+ 'Enter a value between %0:d and %1:d';
218220

219221
const
220222
/// <summary>Map of highlighter elements to descriptions.</summary>
@@ -342,10 +344,24 @@ procedure THiliterPrefsFrame.cbFontSizeChange(Sender: TObject);
342344
Exit;
343345
if TryStrToInt(cbFontSize.Text, Size) then
344346
begin
345-
// Combo has valid value entered: update
346-
fAttrs.FontSize := Size;
347-
UpdatePreview;
348-
fChanged := True;
347+
if TFontHelper.IsInCommonFontSizeRange(Size) then
348+
begin
349+
// Combo has valid value entered: update
350+
fAttrs.FontSize := Size;
351+
UpdatePreview;
352+
fChanged := True;
353+
end
354+
else
355+
begin
356+
TMessageBox.Error(
357+
ParentForm,
358+
Format(
359+
sErrBadFontRange,
360+
[TFontHelper.CommonFontSizes.Min, TFontHelper.CommonFontSizes.Max]
361+
)
362+
);
363+
cbFontSize.Text := IntToStr(fAttrs.FontSize);
364+
end;
349365
end
350366
else
351367
begin

0 commit comments

Comments
 (0)