From 96b423900f734c698932534dacefd59827557470 Mon Sep 17 00:00:00 2001 From: Julien Lebosquain Date: Mon, 16 Jan 2023 11:50:14 +0100 Subject: [PATCH] TextRunProperties: don't allocate if the typeface hasn't changed --- src/Avalonia.Base/Media/TextFormatting/TextRunProperties.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Avalonia.Base/Media/TextFormatting/TextRunProperties.cs b/src/Avalonia.Base/Media/TextFormatting/TextRunProperties.cs index 86b701cb4b..7bad99f33f 100644 --- a/src/Avalonia.Base/Media/TextFormatting/TextRunProperties.cs +++ b/src/Avalonia.Base/Media/TextFormatting/TextRunProperties.cs @@ -93,6 +93,9 @@ namespace Avalonia.Media.TextFormatting internal TextRunProperties WithTypeface(Typeface typeface) { + if (this is GenericTextRunProperties other && other.Typeface == typeface) + return this; + return new GenericTextRunProperties(typeface, FontRenderingEmSize, TextDecorations, ForegroundBrush, BackgroundBrush, BaselineAlignment); }