static Glyph[] ImportFont(SpriteFontAsset options, out float lineSpacing, out float baseLine) { // Which importer knows how to read this source font? IFontImporter importer; var sourceExtension = (Path.GetExtension(options.Source) ?? "").ToLowerInvariant(); var bitmapFileExtensions = new List <string> { ".bmp", ".png", ".gif" }; var importFromBitmap = bitmapFileExtensions.Contains(sourceExtension); if (importFromBitmap) { throw new Exception("SDF Font from image is not supported!"); } importer = new SignedDistanceFieldFontImporter(); // create the list of character to import var characters = GetCharactersToImport(options); // Import the source font data. importer.Import(options, characters); lineSpacing = importer.LineSpacing; baseLine = importer.BaseLine; // Get all glyphs var glyphs = new List <Glyph>(importer.Glyphs); // Validate. if (glyphs.Count == 0) { throw new Exception("Font does not contain any glyphs."); } // Sort the glyphs glyphs.Sort((left, right) => left.Character.CompareTo(right.Character)); // Check that the default character is part of the glyphs if (!DefaultCharacterExists(options.DefaultCharacter, glyphs)) { throw new InvalidOperationException("The specified DefaultCharacter is not part of this font."); } return(glyphs.ToArray()); }
static Glyph[] ImportFont(SpriteFontAsset options, out float lineSpacing, out float baseLine) { // Which importer knows how to read this source font? IFontImporter importer; var sourceExtension = (Path.GetExtension(options.FontSource.GetFontPath()) ?? "").ToLowerInvariant(); var bitmapFileExtensions = new List<string> { ".bmp", ".png", ".gif" }; var importFromBitmap = bitmapFileExtensions.Contains(sourceExtension); if (importFromBitmap) { throw new Exception("SDF Font from image is not supported!"); } importer = new SignedDistanceFieldFontImporter(); // create the list of character to import var characters = GetCharactersToImport(options); // Import the source font data. importer.Import(options, characters); lineSpacing = importer.LineSpacing; baseLine = importer.BaseLine; // Get all glyphs var glyphs = new List<Glyph>(importer.Glyphs); // Validate. if (glyphs.Count == 0) { throw new Exception("Font does not contain any glyphs."); } // Sort the glyphs glyphs.Sort((left, right) => left.Character.CompareTo(right.Character)); // Check that the default character is part of the glyphs if (!DefaultCharacterExists(options.DefaultCharacter, glyphs)) { throw new InvalidOperationException("The specified DefaultCharacter is not part of this font."); } return glyphs.ToArray(); }