From 355cf162b1d959e2625330045d1dd230740792a3 Mon Sep 17 00:00:00 2001 From: Maxwell Katz Date: Fri, 14 Feb 2025 17:12:19 -0800 Subject: [PATCH] Add FontSize property validation (#18198) * Add FontSize property validation * Also disallow 0 value for the font size * Also check for IsInfinity --- src/Avalonia.Controls/Documents/TextElement.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Documents/TextElement.cs b/src/Avalonia.Controls/Documents/TextElement.cs index e4e5fb8983..1d02161689 100644 --- a/src/Avalonia.Controls/Documents/TextElement.cs +++ b/src/Avalonia.Controls/Documents/TextElement.cs @@ -38,7 +38,8 @@ namespace Avalonia.Controls.Documents AvaloniaProperty.RegisterAttached( nameof(FontSize), defaultValue: 12, - inherits: true); + inherits: true, + validate: fontSize => fontSize > 0 && !double.IsNaN(fontSize) && !double.IsInfinity(fontSize)); /// /// Defines the property.