mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-22 18:29:30 +00:00
66277568c8
* Update file header * Created initial project to move BitmapFont too * XMl, Text, and Binar reading now supported for BMFont * Refactor BittmapFont * Update content pipeline from BitmapFont refactor * Update changelog
55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using Microsoft.Xna.Framework.Content.Pipeline;
|
|
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
|
|
|
|
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 "MonoGame.Extended.BitmapFonts.BitmapFont, MonoGame.Extended";
|
|
}
|
|
|
|
public override string GetRuntimeReader(TargetPlatform targetPlatform)
|
|
{
|
|
return "MonoGame.Extended.BitmapFonts.BitmapFontReader, MonoGame.Extended";
|
|
}
|
|
}
|
|
}
|