/** Inserts all the fonts recognized by iText in the * <CODE>directory</CODE> into the map. The encoding * will be <CODE>BaseFont.CP1252</CODE> but can be * changed later. * @param dir the directory to scan * @return the number of files processed */ public int insertDirectory(string dir) { DirectoryInfo di = new DirectoryInfo(dir); if (!di.Exists) { return(0); } FileInfo[] files = di.GetFiles(); int count = 0; foreach (FileInfo file in files) { string name = file.FullName.ToLower(); try { if (name.EndsWith(".ttf") || name.EndsWith(".otf") || name.EndsWith(".afm")) { string[][] names = BaseFont.getFullFontName(file.FullName, BaseFont.CP1252, null); insertNames(names, file.FullName); ++count; } else if (name.EndsWith(".ttc")) { string[] ttcs = BaseFont.enumerateTTCNames(file.FullName); for (int j = 0; j < ttcs.Length; ++j) { string nt = file.FullName + "," + (j + 1); string[][] names = BaseFont.getFullFontName(nt, BaseFont.CP1252, null); insertNames(names, nt); } ++count; } } catch (Exception e) { e.GetType(); } } return(count); }