Exemple #1
0
        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);
        }