Exemple #1
0
        /// <summary>
        /// Specifies the fonts which shall be used to display the text contents of
        /// this run.The default handling for fcr == null is to overwrite the
        /// ascii font char range with the given font family and also set all not
        /// specified font ranges
        /// </summary>
        /// <param name="fontFamily">fontFamily</param>
        /// <param name="fcr">FontCharRange or null for default handling</param>
        public void SetFontFamily(String fontFamily, FontCharRange fcr)
        {
            W.CT_RPr   pr    = run.IsSetRPr1() ? run.rPr1 : run.AddNewRPr1();
            W.CT_Fonts fonts = pr.IsSetRFonts() ? pr.rFonts : pr.AddNewRFonts();

            if (fcr == FontCharRange.None)
            {
                fonts.ascii = (fontFamily);
                if (!fonts.IsSetHAnsi())
                {
                    fonts.hAnsi = (fontFamily);
                }
                if (!fonts.IsSetCs())
                {
                    fonts.cs = (fontFamily);
                }
                if (!fonts.IsSetEastAsia())
                {
                    fonts.eastAsia = (fontFamily);
                }
            }
            else
            {
                switch (fcr)
                {
                case FontCharRange.Ascii:
                    fonts.ascii = (fontFamily);
                    break;

                case FontCharRange.CS:
                    fonts.cs = (fontFamily);
                    break;

                case FontCharRange.EastAsia:
                    fonts.eastAsia = (fontFamily);
                    break;

                case FontCharRange.HAnsi:
                    fonts.hAnsi = (fontFamily);
                    break;
                }
            }
        }