예제 #1
0
        private static FontFamily GetFontFamily(FontFamily fontFamily)
        {
            var fontname =
                fontFamily.Source.Substring(fontFamily.Source.LastIndexOf("/#", StringComparison.OrdinalIgnoreCase));

            var newFontName = string.Format(File2, FontPath.Replace("\\", "/"), fontname);

            var newFont = Utilities.PossibleFonts.FirstOrDefault(elem => elem.Source.Equals(newFontName));

            return(newFont ?? Utilities.PossibleFonts.FirstOrDefault());
        }
예제 #2
0
        public static bool ChangeMainFont(this TextElement elem)
        {
            if (!elem.FontFamily.Source.StartsWith("file:///"))
            {
                return(false);
            }

            string format = string.Format(File, FontPath.Replace("\\", "/"));

            if (elem.FontFamily.Source.StartsWith(format))
            {
                return(false);
            }



            elem.FontFamily = GetFontFamily(elem.FontFamily);
            return(true);
        }