I keep getting this error while trying to add a font to my game.
I followed this guide: https://docs.monogame.net/articles/content/adding_ttf_fonts.html
Would very appreciate any help.
Hi @Cedrus Welcome to the Community!
What platform are you targeting with your project?
Happy Coding!
EDIT
Also, where are you getting the error?
EDIT
I am assuming with the MGCB, which version are you using?
@MrValentine
Platform: Windows
Where: In the pipeline while trying to build.
MGCB version: not sure how to check that
How did you install MonoGame?
Going to assume you are using 3.7.1 then… try updating to 3.8.
That didn’t work.
Do you have any other suggestions?
Post a screenshot of the exact error, and someone may be able to assist further.
The problem is a direct mgcb importer for .ttf files doesn’t exist, I don’t think it ever has. If you think about it logically when seeing the documentation; Do you need to add the arial .ttf when using arial in your project. You do not, however you reference it from the .spritefont file
You need to remove it from the .mgcb file. Just type the FontName like this, you’ll have to verify the spelling yourself <FontName>Infinite Ocean Font 8.ttf</FontName>
It’s possible that spaces will not be handled well though so you might rename the file if needs be
Edit: I might have jumped the gun a little, so your problem may be something else. But I see the .ttf file in your .mgcb and I don’t think it’s supposed to be there. And you need to post the full error message, the contents of your spritefont file, and maybe even the .mgcb file
LOL I was wondering, what the hell… then I scrolled up… nice.
EDIT
meh REDACTED
EDIT
In case you are not already aware, when someone already in your thread clicks into the thread, they will no longer see the first post unless they scroll up to it.
So, umm, post a single new post and edit it if you must add more details.
The full error is what’s over in the image. There is nothing beyond it I can show.
Regardless I tried removing the .tff file and it did nothing. I also tried entering any other font name than Arial and the same error occurs
Did you try removing spaces?
The image doesn’t even show the full error, it’s cropped because the window needs to be resized to fit the whole text box. And what about the spritefont file and the mgcb file?
Tried. Did not work.
Share the actual Spritefont file code… like this:
<?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> </Start>
<End>~</End>
</CharacterRegion>
</CharacterRegions>
</Asset>
</XnaContent>
But looks like your system needs a reboot too lol
<!--
Modify this string to change the font that will be imported.
-->
<FontName>Infinite Ocean Font 8</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> </Start>
<End>~</End>
</CharacterRegion>
</CharacterRegions>
Is that a font you have installed or the name you want it to have?
I figured it was your project name…
EDIT
Also, the Snip and Sketch tool has a rectangle selection option, you could use that and paste it in here instead of a full screen screenshot…
It’s the name of the installed font
Have you tried restarting your system recently?
EDIT
Also, is that the whole Spritefont file?
EDIT
Another thing, try another obscure font you may have, I suspect it might be an issue with that font…