Browse Source

Add FontSize property validation (#18198)

* Add FontSize property validation

* Also disallow 0 value for the font size

* Also check for IsInfinity
pull/18206/head
Maxwell Katz 12 months ago
committed by GitHub
parent
commit
355cf162b1
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 3
      src/Avalonia.Controls/Documents/TextElement.cs

3
src/Avalonia.Controls/Documents/TextElement.cs

@ -38,7 +38,8 @@ namespace Avalonia.Controls.Documents
AvaloniaProperty.RegisterAttached<TextElement, TextElement, double>(
nameof(FontSize),
defaultValue: 12,
inherits: true);
inherits: true,
validate: fontSize => fontSize > 0 && !double.IsNaN(fontSize) && !double.IsInfinity(fontSize));
/// <summary>
/// Defines the <see cref="FontStyle"/> property.

Loading…
Cancel
Save