Esempio n. 1
0
        static Dictionary <string, string> QueryFontFilesFromFontDirectories(string[] fontdirs)
        {
            var results  = new Dictionary <string, string>();
            var analyzer = new TTFAnalyzer();

            foreach (var fontdir in fontdirs)
            {
                using (var dir = new File(fontdir))
                {
                    if (!dir.Exists())
                    {
                        continue;
                    }

                    File[] files = dir.ListFiles();

                    if (files == null)
                    {
                        continue;
                    }

                    foreach (var file in files)
                    {
                        if (analyzer.FontFamiliesAndStyle(file.AbsolutePath) is List <string> fontFamilies)
                        {
                            foreach (var fontFamily in fontFamilies)
                            {
                                AddFont(results, fontFamily, file);
                            }
                        }
                    }
                }
            }
            return(results);
        }
Esempio n. 2
0
        static Dictionary <string, string> QueryFontFilesFromFontDirectories(string[] fontdirs)
        {
            var results  = new Dictionary <string, string>();
            var analyzer = new TTFAnalyzer();

            foreach (var fontdir in fontdirs)
            {
                using (var dir = new File(fontdir))
                {
                    if (!dir.Exists())
                    {
                        continue;
                    }

                    File[] files = dir.ListFiles();

                    if (files == null)
                    {
                        continue;
                    }

                    foreach (var file in files)
                    {
                        if (analyzer.FontAttributes(file.AbsolutePath) == "Regular")
                        {
                            var fontFamilys = analyzer.FontFamily(file.AbsolutePath);
                            foreach (var fontFamily in fontFamilys)
                            {
                                if (fontFamily != null && !results.ContainsKey(fontFamily))
                                {
                                    results.Add(fontFamily, file.AbsolutePath);
                                }
                            }
                        }
                    }
                }
            }
            return(results);
        }