public static void Setup(ContentManager content, GraphicsDevice graphicsDevice) { var FontSystem = FontSystemFactory.Create(graphicsDevice, 2048, 2048); FontSystem.AddFont(TitleContainer.OpenStream($"{content.RootDirectory}/source-code-pro-medium.ttf")); Font = FontSystem.GetFont(28); }
public void LoadContent(GraphicsDevice graphicsDevice) { fontSystem = FontSystemFactory.Create(graphicsDevice, 1024, 1024); fontSystem.AddFont(File.ReadAllBytes(@"C:\\Windows\\Fonts\arial.ttf")); coordinatesFont = fontSystem.GetFont(24); pixel = new Texture2D(graphicsDevice, 1, 1); pixel.SetData(new uint[] { 0xFFFFFFFF }); }
protected override void LoadContent() { _s = new SpriteBatch(GraphicsDevice); _fontSystem = FontSystemFactory.Create(GraphicsDevice, 2048, 2048); _fontSystem.AddFont(TitleContainer.OpenStream($"{Content.RootDirectory}/SourceCodePro-Medium.ttf")); GuiHelper.Setup(this, _fontSystem); _ui = new IMGUI(); }
/// <summary> /// Creates a Font by building a FontSystem with the arguments passed. /// </summary> /// <param name="graphicsDevice"></param> /// <param name="fontFiles"></param> /// <param name="textureWidth"></param> /// <param name="textureHeight"></param> public Font(GraphicsDevice graphicsDevice, IEnumerable <string> fontFiles, int textureWidth = 1024, int textureHeight = 1024) { var fontSystem = FontSystemFactory.Create(graphicsDevice, textureWidth, textureHeight); foreach (var f in fontFiles) { fontSystem.AddFont(File.ReadAllBytes(f)); } _fontSystem = fontSystem; }
private static FontSystem CreateFontSystem(GraphicsDevice gd, int textureWidth, int textureHeight, params string[] fontPaths) { var system = FontSystemFactory.Create(gd, textureWidth, textureHeight); foreach (var font in fontPaths) { using var fs = new FileStream(font, FileMode.Open); system.AddFont(fs); } return(system); }
private void SetupGui() { var fontSystem = FontSystemFactory.Create(GraphicsDevice, 2048, 2048); fontSystem.AddFont(File.ReadAllBytes("Content/Fonts/Goldman-Regular.ttf")); GuiHelper.Setup(this, fontSystem); _screen = new ScreenPanel { Layout = new LayoutVerticalCenter() }; _focus = new ComponentFocus(_screen, Default.ConditionPrevFocus, Default.ConditionNextFocus); _menuGuiModule = new GuiModule(_focus); Components.Add(_menuGuiModule); }
/// <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); // TODO: use this.Content to load your game content here _fontSystem = FontSystemFactory.Create(GraphicsDevice, AtlasSize, AtlasSize); _fontSystem.AddFont(File.ReadAllBytes(@"Fonts/DroidSans.ttf")); _white = new Texture2D(GraphicsDevice, 1, 1); _white.SetData(new[] { Color.White }); GC.Collect(); }
private static FontSystem FromFile(string file, GraphicsDevice device) { try { using (var stream = File.OpenRead(file)) { var fontSystem = FontSystemFactory.Create(device, 1024, 1024, true); fontSystem.UseKernings = false; fontSystem.AddFont(stream); return(fontSystem); } } catch { } return(null); }
public override void Init(GraphicsDeviceManager _graphics, ContentManager Content, GraphicsDevice GraphicsDevice, ScreenManager screenManager, Game game) { this.game = game; FPS = new Vector2(10, 10); font = Content.Load <SpriteFont>("File"); FontSystem fontSystem = FontSystemFactory.Create(GraphicsDevice, 2048, 2048); fontSystem.AddFont(TitleContainer.OpenStream($"{Content.RootDirectory}/Monaco-1.ttf")); GuiHelper.Setup(game, fontSystem); _ui = new IMGUI(); Text = new Vector2(30, 30); base.Init(_graphics, Content, GraphicsDevice, screenManager, game); }
/// <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); // White texture _white = new Texture2D(GraphicsDevice, 1, 1); _white.SetData(new[] { Color.White }); // Font var data = File.ReadAllBytes("Fonts/DroidSans.ttf"); _fontSystem = FontSystemFactory.Create(GraphicsDevice); _fontSystem.AddFont(data); }
protected override void LoadContent() { _s = new SpriteBatch(GraphicsDevice); FontSystem fontSystem = FontSystemFactory.Create(GraphicsDevice, 2048, 2048); fontSystem.AddFont(TitleContainer.OpenStream($"{Content.RootDirectory}/source-code-pro-medium.ttf")); GuiHelper.Setup(this, fontSystem); _ui = new IMGUI(); GuiHelper.CurrentIMGUI = _ui; var texture = Content.Load <Texture2D>("apos"); _apos = new TextureRegion2D(texture, 0, 0, texture.Width, texture.Height); }
protected override void LoadContent() { InputHelper.Setup(this); _apos = Content.Load <Texture2D>("apos"); _s = new SpriteBatch(GraphicsDevice); _effect = Content.Load <Effect>("batch"); _custom = Content.Load <Effect>("custom"); _b = new Batch(GraphicsDevice, _effect); _random = new Random(); _fps = new FPSCounter(); _fontSystem = FontSystemFactory.Create(GraphicsDevice, 2048, 2048); _fontSystem.AddFont(TitleContainer.OpenStream($"{Content.RootDirectory}/source-code-pro-medium.ttf")); _font = _fontSystem.GetFont(24); }
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 }
protected override void LoadContent() { SpriteBatch = new SpriteBatch(GraphicsDevice); //Create the different managers _chargeBar = new ChargeBar(this, SpriteBatch, Graphics, new Vector2((1900 * Window.ClientBounds.Width) / 1980, (1100 * Window.ClientBounds.Height) / 1080)); _sound = new SoundManager(this); _manager = new GameManager(this); _manager.AddPlayer(new Player(this, "jojo", "ball_red", new Vector3(0, -20, 0))); _manager.LoadGame(1); //Create cameras responsible of following the ball CameraClassic = new Camera(Vector3.Zero, 0, 0, BEPUutilities.Matrix.CreatePerspectiveFieldOfViewRH(MathHelper.PiOver4, Graphics.PreferredBackBufferWidth / (float)Graphics.PreferredBackBufferHeight, .1f, 10000)); Camera = new ChaseCameraControlScheme(_manager.Space.Entities[0], new Vector3(0, 7, 0), false, 50f, CameraClassic, this); //Adding event for sound managing _manager.MainPlayer.Ball.Form.CollisionInformation.Events.ContactCreated += Events_ContactCreated; _manager.MainPlayer.Ball.Form.CollisionInformation.Events.DetectingInitialCollision += Events_DetectingInitialCollision; _manager.MainPlayer.Ball.Form.CollisionInformation.Events.CollisionEnded += Events_CollisionEnded; //Loading font and background for HUD FontSystem fontSystem = FontSystemFactory.Create(GraphicsDevice, 2048, 2048); fontSystem.AddFont(TitleContainer.OpenStream($"{Content.RootDirectory}/font-file.ttf")); _background = Content.Load <Texture2D>("Sprites/background_menu"); //Setup the HUD GuiHelper.Setup(this, fontSystem); _hudFont = Content.Load <SpriteFont>("Hud"); _ui = new IMGUI(); }
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); }