Example #1
0
        /**
         * Specifies the font size which shall be applied to all non complex script
         * characters in the contents of this run.when displayed.
         * <p/>
         * If this element is not present, the default value is to leave the value
         * applied at previous level in the style hierarchy. If this element is
         * never applied in the style hierarchy, then any appropriate font size may
         * be used for non complex script characters.
         * </p>
         *
         * @param size
         */
        public void SetFontSize(int size)
        {
            CT_RPr        pr     = run.IsSetRPr() ? run.rPr : run.AddNewRPr();
            CT_HpsMeasure ctSize = pr.IsSetSz() ? pr.sz : pr.AddNewSz();

            ctSize.val = (ulong)size * 2;
        }
        /// <summary>
        /// 设置字体大小
        /// </summary>
        /// <param name="run"></param>
        /// <param name="sizeType"></param>
        public static void SetFontSize(this XWPFRun run, FontSizeType sizeType)
        {
            ulong         fontSize = GetFontSize(sizeType);
            CT_R          r        = run.GetCTR();
            CT_RPr        rpr      = r.IsSetRPr() ? r.rPr : r.AddNewRPr();
            CT_HpsMeasure ctSize   = rpr.IsSetSz() ? rpr.sz : rpr.AddNewSz();

            ctSize.val = fontSize;
        }