1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-27 23:08:35 +01:00

Compare commits

..

No commits in common. "3e76364c5d6b861fc0a097704566aad46469b926" and "17b6a3297aa26f5964b4d7076add3656fed9e972" have entirely different histories.

3 changed files with 7 additions and 21 deletions

View file

@ -29,7 +29,6 @@ Improvements
Fixes Fixes
- Fixed TextInput not working correctly when using surrogate pairs - Fixed TextInput not working correctly when using surrogate pairs
- Fixed InputHandler touch states being initialized incorrectly when touch handling is disabled - Fixed InputHandler touch states being initialized incorrectly when touch handling is disabled
- Fixed empty NinePatch regions stalling when using tile mode
### MLEM.Ui ### MLEM.Ui
Additions Additions
@ -51,7 +50,6 @@ Fixes
### MLEM.Extended ### MLEM.Extended
Improvements Improvements
- Updated to FontStashSharp 1.3.0's API - Updated to FontStashSharp 1.3.0's API
- Expose character and line spacing in GenericStashFont
### MLEM.Data ### MLEM.Data
Fixes Fixes

View file

@ -11,7 +11,6 @@ namespace MLEM.Extended.Font {
/// The <see cref="SpriteFontBase"/> that is being wrapped by this generic font /// The <see cref="SpriteFontBase"/> that is being wrapped by this generic font
/// </summary> /// </summary>
public readonly SpriteFontBase Font; public readonly SpriteFontBase Font;
/// <inheritdoc /> /// <inheritdoc />
public override GenericFont Bold { get; } public override GenericFont Bold { get; }
/// <inheritdoc /> /// <inheritdoc />
@ -19,15 +18,6 @@ namespace MLEM.Extended.Font {
/// <inheritdoc /> /// <inheritdoc />
public override float LineHeight => this.Font.LineHeight; public override float LineHeight => this.Font.LineHeight;
/// <summary>
/// The character spacing that will be passed to the underlying <see cref="Font"/>.
/// </summary>
public float CharacterSpacing { get; set; }
/// <summary>
/// The line spacing that will be passed to the underlying <see cref="Font"/>.
/// </summary>
public float LineSpacing { get; set; }
/// <summary> /// <summary>
/// Creates a new generic font using <see cref="SpriteFontBase"/>. /// Creates a new generic font using <see cref="SpriteFontBase"/>.
/// Optionally, a bold and italic version of the font can be supplied. /// Optionally, a bold and italic version of the font can be supplied.
@ -43,12 +33,12 @@ namespace MLEM.Extended.Font {
/// <inheritdoc /> /// <inheritdoc />
protected override float MeasureCharacter(int codePoint) { protected override float MeasureCharacter(int codePoint) {
return this.Font.MeasureString(CodePointSource.ToString(codePoint), null, this.CharacterSpacing, this.LineSpacing).X; return this.Font.MeasureString(CodePointSource.ToString(codePoint)).X;
} }
/// <inheritdoc /> /// <inheritdoc />
protected override void DrawCharacter(SpriteBatch batch, int codePoint, string character, Vector2 position, Color color, float rotation, Vector2 scale, SpriteEffects effects, float layerDepth) { protected override void DrawCharacter(SpriteBatch batch, int codePoint, string character, Vector2 position, Color color, float rotation, Vector2 scale, SpriteEffects effects, float layerDepth) {
this.Font.DrawText(batch, character, position, color, rotation, Vector2.Zero, scale, layerDepth, this.CharacterSpacing, this.LineSpacing); this.Font.DrawText(batch, character, position, color, rotation, Vector2.Zero, scale, layerDepth);
} }
} }

View file

@ -158,13 +158,11 @@ namespace MLEM.Textures {
case NinePatchMode.Tile: case NinePatchMode.Tile:
var width = src.Width * patchScale; var width = src.Width * patchScale;
var height = src.Height * patchScale; var height = src.Height * patchScale;
if (width > 0 && height > 0) { for (var x = 0F; x < rect.Width; x += width) {
for (var x = 0F; x < rect.Width; x += width) { for (var y = 0F; y < rect.Height; y += height) {
for (var y = 0F; y < rect.Height; y += height) { var size = new Vector2(Math.Min(rect.Width - x, width), Math.Min(rect.Height - y, height));
var size = new Vector2(Math.Min(rect.Width - x, width), Math.Min(rect.Height - y, height)); var srcSize = (size / patchScale).CeilCopy().ToPoint();
var srcSize = (size / patchScale).CeilCopy().ToPoint(); batch.Draw(texture.Region.Texture, new RectangleF(rect.Location + new Vector2(x, y), size), new Rectangle(src.X, src.Y, srcSize.X, srcSize.Y), color, rotation, origin, effects, layerDepth);
batch.Draw(texture.Region.Texture, new RectangleF(rect.Location + new Vector2(x, y), size), new Rectangle(src.X, src.Y, srcSize.X, srcSize.Y), color, rotation, origin, effects, layerDepth);
}
} }
} }
break; break;