public Neo(Game game, MonoGamePlatform platform) : base(null) { _game = game; _currentPlatform = platform; _game.Window.ClientSizeChanged += OnResize; if (_currentPlatform == MonoGamePlatform.Android) { Scale = 2.5f; } else { Scale = 1f; } DefaultFont = game.Content.Load <NeoFont>("output"); DefaultFont.Atlas = game.Content.Load <Texture2D>("atlas"); _neo = this; }
public void DrawString(string text, Vector2 position, float scale, Color color) { NeoFont font = _neo.DefaultFont; if (text != null) { float advance = 0; float row = 0; for (var i = 0; i < text.Length; ++i) { char c = text[i]; if (c == ' ') { advance += 0.35f; continue; } if (c == '\n') { row++; advance = 0; continue; } NeoGlyph g; font.Glyphs.TryGetValue(c, out g); Bounds gg = g.PlaneBounds * scale; if (g != null) { DrawGlyph(font.Atlas, new Rectangle((int)(gg.Left + (advance * scale + position.X)), (int)(scale - gg.Top + position.Y + (row * 1 * scale)), (int)(gg.Right - gg.Left), (int)(gg.Top - gg.Bottom)), g.AtlasBounds.Left, g.AtlasBounds.Bottom, g.AtlasBounds.Right, g.AtlasBounds.Top, color); advance += g.Advance; } } } }