From a90ce149b647f99b6bef9efbebbd3f67213727c1 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 15 Apr 2016 15:00:05 +0200 Subject: [PATCH] Dispose the DirectWrite TextFormat. --- .../Media/FormattedTextImpl.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Windows/Perspex.Direct2D1/Media/FormattedTextImpl.cs b/src/Windows/Perspex.Direct2D1/Media/FormattedTextImpl.cs index 4daeb685fb..9c9bb6f29e 100644 --- a/src/Windows/Perspex.Direct2D1/Media/FormattedTextImpl.cs +++ b/src/Windows/Perspex.Direct2D1/Media/FormattedTextImpl.cs @@ -22,19 +22,20 @@ namespace Perspex.Direct2D1.Media { var factory = PerspexLocator.Current.GetService(); - var format = new DWrite.TextFormat( + using (var format = new DWrite.TextFormat( factory, fontFamily, (DWrite.FontWeight)fontWeight, (DWrite.FontStyle)fontStyle, - (float)fontSize); - - TextLayout = new DWrite.TextLayout( - factory, - text ?? string.Empty, - format, - float.MaxValue, - float.MaxValue); + (float)fontSize)) + { + TextLayout = new DWrite.TextLayout( + factory, + text ?? string.Empty, + format, + float.MaxValue, + float.MaxValue); + } TextLayout.TextAlignment = textAlignment.ToDirect2D(); }