protected override Task LoadContent() #endif { // Create a new SpriteBatch, which can be used to draw textures. _spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here var assembly = GetType().Assembly; _font = StaticSpriteFont.FromBMFont(assembly.ReadResourceAsString("FontStashSharp.Samples.StaticSpriteFont.Fonts.Arial.fnt"), fileName => assembly.OpenResourceStream("FontStashSharp.Samples.StaticSpriteFont.Fonts." + fileName), GraphicsDevice); #if MONOGAME || FNA _white = new Texture2D(GraphicsDevice, 1, 1); _white.SetData(new[] { Color.White }); #elif STRIDE _white = Texture2D.New2D(GraphicsDevice, 1, 1, false, PixelFormat.R8G8B8A8_UNorm_SRgb, TextureFlags.ShaderResource); _white.SetData(GraphicsContext.CommandList, new[] { Color.White }); #endif GC.Collect(); #if STRIDE return(base.LoadContent()); #endif }
public void Load() { var assembly = TestsEnvironment.Assembly; var data = assembly.ReadResourceAsString("Resources.arial64.fnt"); var font = StaticSpriteFont.FromBMFont(data, fileName => assembly.OpenResourceStream("Resources." + fileName), TestsEnvironment.GraphicsDevice); Assert.AreEqual(font.FontSize, 63); Assert.AreEqual(font.Glyphs.Count, 191); var texture = font.Glyphs.First().Value.Texture; Assert.NotNull(texture); Assert.AreEqual(texture.Width, 512); Assert.AreEqual(texture.Height, 512); }