summaryrefslogtreecommitdiff
path: root/Plugins/MonoGame.Extended/source/MonoGame.Extended.Content.Pipeline/BitmapFonts/BitmapFontProcessor.cs
blob: a859eb531c3ce5185183a20b56a35a67f9c8495f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.IO;
using Microsoft.Xna.Framework.Content.Pipeline;

namespace MonoGame.Extended.Content.Pipeline.BitmapFonts
{
    [ContentProcessor(DisplayName = "BMFont Processor - MonoGame.Extended")]
    public class BitmapFontProcessor : ContentProcessor<BitmapFontFile, BitmapFontProcessorResult>
    {
        public override BitmapFontProcessorResult Process(BitmapFontFile bitmapFontFile, ContentProcessorContext context)
        {
            try
            {
                context.Logger.LogMessage("Processing BMFont");
                var result = new BitmapFontProcessorResult(bitmapFontFile);

                foreach (var fontPage in bitmapFontFile.Pages)
                {
                    var assetName = Path.GetFileNameWithoutExtension(fontPage.File);
                    context.Logger.LogMessage("Expected texture asset: {0}", assetName);
                    result.TextureAssets.Add(assetName);
                }

                return result;
            }
            catch (Exception ex)
            {
                context.Logger.LogMessage("Error {0}", ex);
                throw;
            }
        }
    }
}