Can't build spritefont.

I started learning MonoGame since couple days ago, currently trying to use SpriteFont. But building .spritefont asset always fails with NullReferenceException. Version of the pipeline is 3.8.0.600.

D:/_project/Test2/Test2/Content/Resources/Fonts/DungGeunMo.spritefont: error: Processor ‘FontDescriptionProcessor’ had unexpected failure!
System.NullReferenceException: 개체 참조가 개체의 인스턴스로 설정되지 않았습니다.
위치: Microsoft.Xna.Framework.Content.Pipeline.Processors.FontDescriptionProcessor.FindFont(String name, String style)
위치: Microsoft.Xna.Framework.Content.Pipeline.Processors.FontDescriptionProcessor.Process(FontDescription input, ContentProcessorContext context)
위치: Microsoft.Xna.Framework.Content.Pipeline.ContentProcessor`2.Microsoft.Xna.Framework.Content.Pipeline.IContentProcessor.Process(Object input, ContentProcessorContext context)
위치: MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.ProcessContent(PipelineBuildEvent pipelineEvent)

On 3.7.1 however, it doesn’t generate error. But rasterizing font is crazy slow. I am trying to use font with ~17k glyphs in size of 12pt, and it doesn’t progress at all. I slept about 5 hours after started building font, and it did nothing. I think the pipeline stuck in infinite loop in certain glyph, because removing certain character region from rasterizing does pipeline to work again. But I think it’s slow even without ‘possible infinite loop’ issue, 7 seconds on just about 100 glyphs seems curious to me.

“~17k glyphs”

That’s a lot of glyphs :slight_smile: Remember it is building all those glyphs into a texture, so the result is gonna be very large indeed.

I’m guessing your building an Asian language, in which case you will need to use localised sprite font, and only build the characters you actually need. I did it recently for CJK languages, but I can’t find the resource I followed. Although a quick google search did bring this up which I didn’t know about, sounds useful - http://www.axiomverge.com/blog/localized-font-textures-in-monogame

1 Like

So I changed FontName to use file name instead of font’s stored name, cut down glyphs to 2 sections - Basic Latin and Hangul Syllables, and while it took off NullReferenceException issue that I had before, it still gets stuck in building spritefont again. It seems like this issue is neither caused by my .spritefont file, nor TTF file itself.

EDIT: The version is still 3.8.0.600. Nothing big change was done, except the .spritefont resource file.

Are you embedding the full font subset for a chat interface? I can only imagine that being the real reason why…

Isn’t it possible to load multiple fonts anyway and this would just require you to parse all inputs for Hangul, Latin and such…

My head, OMG Wikipedia……. and then I find out Just the standard associated CJK fonts contain upwards of 90,000 code points………. :scream:

My first thought was to just use a system based UI for chat elements, and forego the process from eating up GPU memory space…

Would like to hear your solution to this as it may affect other users in future too.