Files
MonoGame.Extended/source/MonoGame.Extended.Content.Pipeline/BitmapFonts/BitmapFontWriter.cs
T
Nikos Kastellanos 2bbdc38b51 Kni.Extended (#892)
* KNI projects

* update actions

fixes MSBUILD : error MSB1011: Specify which project or solution file to
use because this folder contains more than one project or solution file.

* remove test for issue #633

* build tests

* KNI TypeReaders

* KNI/XNA compatible code

* GetRuntimeReader from runtime types

* remove MockGameWindow
2024-06-23 22:38:20 -04:00

56 lines
1.8 KiB
C#

using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
using MonoGame.Extended.BitmapFonts;
namespace MonoGame.Extended.Content.Pipeline.BitmapFonts
{
[ContentTypeWriter]
public class BitmapFontWriter : ContentTypeWriter<BitmapFontProcessorResult>
{
protected override void Write(ContentWriter writer, BitmapFontProcessorResult result)
{
writer.Write(result.TextureAssets.Count);
foreach (var textureAsset in result.TextureAssets)
writer.Write(textureAsset);
var fontFile = result.FontFile;
writer.Write(fontFile.FontName);
writer.Write(fontFile.Info.FontSize);
writer.Write(fontFile.Common.LineHeight);
writer.Write(fontFile.Characters.Count);
foreach (var c in fontFile.Characters)
{
writer.Write(c.ID);
writer.Write(c.Page);
writer.Write(c.X);
writer.Write(c.Y);
writer.Write(c.Width);
writer.Write(c.Height);
writer.Write(c.XOffset);
writer.Write(c.YOffset);
writer.Write(c.XAdvance);
}
writer.Write(fontFile.Kernings.Count);
foreach(var k in fontFile.Kernings)
{
writer.Write(k.First);
writer.Write(k.Second);
writer.Write(k.Amount);
}
}
public override string GetRuntimeType(TargetPlatform targetPlatform)
{
return typeof(BitmapFont).AssemblyQualifiedName;
}
public override string GetRuntimeReader(TargetPlatform targetPlatform)
{
return typeof(BitmapFontReader).AssemblyQualifiedName;
}
}
}