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