Click here to Skip to main content
15,886,017 members
Articles / Desktop Programming / Windows Forms

RichText Builder (StringBuilder for RTF)

Rate me:
Please Sign up or sign in to vote.
4.86/5 (102 votes)
12 Nov 2008CPOL4 min read 247K   9.9K   214  
RichText Builder - use in place of StringBuilder to output RTF.
namespace RTF
{
    using System;

    partial class RTFBuilder
    {
        #region Nested type: RawFonts


        // ----------------------------------------------------------------------------------------
        //    _                ___        _..-._   Date: 01/11/08    21:15
        //    \`.|\..----...-'`   `-._.-'' _.-..'     
        //    /  ' `         ,       __.-'' 
        //    )/` _/     \   `-_,   /     Solution: RTFLib
        //    `-'" `"\_  ,_.-;_.-\_ ',    Project : RTFLib                                 
        //        _.-'_./   {_.'   ; /    Author  : Anton
        //       {_.-``-'         {_/     Assembly: 1.3.0.2499
        //                                Copyright © 2005-2008, Rogue Trader
        //        Project Item Name:      RTFBuilder.RTFFonts.cs - [PROJECT_ITEM_KIND]
        //        Purpose:                Used internally by RtfBuilderBase
        // ----------------------------------------------------------------------------------------


        internal static class RawFonts
        {
            #region Fields

            public const string Arial = @"{{\f{0}\fswiss\fprq2\fcharset0 Arial;}}";
            public const string ArialBlack = @"{{\f{0}\fswiss\fprq2\fcharset0 Arial Black;}}";
            public const string BookmanOldStyle = @"{{\f{0}\froman\fprq2\fcharset0 Bookman Old Style;}}";
            public const string Broadway = @"{{\f{0}\fdecor\fprq2\fcharset0 Broadway;}}";
            public const string CenturyGothic = @"{{\f{0}\fswiss\fprq2\fcharset0 Century Gothic;}}";
            public const string Consolas = @"{{\f{0}\fmodern\fprq1\fcharset0 Consolas;}}";
            public const string CordiaNew = @"{{\f{0}\fswiss\fprq2\fcharset0 Cordia New;}}";
            public const string CourierNew = @"{{\f{0}\fmodern\fprq1\fcharset0 Courier New;}}";
            public const string FontTimesNewRoman = @"{{\f{0}\froman\fcharset0 Times New Roman;}}";
            public const string Garamond = @"{{\f{0}\froman\fprq2\fcharset0 Garamond;}}";
            public const string Georgia = @"{{\f{0}\froman\fprq2\fcharset0 Georgia;}}";
            public const string Impact = @"{{\f{0}\fswiss\fprq2\fcharset0 Impact;}}";
            public const string LucidaConsole = @"{{\f{0}\fmodern\fprq1\fcharset0 Lucida Console;}}";
            public const string MSSansSerif = "{{\f{0}\fswiss\fprq2\fcharset0 MS Reference Sans Serif;}}";
            public const string Symbol = @"{{\f{0}\ftech\fcharset0 Symbol;}}";
            public const string WingDings = "{{\f{0}\fnil\fprq2\fcharset2 Wingdings;}}";

            #endregion

            #region Static Methods

            public static string GetKnownFontstring(RTFFont font)
            {
                string value = string.Empty;
                switch (font)
                {
                    case RTFFont.Arial:
                        value = Arial;
                        break;
                    case RTFFont.ArialBlack:
                        value = ArialBlack;
                        break;
                    case RTFFont.BookmanOldStyle:
                        value = BookmanOldStyle;
                        break;
                    case RTFFont.Broadway:
                        value = Broadway;
                        break;
                    case RTFFont.CenturyGothic:
                        value = CenturyGothic;
                        break;
                    case RTFFont.Consolas:
                        value = Consolas;
                        break;
                    case RTFFont.CordiaNew:
                        value = CordiaNew;
                        break;
                    case RTFFont.CourierNew:
                        value = CourierNew;
                        break;
                    case RTFFont.FontTimesNewRoman:
                        value = FontTimesNewRoman;
                        break;
                    case RTFFont.Garamond:
                        value = Garamond;
                        break;
                    case RTFFont.Georgia:
                        value = Georgia;
                        break;
                    case RTFFont.Impact:
                        value = Impact;
                        break;
                    case RTFFont.LucidaConsole:
                        value = LucidaConsole;
                        break;
                    case RTFFont.Symbol:
                        value = Symbol;
                        break;
                    case RTFFont.WingDings:
                        value = WingDings;
                        break;
                    case RTFFont.MSSansSerif:
                        value = MSSansSerif;
                        break;
                    default:
                        throw new ArgumentOutOfRangeException("font");
                }
                return value;
            }

            #endregion
        }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Australia Australia
Interested in financial math and programming theory in general. Working on medical applications in spare time. Happy to get feedback.

Comments and Discussions