static Glyph[] ImportFont(CommandLineOptions options, out float lineSpacing) { // Which importer knows how to read this source font? IFontImporter importer; string fileExtension = Path.GetExtension(options.SourceFont).ToLowerInvariant(); string[] BitmapFileExtensions = { ".bmp", ".png", ".gif" }; if (BitmapFileExtensions.Contains(fileExtension)) { importer = new BitmapImporter(); } else { importer = new TrueTypeImporter(); } // Import the source font data. importer.Import(options); lineSpacing = importer.LineSpacing; var glyphs = importer.Glyphs .OrderBy(glyph => glyph.Character) .ToArray(); // Validate. if (glyphs.Length == 0) { throw new Exception("Font does not contain any glyphs."); } if ((options.DefaultCharacter != 0) && !glyphs.Any(glyph => glyph.Character == options.DefaultCharacter)) { throw new Exception("The specified DefaultCharacter is not part of this font."); } return(glyphs); }
static Glyph[] ImportFont(CommandLineOptions options, out float lineSpacing) { // Which importer knows how to read this source font? IFontImporter importer; string fileExtension = Path.GetExtension(options.SourceFont).ToLowerInvariant(); string[] BitmapFileExtensions = { ".bmp", ".png", ".gif" }; if (BitmapFileExtensions.Contains(fileExtension)) { importer = new BitmapImporter(); } else { importer = new TrueTypeImporter(); } // Import the source font data. importer.Import(options); lineSpacing = importer.LineSpacing; var glyphs = importer.Glyphs .OrderBy(glyph => glyph.Character) .ToArray(); // Validate. if (glyphs.Length == 0) { throw new Exception("Font does not contain any glyphs."); } if ((options.DefaultCharacter != 0) && !glyphs.Any(glyph => glyph.Character == options.DefaultCharacter)) { throw new Exception("The specified DefaultCharacter is not part of this font."); } return glyphs; }