protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory) { base.OnCreateDeviceIndependentResources(factory); _redColorDrawingEffect = new ColorDrawingEffect(Color.FromKnown(Colors.Red, 1)); _greenColorDrawingEffect = new ColorDrawingEffect(Color.FromKnown(Colors.Green, 1)); _blueColorDrawingEffect = new ColorDrawingEffect(Color.FromKnown(Colors.Blue, 1)); _textFormat = DirectWriteFactory.CreateTextFormat("Gabriola", 72); _textFormat.TextAlignment = TextAlignment.Center; _textFormat.ParagraphAlignment = ParagraphAlignment.Center; float width = ClientSize.Width / _dpiScaleX; float height = ClientSize.Height / _dpiScaleY; _textLayout = DirectWriteFactory.CreateTextLayout( _text, _textFormat, width, height); _textLayout.SetFontSize(100, new TextRange(20, 6)); _textLayout.SetDrawingEffect(_blueColorDrawingEffect, new TextRange(6, 5)); _textLayout.SetDrawingEffect(_redColorDrawingEffect, new TextRange(20, 6)); _textLayout.SetDrawingEffect(_greenColorDrawingEffect, new TextRange(26, 5)); ClientDrawingEffect effect = _textLayout.GetDrawingEffect(7); _textLayout.SetUnderline(true, new TextRange(20, 11)); _textLayout.SetFontWeight(FontWeight.Bold, new TextRange(20, 11)); using (Typography typography = DirectWriteFactory.CreateTypography()) { typography.AddFontFeature(FontFeatureTag.StylisticSet7, 1); _textLayout.SetTypography(typography, new TextRange(0, _text.Length)); } }