コード例 #1
0
        /// <summary>
        /// Attempts to retrieve the specified font from the System's Fonts folder
        /// and registers the font with WPF.
        /// </summary>
        /// <param name="fontName">Name of the font.</param>
        /// <returns></returns>
        private static PdfFont GetFont(string fontName)
        {
            if (!PdfFontFactory.IsRegistered(fontName))
            {
                var fontPath = Environment.GetEnvironmentVariable("SystemRoot") + "\\fonts\\" + fontName.Replace(" ", "") + ".ttf";
                PdfFontFactory.Register(fontPath);
            }

            return(PdfFontFactory.CreateRegisteredFont(fontName));
        }
コード例 #2
0
        public void InitializeLayout()
        {
            if (string.IsNullOrEmpty(RegularFontName))
            {
                RegularFontName = Common.FontTitleRegular;
            }

            if (string.IsNullOrEmpty(BoldFontName))
            {
                BoldFontName = Common.FontTitleBold;
            }

            if (!PdfFontFactory.IsRegistered(RegularFontName))
            {
                PdfFontFactory.Register(RegularFontName);
            }
            if (!PdfFontFactory.IsRegistered(BoldFontName))
            {
                PdfFontFactory.Register(BoldFontName);
            }

            regularFont = PdfFontFactory.CreateFont(RegularFontName, true);
            boldFont    = PdfFontFactory.CreateFont(BoldFontName, true);
        }