Пример #1
0
        public void FontChangeTest()
        {
            var builder = new RichTextBuilder();

            builder.SetDefaultFont("Arial");
            builder.Text("Start").LineBreak();
            builder.BeginGroup().Font("Times New Roman");
            builder.Text("Times New Roman").EndGroup().LineBreak();
            builder.BeginGroup().Font("Arial").Text("Arial").EndGroup().LineBreak();
            var rtf = builder.ToRtf();

            Console.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);
        }
Пример #2
0
        public void FormattedTextTest()
        {
            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.BeginGroup().Bold().Italic().Text("Bold Italic").EndGroup().Text(" text.");
            var rtf = builder.ToRtf();

            Console.WriteLine(rtf);
            int i = rtf.IndexOf("This is ", StringComparison.Ordinal);

            Assert.True(i > 0);
            Assert.AreEqual(
                @"This is {\b bold} and {\i italic} text.\line And this is {\b\i Bold Italic} text.}",
                rtf.Substring(i));
        }