mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 03:56:31 +00:00
3a5269cfea
* Removed MonoGame.Extended.Animations This project was just a shell that referenced MonoGame.Extended.csproj. It added no additional functionality. * Rework BitmapFonts for new project organization. * Cleanup namespaces * Cleanup namespaces * Move MonoGame.Extended.Collision into base project * Moved MonoGame.Extended.Entities into base project * Moved MonoGame.Extended.Graphics into base project * Moved MonoGame.Extended.Graphics into base project * Moved MonoGame.Extended.Input into base project * Moved MonoGame.Extended.Particles into base project * Moved MonoGame.Extended.Tiled into base project * Moved MonoGame.Extended.Tiled into base project * Moved MonoGame.Extended.Tweening into base project * Removing SpriteFactory support This will be added back in at a later date once the SpriteFactory application has been updated * Update TexturePacker content import support * Only needs to reference base project now * Moved to Serialization namespace * Moved Json serialization to Serialization.Json namespace * Moved TexturePacker content DTOs to the Content namespace * Renamed to Texture2DRegion.Extensions.cs * Cleaned up namespace * Moved ReadTiledMapProperties into the ContentReaderExtensions * Created an Extended content manager * Moved Tweening tests to base test project * Moved Tiled test to base test project * Moved Entities Tests to base test project * Moved Entities tests to base test project * Moved Collisions tests to base test project * Moved Pipeline Tiled test to Pipeline tests project * Use `var` instead of full type name * Add Tiled namespace * Correct `Metadata` property name to new `Meta` property name * Cleanup namespace * Add effects namespace * Add Content namespace * Update using statements to new namespaces * Move Pipeline Tiled tests to Pipeline test project * Use correct namespace * Use `var` instead of typing out nested types * Remove unused namespaces * Update to new namespaces * Remove unused namespaces * Update to new namespaces * Remove dependency on Particles csproj * Update included content on build * Add embedded resources * Merge multi csproj structure into single csproj structure * TexturePackerPoint properties should be `double` not `int` * Update csproj * Use dotnet tool to rebuild effects * Move effect compilation to targets file This will ensure the effects are always built * Fix workflow to build effects on linux * Set wine path * Export instead of using actions env section * Revert back to manual effect compile until automation can be solved on GitHub Ubuntu runner
144 lines
4.3 KiB
C#
144 lines
4.3 KiB
C#
// Copyright (c) Craftwork Games. All rights reserved.
|
|
// Licensed under the MIT license.
|
|
// See LICENSE file in the project root for full license information.
|
|
|
|
|
|
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using MonoGame.Extended.Content.BitmapFonts;
|
|
|
|
namespace MonoGame.Extended.BitmapFonts.Tests;
|
|
|
|
public class BitmapFontFileReaderTests
|
|
{
|
|
private readonly BitmapFontFileContent _expected;
|
|
|
|
public BitmapFontFileReaderTests()
|
|
{
|
|
_expected = CreateExpected();
|
|
}
|
|
|
|
private static BitmapFontFileContent CreateExpected()
|
|
{
|
|
BitmapFontFileContent bmfFile = new BitmapFontFileContent()
|
|
{
|
|
Header = new()
|
|
{
|
|
B = (byte)'B',
|
|
M = (byte)'M',
|
|
F = (byte)'F',
|
|
Version = 3
|
|
},
|
|
Info = new()
|
|
{
|
|
FontSize = 32,
|
|
BitField = 0b1100_0000,
|
|
CharSet = 0,
|
|
StretchH = 50,
|
|
AA = 1,
|
|
PaddingUp = 1,
|
|
PaddingRight = 2,
|
|
PaddingDown = 3,
|
|
PaddingLeft = 4,
|
|
SpacingHoriz = 6,
|
|
SpacingVert = 5,
|
|
Outline = 2
|
|
},
|
|
FontName = "Cute Dino",
|
|
Common = new()
|
|
{
|
|
LineHeight = 16,
|
|
Base = 12,
|
|
ScaleW = 256,
|
|
ScaleH = 256,
|
|
Pages = 1,
|
|
BitField = 0b0000_0000,
|
|
AlphaChnl = 1,
|
|
RedChnl = 0,
|
|
GreenChnl = 0,
|
|
BlueChnl = 0,
|
|
}
|
|
};
|
|
|
|
bmfFile.Pages.Add("test-font_0.png");
|
|
bmfFile.Characters.Add(new()
|
|
{
|
|
ID = 70,
|
|
X = 34,
|
|
Y = 0,
|
|
Width = 27,
|
|
Height = 20,
|
|
XOffset = -5,
|
|
YOffset = -3,
|
|
XAdvance = 17,
|
|
Page = 0,
|
|
Chnl = 15
|
|
});
|
|
bmfFile.Characters.Add(new()
|
|
{
|
|
ID = 74,
|
|
X = 0,
|
|
Y = 0,
|
|
Width = 28,
|
|
Height = 20,
|
|
XOffset = -6,
|
|
YOffset = -3,
|
|
XAdvance = 18,
|
|
Page = 0,
|
|
Chnl = 15,
|
|
});
|
|
|
|
bmfFile.Kernings.Add(new()
|
|
{
|
|
First = 70,
|
|
Second = 74,
|
|
Amount = -1
|
|
});
|
|
|
|
return bmfFile;
|
|
}
|
|
|
|
[Fact]
|
|
public void Read_BinaryFile_Test()
|
|
{
|
|
using FileStream stream = File.OpenRead("BitmapFonts/files/bmfont/test-font-binary.fnt");
|
|
var actual = BitmapFontFileReader.Read(stream);
|
|
Assert.Equal(_expected.Header, actual.Header);
|
|
Assert.Equal(_expected.Info, actual.Info);
|
|
Assert.Equal(_expected.Common, actual.Common);
|
|
Assert.Equal(_expected.FontName, actual.FontName);
|
|
Assert.True(_expected.Pages.SequenceEqual(actual.Pages));
|
|
Assert.True(_expected.Characters.SequenceEqual(actual.Characters));
|
|
Assert.True(_expected.Kernings.SequenceEqual(actual.Kernings));
|
|
}
|
|
|
|
[Fact]
|
|
public void Read_XmlFile_Test()
|
|
{
|
|
using FileStream stream = File.OpenRead("BitmapFonts/files/bmfont/test-font-xml.fnt");
|
|
var actual = BitmapFontFileReader.Read(stream);
|
|
Assert.Equal(_expected.Header, actual.Header);
|
|
Assert.Equal(_expected.Info, actual.Info);
|
|
Assert.Equal(_expected.Common, actual.Common);
|
|
Assert.Equal(_expected.FontName, actual.FontName);
|
|
Assert.True(_expected.Pages.SequenceEqual(actual.Pages));
|
|
Assert.True(_expected.Characters.SequenceEqual(actual.Characters));
|
|
Assert.True(_expected.Kernings.SequenceEqual(actual.Kernings));
|
|
}
|
|
|
|
[Fact]
|
|
public void Read_Text_Test()
|
|
{
|
|
using FileStream stream = File.OpenRead("BitmapFonts/files/bmfont/test-font-text.fnt");
|
|
var actual = BitmapFontFileReader.Read(stream);
|
|
Assert.Equal(_expected.Header, actual.Header);
|
|
Assert.Equal(_expected.Info, actual.Info);
|
|
Assert.Equal(_expected.Common, actual.Common);
|
|
Assert.Equal(_expected.FontName, actual.FontName);
|
|
Assert.True(_expected.Pages.SequenceEqual(actual.Pages));
|
|
Assert.True(_expected.Characters.SequenceEqual(actual.Characters));
|
|
Assert.True(_expected.Kernings.SequenceEqual(actual.Kernings));
|
|
}
|
|
}
|