public void CanFontChange() { var builder = new RichTextBuilder(); builder.SetDefaultFont("Arial"); builder.Text("Start").LineBreak(); builder.Begin().Font("Times New Roman"); builder.Text("Times New Roman").End().LineBreak(); builder.Begin().Font("Arial").Text("Arial").End().LineBreak(); var rtf = builder.ToRtf(); _output.WriteLine(rtf); int i = rtf.IndexOf(@"{\f1 Times New Roman}", StringComparison.Ordinal); int j = rtf.IndexOf(@"{\f0 Arial}", StringComparison.Ordinal); Assert.True(i > 0 && j > i); }
public void CanFormattedText() { var builder = new RichTextBuilder(); builder.LineLimit = 999; // long lines are fine for this test builder.Text("This is ").Bold("bold").Text(" and ").Italic("italic").Text(" text."); builder.LineBreak(); builder.Text("And this is "); builder.Begin().Bold().Italic().Text("Bold Italic").End().Text(" text."); var rtf = builder.ToRtf(); _output.WriteLine(rtf); int i = rtf.IndexOf("This is ", StringComparison.Ordinal); Assert.True(i > 0); Assert.Equal( @"This is {\b bold} and {\i italic} text.\line And this is {\b\i Bold Italic} text.}", rtf.Substring(i)); }