public FontSystem Load(AssetLoaderContext context, string assetName) { var parts = assetName.Split(':'); var fontType = FontType.Regular; var amount = 1; if (parts.Length > 1) { fontType = (FontType)Enum.Parse(typeof(FontType), parts[1]); if (fontType != FontType.Regular) { if (parts.Length < 3) { throw new Exception("Missing amount"); } amount = int.Parse(parts[2]); } } FontSystem fontSystem = null; switch (fontType) { case FontType.Regular: fontSystem = FontSystemFactory.Create(context.GraphicsDevice, 1024, 1024); break; case FontType.Blurry: fontSystem = FontSystemFactory.CreateBlurry(context.GraphicsDevice, 1024, 1024, amount); break; case FontType.Stroked: fontSystem = FontSystemFactory.CreateStroked(context.GraphicsDevice, 1024, 1024, amount); break; } var data = context.Load <byte[]>(parts[0]); fontSystem.AddFont(data); return(fontSystem); }
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 fontSystems = new List <FontSystem>(); // Simple var fontSystem = FontSystemFactory.Create(GraphicsDevice); LoadFontSystem(fontSystem); fontSystems.Add(fontSystem); // Blurry var blurryFontSystem = FontSystemFactory.CreateBlurry(GraphicsDevice, EffectAmount); LoadFontSystem(blurryFontSystem); fontSystems.Add(blurryFontSystem); // Stroked var strokedFontSystem = FontSystemFactory.CreateStroked(GraphicsDevice, EffectAmount); LoadFontSystem(strokedFontSystem); fontSystems.Add(strokedFontSystem); _fontSystems = fontSystems.ToArray(); _currentFontSystem = _fontSystems[0]; #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 FontSystem Load(AssetLoaderContext context, string assetName) { var parts = assetName.Split(':'); var fontType = FontType.Regular; var amount = 1; if (parts.Length > 1) { fontType = (FontType)Enum.Parse(typeof(FontType), parts[1]); if (fontType != FontType.Regular) { if (parts.Length < 3) { throw new Exception("Missing amount"); } amount = int.Parse(parts[2]); } } FontSystem fontSystem = null; #if MONOGAME || FNA || STRIDE switch (fontType) { case FontType.Regular: fontSystem = FontSystemFactory.Create(MyraEnvironment.GraphicsDevice, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize); break; case FontType.Blurry: fontSystem = FontSystemFactory.CreateBlurry(MyraEnvironment.GraphicsDevice, amount, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize); break; case FontType.Stroked: fontSystem = FontSystemFactory.CreateStroked(MyraEnvironment.GraphicsDevice, amount, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize); break; } #else switch (fontType) { case FontType.Regular: fontSystem = FontSystemFactory.Create(MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize); break; case FontType.Blurry: fontSystem = FontSystemFactory.CreateBlurry(amount, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize); break; case FontType.Stroked: fontSystem = FontSystemFactory.CreateStroked(amount, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize); break; } #endif var data = context.Load <byte[]>(parts[0]); fontSystem.AddFont(data); return(fontSystem); }