1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-05-28 19:13:38 +02:00
MLEM/MLEM/Font/GenericSpriteFont.cs

54 lines
2.6 KiB
C#
Raw Normal View History

2019-08-09 19:28:48 +02:00
using System.Collections.Generic;
2019-08-09 14:26:20 +02:00
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
2019-08-09 19:28:48 +02:00
using MLEM.Extensions;
2019-08-09 14:26:20 +02:00
namespace MLEM.Font {
2020-03-28 22:25:06 +01:00
public class GenericSpriteFont : GenericFont {
2019-08-09 14:26:20 +02:00
public readonly SpriteFont Font;
public override GenericFont Bold { get; }
public override GenericFont Italic { get; }
2020-03-28 22:25:06 +01:00
public override float LineHeight => this.Font.LineSpacing;
2019-08-09 14:26:20 +02:00
public GenericSpriteFont(SpriteFont font, SpriteFont bold = null, SpriteFont italic = null) {
2019-08-09 14:26:20 +02:00
this.Font = font;
this.Bold = bold != null ? new GenericSpriteFont(bold) : this;
this.Italic = italic != null ? new GenericSpriteFont(italic) : this;
2019-08-09 14:26:20 +02:00
}
2020-03-28 22:25:06 +01:00
public override Vector2 MeasureString(string text) {
2019-08-09 14:26:20 +02:00
return this.Font.MeasureString(text);
}
2020-03-28 22:25:06 +01:00
public override Vector2 MeasureString(StringBuilder text) {
2019-08-09 14:26:20 +02:00
return this.Font.MeasureString(text);
}
2020-03-28 22:25:06 +01:00
public override void DrawString(SpriteBatch batch, string text, Vector2 position, Color color) {
2019-08-09 14:26:20 +02:00
batch.DrawString(this.Font, text, position, color);
}
2020-03-28 22:25:06 +01:00
public override void DrawString(SpriteBatch batch, string text, Vector2 position, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) {
2019-08-09 14:26:20 +02:00
batch.DrawString(this.Font, text, position, color, rotation, origin, scale, effects, layerDepth);
}
2020-03-28 22:25:06 +01:00
public override void DrawString(SpriteBatch batch, string text, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth) {
2019-08-09 14:26:20 +02:00
batch.DrawString(this.Font, text, position, color, rotation, origin, scale, effects, layerDepth);
}
2020-03-28 22:25:06 +01:00
public override void DrawString(SpriteBatch batch, StringBuilder text, Vector2 position, Color color) {
2019-08-09 14:26:20 +02:00
batch.DrawString(this.Font, text, position, color);
}
2020-03-28 22:25:06 +01:00
public override void DrawString(SpriteBatch batch, StringBuilder text, Vector2 position, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) {
2019-08-09 14:26:20 +02:00
batch.DrawString(this.Font, text, position, color, rotation, origin, scale, effects, layerDepth);
}
2020-03-28 22:25:06 +01:00
public override void DrawString(SpriteBatch batch, StringBuilder text, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth) {
2019-08-09 14:26:20 +02:00
batch.DrawString(this.Font, text, position, color, rotation, origin, scale, effects, layerDepth);
}
}
}