/// <summary> /// Inits the font family names from DirectWrite /// </summary> private void InitTextFormatLayout() { FontFamilyName = "Gabriola"; FontSize = 72; FontText = "Client Drawing Effect Example!"; // Initialize a TextFormat CurrentTextFormat = new TextFormat(FactoryDWrite, FontFamilyName, FontSize) { TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center }; CurrentTextLayout = new TextLayout(FactoryDWrite, FontText, CurrentTextFormat, ClientRectangle.Width, ClientRectangle.Height); RedDrawingeffect = new ColorDrawingEffect(new Color4(1, 1, 0, 0)); BlueDrawingEffect = new ColorDrawingEffect(new Color4(1, 0, 0, 1)); GreenDrawingEffect = new ColorDrawingEffect(new Color4(1, 0, 1, 0)); CurrentTextLayout.SetDrawingEffect(RedDrawingeffect, new TextRange(0, 14)); CurrentTextLayout.SetDrawingEffect(BlueDrawingEffect, new TextRange(14, 7)); CurrentTextLayout.SetDrawingEffect(GreenDrawingEffect, new TextRange(21, 8)); // Set a stylistic typography var typo = new Typography(FactoryDWrite); typo.AddFontFeature(new FontFeature(FontFeatureTag.StylisticSet7, 1)); CurrentTextLayout.SetTypography(typo, CurrentTextRange); typo.Release(); }
/// <summary> /// Inits the font family names from DirectWrite /// </summary> private void InitTextFormatLayout() { FontFamilyName = "Gabriola"; FontSize = 72; FontText = "Client Drawing Effect Example!"; // Initialize a TextFormat CurrentTextFormat = new TextFormat(FactoryDWrite, FontFamilyName, FontSize); CurrentTextFormat.TextAlignment = TextAlignment.Center; CurrentTextFormat.ParagraphAlignment = ParagraphAlignment.Center; CurrentTextLayout = new TextLayout(FactoryDWrite, FontText, CurrentTextFormat, ClientRectangle.Width, ClientRectangle.Height); RedDrawingeffect = new ColorDrawingEffect(Color.Red); BlueDrawingEffect = new ColorDrawingEffect(Color.Blue); GreenDrawingEffect = new ColorDrawingEffect(Color.Green); CurrentTextLayout.SetDrawingEffect(RedDrawingeffect, new TextRange(0, 14)); CurrentTextLayout.SetDrawingEffect(BlueDrawingEffect, new TextRange(14, 7)); CurrentTextLayout.SetDrawingEffect(GreenDrawingEffect, new TextRange(21, 8)); CurrentTextLayout.SetUnderline(true, new TextRange(0, 20)); CurrentTextLayout.SetStrikethrough(true, new TextRange(22, 7)); // Set a stylistic typography using (var typo = new Typography(FactoryDWrite)) { typo.AddFontFeature(new FontFeature(FontFeatureTag.StylisticSet7, 1)); CurrentTextLayout.SetTypography(typo, CurrentTextRange); } }