/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. _spriteBatch = new SpriteBatch(GraphicsDevice); Texture2D texture; using (var stream = TitleContainer.OpenStream("Fonts/test_0.png")) { texture = Texture2D.FromStream(GraphicsDevice, stream); } string fontData; using (var stream = TitleContainer.OpenStream("Fonts/test.fnt")) { using (var reader = new StreamReader(stream)) { fontData = reader.ReadToEnd(); } } _font = BMFontLoader.LoadXml(fontData, name => texture); GC.Collect(); }
public MonoGameGameFont(MonoGameFileHandle fntFileHandle, MonoGameFileHandle textureFileHandle) { _fontName = fntFileHandle.nameWithoutExtension(); _spriteFont = BMFontLoader.LoadXml(fntFileHandle.readString(), ((MonoGameTexture)Mdx.graphics.newTexture(textureFileHandle)).texture2D); _sharedFontGlyphLayout = newGlyphLayout(); _capHeight = _spriteFont.MeasureString("A").Y; }
public override SpriteFont Load(Stream stream) { using var reader = new StreamReader(stream); var fontData = reader.ReadToEnd(); var font = BMFontLoader.LoadXml(fontData, name => new TextureWithOffset(_assetLoader.Get <Texture2D>(name))); return(font); }
public static MonoGameGameFont loadBitmapFont(MonoGameFileHandle fntFileHandle) { var font = new MonoGameGameFont(); font._spriteFont = BMFontLoader.LoadXml(fntFileHandle.readString(), textureFileName => { return(new TextureWithOffset(((MonoGameTexture)Mdx.graphics_.newTexture(fntFileHandle.parent().child(textureFileName))).texture2D)); }); font._sharedFontGlyphLayout = font.newGlyphLayout(); font._capHeight = font._spriteFont.GetGlyphs()['A'].BoundsInTexture.Height; return(font); }