0
\$\begingroup\$

I've been trying to get to work spritefonts, but to no avail. I've added the pipefont to the Pipeline

enter image description here

but when I try to load it, it shows this error here

enter image description here

Here it is the spritefont content

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

<!--
Modify this string to change the font that will be imported.
-->
<FontName>Arial</FontName>

<!--
Size is a float value, measured in points. Modify this value to change
the size of the font.
-->
<Size>12</Size>

<!--
Spacing is a float value, measured in pixels. Modify this value to change
the amount of spacing in between characters.
-->
<Spacing>0</Spacing>

<!--
UseKerning controls the layout of the font. If this value is true, kerning information
will be used when placing characters.
-->
<UseKerning>true</UseKerning>

<!--
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
and "Bold, Italic", and are case sensitive.
-->
<Style>Regular</Style>

<!--
If you uncomment this line, the default character will be substituted if you draw
or measure text that contains characters which were not included in the font.
-->
<!-- <DefaultCharacter>*</DefaultCharacter> -->

<!--
CharacterRegions control what letters are available in the font. Every
character from Start to End will be built and made available for drawing. The
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
character set. The characters are ordered according to the Unicode standard.
See the documentation for more information.
-->
<CharacterRegions>
  <CharacterRegion>
    <Start>&#32;</Start>
    <End>&#126;</End>
  </CharacterRegion>
</CharacterRegions>

Any ideas?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

To be honest I don't really use SpriteFont's myself. I prefer to generate BitmapFont's using BMFont and importing them in with MonoGame.Extended (I'm the creator of that library).

That said, I think I can see the issue pretty quickly. You haven't got an importer or processor set in the Pipeline tool.

When I add a sprite font to the Pipeline the properties window looks like this:

enter image description here

As you can see, the Build Action is set to Build and the importer and processor is also set. This happens by default when you add a new spritefont within the tool.

If you right click the root Content node in the tree and select Add => New Item...

You should see a window like this:

enter image description here

That'll generate a new SpriteFont file and you can open it up in a text editor to change the font. Here's what it looks like on my machine:

<?xml version="1.0" encoding="utf-8"?>
<!--
This file contains an xml description of a font, and will be read by the XNA
Framework Content Pipeline. Follow the comments to customize the appearance
of the font in your game, and to change the characters which are available to draw
with.
-->
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
  <Asset Type="Graphics:FontDescription">

    <!--
    Modify this string to change the font that will be imported.
    -->
    <FontName>Arial</FontName>

    <!--
    Size is a float value, measured in points. Modify this value to change
    the size of the font.
    -->
    <Size>12</Size>

    <!--
    Spacing is a float value, measured in pixels. Modify this value to change
    the amount of spacing in between characters.
    -->
    <Spacing>0</Spacing>

    <!--
    UseKerning controls the layout of the font. If this value is true, kerning information
    will be used when placing characters.
    -->
    <UseKerning>true</UseKerning>

    <!--
    Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
    and "Bold, Italic", and are case sensitive.
    -->
    <Style>Regular</Style>

    <!--
    If you uncomment this line, the default character will be substituted if you draw
    or measure text that contains characters which were not included in the font.
    -->
    <!-- <DefaultCharacter>*</DefaultCharacter> -->

    <!--
    CharacterRegions control what letters are available in the font. Every
    character from Start to End will be built and made available for drawing. The
    default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
    character set. The characters are ordered according to the Unicode standard.
    See the documentation for more information.
    -->
    <CharacterRegions>
      <CharacterRegion>
    <Start>&#32;</Start>
    <End>&#126;</End>
      </CharacterRegion>
    </CharacterRegions>
  </Asset>
</XnaContent>

I hope that helps. Good luck :)

\$\endgroup\$
1
  • \$\begingroup\$ O man, thank you! Yes, it was that the spritefont wasn't set to build (it seems I misunderstood the tutorial I was doing). I will look "Monogame.Extended", maybe that will help me in many ways. \$\endgroup\$
    – user74224
    Jun 25, 2016 at 12:15

You must log in to answer this question.