コード例 #1
0
 public FontEmbedOption(SystemFontFamily systemFont, SceneViewModel viewModel, FontEmbeddingDialogModel embeddingModel)
 {
     this.systemFont              = systemFont;
     this.viewModel               = viewModel;
     this.embeddingModel          = embeddingModel;
     this.IsFontSubsettingAllowed = FontEmbedder.DoesFontFileSupportSubsetting(Enumerable.FirstOrDefault <string>((IEnumerable <string>)systemFont.FontSources) ?? string.Empty);
 }
コード例 #2
0
ファイル: FontEmbedder.cs プロジェクト: radtek/Shopdrawing
        public ProjectFont EmbedSystemFont(SystemFontFamily systemFontFamily)
        {
            string fontsDirectory = Path.Combine(this.viewModel.DesignerContext.ActiveProject.ProjectRoot.Path, "Fonts");

            if (!Microsoft.Expression.Framework.Documents.PathHelper.DirectoryExists(fontsDirectory))
            {
                Directory.CreateDirectory(fontsDirectory);
            }
            foreach (IProjectItem projectItem in this.viewModel.DesignerContext.ActiveProject.AddItems(Enumerable.Select <string, DocumentCreationInfo>((IEnumerable <string>)systemFontFamily.FontSources, (Func <string, DocumentCreationInfo>)(fontSource => new DocumentCreationInfo()
            {
                TargetFolder = fontsDirectory,
                SourcePath = fontSource,
                CreationOptions = CreationOptions.DoNotSelectCreatedItems
            }))))
            {
                IMSBuildItem msBuildItem = projectItem as IMSBuildItem;
                if (msBuildItem != null)
                {
                    projectItem.Properties["BuildAction"] = "BlendEmbeddedFont";
                    msBuildItem.SetMetadata("IsSystemFont", "True");
                    msBuildItem.SetMetadata("All", "True");
                    msBuildItem.SetMetadata("AutoFill", "True");
                }
            }
            this.EnsureFontSubsettingTask();
            foreach (ProjectFont projectFont in (Collection <IProjectFont>) this.viewModel.ProjectContext.ProjectFonts)
            {
                if (projectFont.FontFamilyName == FontEmbedder.GetFontNameFromSource(systemFontFamily.FontFamily))
                {
                    this.ChangeFontReferenceToEmbeddedFont((IProjectFont)projectFont);
                    return(projectFont);
                }
            }
            return((ProjectFont)null);
        }
コード例 #3
0
ファイル: FontEmbedder.cs プロジェクト: radtek/Shopdrawing
        private static void StoreSystemFont(string fontFile, Typeface typeface, Dictionary <string, SystemFontFamily> fontFileMap, bool useGdiFontNames)
        {
            string serializeFontFamilyName = FontEmbedder.GetSerializeFontFamilyName(typeface, useGdiFontNames);

            if (string.IsNullOrEmpty(serializeFontFamilyName))
            {
                return;
            }
            SystemFontFamily systemFontFamily = (SystemFontFamily)null;

            if (!fontFileMap.TryGetValue(serializeFontFamilyName, out systemFontFamily))
            {
                systemFontFamily = new SystemFontFamily(new FontFamily(serializeFontFamilyName));
                fontFileMap[serializeFontFamilyName] = systemFontFamily;
            }
            if (systemFontFamily.FontSources.Contains(fontFile))
            {
                return;
            }
            systemFontFamily.FontSources.Add(fontFile);
        }
コード例 #4
0
ファイル: FontEmbedder.cs プロジェクト: radtek/Shopdrawing
        public static void CreateSystemFontFamiliesCache()
        {
            PerformanceUtility.StartPerformanceSequence(PerformanceEvent.FontCacheInitialization);
            Dictionary <string, SystemFontFamily> fontFileMap1 = new Dictionary <string, SystemFontFamily>();
            Dictionary <string, SystemFontFamily> fontFileMap2 = new Dictionary <string, SystemFontFamily>();

            foreach (string str in Directory.GetFiles(FontEmbedder.SystemFontsDirectory))
            {
                foreach (Typeface typeface in (IEnumerable <Typeface>)FontEmbedder.GetTypefacesSafe(str))
                {
                    bool useGdiFontNames1 = false;
                    FontEmbedder.StoreSystemFont(str, typeface, fontFileMap1, useGdiFontNames1);
                    bool useGdiFontNames2 = true;
                    FontEmbedder.StoreSystemFont(str, typeface, fontFileMap2, useGdiFontNames2);
                }
            }
            FontEmbedder.wpfFonts = (IEnumerable <SystemFontFamily>)Enumerable.ToList <SystemFontFamily>((IEnumerable <SystemFontFamily>)fontFileMap1.Values);
            SystemFontFamily systemFontFamily = new SystemFontFamily(new FontFamily("Portable User Interface"));

            fontFileMap2["Portable User Interface"] = systemFontFamily;
            FontEmbedder.gdiFonts = (IEnumerable <SystemFontFamily>)Enumerable.ToList <SystemFontFamily>((IEnumerable <SystemFontFamily>)fontFileMap2.Values);
            PerformanceUtility.EndPerformanceSequence(PerformanceEvent.FontCacheInitialization);
        }
コード例 #5
0
 public SystemFontFamilyItem(SystemFontFamily systemFontFamily, SceneNodeObjectSet sceneNodeObjectSet)
     : base(systemFontFamily.FontFamily, "System Font", sceneNodeObjectSet)
 {
     this.systemFontFamily = systemFontFamily;
     this.PropertyChanged += new PropertyChangedEventHandler(this.SystemFontFamilyItem_PropertyChanged);
 }
コード例 #6
0
 public SystemFontFamilyItem(SystemFontFamily systemFontFamily, IDocumentContext documentContext)
     : base(systemFontFamily.FontFamily, "System Font", documentContext)
 {
     this.systemFontFamily = systemFontFamily;
     this.PropertyChanged += new PropertyChangedEventHandler(this.SystemFontFamilyItem_PropertyChanged);
 }