It'sNotALie.
It'sNotALie.

Reputation: 22794

How to make a .spritefont into Monogame?

I have tried the XNA Content Compiler, but it just spits out an error:

There was an error while deserializing intermediate XML. String must be exactly one character long.

My .spritefont file is this:

<?xml version="1.0" encoding="utf-8"?>

<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
  <Asset Type="Graphics:FontDescription">
    <FontName>Miramonte</FontName>
    <Size>18</Size>
    <Spacing>0</Spacing>
    <UseKerning>true</UseKerning>
    <Style>Regular</Style>
    <CharacterRegions>
      <CharacterRegion>
        <Start>32</Start>
        <End>127</End>
      </CharacterRegion>
    </CharacterRegions>
  </Asset>
</XnaContent>

Is there any way to make a .spritefont file for MonoGame?

Upvotes: 2

Views: 7179

Answers (2)

Sergio Porres
Sergio Porres

Reputation: 67

Nahuel's answer works. However, its no longer needed. MonoGame 3.3+ will build the XNB files through the Project Pipeline https://gamedev.stackexchange.com/questions/96793/monogame-3-3-font-loading

Upvotes: 1

Nahuel Ianni
Nahuel Ianni

Reputation: 3185

You can find a tutorial (written by me) explaining exactly how to use spritefonts in Monogame here.

But basically, all you need to do is:

  • Create a new Game project with XNA.
  • Add the desired spritefont to the content project.
  • Compile.
  • Go to the output folder and copy the spritefont xnb file to your monogame one (add it on the Content folder).
  • Change it's properties to "Content" and "Copy if newer" so that it works.

enter image description here

Then you can use it as you would in a typical XNA game.

As of today, I have not been able to find another way to load them without needing XNA. Same goes for sound files. You need to generate the xnb files by using the Content project provided by XNA.

Remember that you can install XNA on VS 2012+ and Windows 8 without a problem thanks to XNA Refresh.

Upvotes: 2

Related Questions