using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using MLEM.Font; using MonoGame.Extended.BitmapFonts; namespace MLEM.Extended.Font { /// public class GenericBitmapFont : GenericFont { /// /// The that is being wrapped by this generic font /// public readonly BitmapFont Font; /// public override GenericFont Bold { get; } /// public override GenericFont Italic { get; } /// public override float LineHeight => this.Font.LineHeight; /// /// Creates a new generic font using . /// Optionally, a bold and italic version of the font can be supplied. /// /// The font to wrap /// A bold version of the font /// An italic version of the font public GenericBitmapFont(BitmapFont font, BitmapFont bold = null, BitmapFont italic = null) { this.Font = font; this.Bold = bold != null ? new GenericBitmapFont(bold) : this; this.Italic = italic != null ? new GenericBitmapFont(italic) : this; } /// protected override Vector2 CalcCharSize(char c) { var region = this.Font.GetCharacterRegion(c); return region != null ? new Vector2(region.XAdvance, region.Height) : Vector2.Zero; } /// public override void DrawString(SpriteBatch batch, string text, Vector2 position, Color color) { batch.DrawString(this.Font, text, position, color); } /// public override void DrawString(SpriteBatch batch, string text, Vector2 position, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) { batch.DrawString(this.Font, text, position, color, rotation, origin, scale, effects, layerDepth); } /// public override void DrawString(SpriteBatch batch, string text, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth) { batch.DrawString(this.Font, text, position, color, rotation, origin, scale, effects, layerDepth); } /// public override void DrawString(SpriteBatch batch, StringBuilder text, Vector2 position, Color color) { batch.DrawString(this.Font, text, position, color); } /// public override void DrawString(SpriteBatch batch, StringBuilder text, Vector2 position, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) { batch.DrawString(this.Font, text, position, color, rotation, origin, scale, effects, layerDepth); } /// public override void DrawString(SpriteBatch batch, StringBuilder text, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth) { batch.DrawString(this.Font, text, position, color, rotation, origin, scale, effects, layerDepth); } } }