Browse Source

TextRunProperties: don't allocate if the typeface hasn't changed

pull/10013/head
Julien Lebosquain 4 years ago
parent
commit
96b423900f
  1. 3
      src/Avalonia.Base/Media/TextFormatting/TextRunProperties.cs

3
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);
}

Loading…
Cancel
Save