/// <summary> /// Updates the TextFormat and TextLayout. /// </summary> private void UpdateTextFormatAndLayout() { try { if (CurrentTextFormat != null) { CurrentTextFormat.Dispose(); CurrentTextFormat = null; } if (CurrentTextLayout != null) { CurrentTextLayout.Dispose(); CurrentTextLayout = null; } // Initialize a TextFormat CurrentTextFormat = new TextFormat(FactoryDWrite, FontFamilyName, FontSize) { TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center }; CurrentTextLayout = new TextLayout(FactoryDWrite, FontText, CurrentTextFormat, renderControl.Width, renderControl.Height); // Set a stylistic typography var typo = new Typography(FactoryDWrite); typo.AddFontFeature(new FontFeature(FontFeatureTag.StylisticSet7, 1)); CurrentTextLayout.SetTypography(typo, CurrentTextRange); typo.Dispose(); UpdateBold(); UpdateItalic(); UpdateUnderline(); UpdateFontSize(); } catch (Exception ex) { LogException(ex); } }