Sign in to follow this  
jcsnider

Replacing Fonts and Adding Font Characters

Recommended Posts

Replace Fonts/Adding Font Characters in Intersect!

Date: August 14th 2016

Guide written for Intersect Alpha 1.8+

 

 

Summary:

This guide will show you how to re-generate the fonts (.xnb) files distributed with the Intersect engine. This will allow you to change the font, some styling options and add/remove characters from in-game fonts. This guide only covers the client not the editor or server. 

 

Requirements:

Before getting started you should visit http://www.monogame.net/downloads/ and download/install the MonoGame 3.5 (as of Alpha 1.8) package. This should install tools on your computer that are required to generate the new font files.

 

I /recommend/ that you download and install Notepad++. You will need a good text editor for this guide. I use Notepad++ on a daily basis and it is really good software. Other software like vim and even standard notepad should work but I make no guarantees.

 

Table Of Contents:

 

 

 

MonoGame Content.zip

Share this post


Link to post
Share on other sites

1. Download/Open the Content Pipeline

 

1.1 Download the Content Pipeline

This is the MonoGame Content pipeline for Intersect. This allows us to compile fonts and shaders for Intersect. In this guide we are only going to discuss shaders. Go ahead and download the content project by clicking the attachment below.  After you download that zip go ahead and extract it anywhere on your machine.

MonoGame Content.zip

 

1.2 Open the Content Project

After you extract this double click the Content.mgcb file. That should open the content pipeline.

80ca9bb069fdc2e360a3218dd5abe59e.png

 

1.3 Content Pipeline Layout

in the Fonts and Shaders folders you will find the raw shader and font information. This information is used to generate .xnb files which the engine actually reads. In section 3 I will go over all of the options in the spritefont files.

Share this post


Link to post
Share on other sites

2. Edit the Font Files

 

2.1 Opening Font Files

In the Content Pipeline expand the Fonts folder and double click on any of the sprite font files. We have a different spritefont for every text size, so any changes you make to one you will want to make to all the others. When asked I recommend telling windows to open the .spritefont files with Notepad++.

 

2.1.1 Explanation of Options

This should be pretty self explanatory. Going to show the first part of the spritefont file along with the comments provided by the MonoGame team.

a98d6752cfcd8a7e8c12fe7ba68dd4d0.png

 

 

2.2 Adding Character Regions

Character regions are defined at the bottom of the .spritefont files. You can define as many regions as you like. In each region you can type in the character the region starts at and the ending character. You can enter characters literally or as their unicode values. You can find unicode ranges to use in these files at this site: http://jrgraphix.net/r/Unicode/  Example below:

b927c317f79d624206d69df2a59a0f77.png

 

2.2.1 The Character Map Tool

There is a really nice tool on Windows called the Character map tool. You can find it by clicking start and typing Character Map.  You can use this tool to retrieve character values for your spritefonts. 

a3b6eaa5c18897828cbf73431c07e101.png

Please note, you should not try to enter a range covering every Unicode value. There are simply too many characters. Your spritefonts would be massive and they wouldn't even generate successfully.

 

Share this post


Link to post
Share on other sites

3. Building the Content

 

3.1 How to Compile Everything

This part is easy. When you are done modifying your spritefonts you can save them and then go back to your content pipeline. To compile new fonts for your game just click Build > Rebuild.

4a01148962f309158819fe87ceb163ce.png

 

The pipeline will tell you how compiling goes and if there are problems the status window will tell you more.

a566536790cd856e310fe9a65f5c4a63.png

 

 

3.2 Installing the New Fonts

After everything is compiled you can find your new fonts in the Content/bin/Windows/Fonts/ folder. You can copy those font files over the existing ones in the Client/Resources/Fonts directory. Overwriting those files and restarting the client is all you should have to do.

 

 

Share this post


Link to post
Share on other sites

That's basically it. This is very standard for MonoGame projects. I referenced this stackoverflow post when making this one - http://stackoverflow.com/questions/13243130/how-to-draw-special-characters-in-xna

 

With this you can go as far as adding non-latin characters to your games. You can change the font-faces (but don't rename the files, they are hard coded for now) and you can change font sizes.  After multi-language support is in and the source is released you will be able to take this a few steps further but that is a guide for another day.

Share this post


Link to post
Share on other sites

I am trying to put in a font that i like and i changed them all but the rebuild isn't working and I don't understand what it is that i'm doing wrong. I fixed where the error codes were but I'm still not getting the rebuild correct.

Share this post


Link to post
Share on other sites
2 minutes ago, merilwen91 said:

I am trying to put in a font that i like and i changed them all but the rebuild isn't working and I don't understand what it is that i'm doing wrong. I fixed where the error codes were but I'm still not getting the rebuild correct.

 

What's the error message?

Share this post


Link to post
Share on other sites
1 minute ago, merilwen91 said:

font description has unexpected error

 

Make sure you have written the font name correctly, did you try with others fonts?

If you can, would be good to know what font are you trying to rebuild, the name who appear in the Windows font folder 

Share this post


Link to post
Share on other sites
15 minutes ago, Refur said:

 

Make sure you have written the font name correctly, did you try with others fonts?

If you can, would be good to know what font are you trying to rebuild, the name who appear in the Windows font folder 

I found a game font online Alagard. Free to use but as I try and get the font to work it wont. I've tried other ones Bradley Hand ITC it worked. But for some reason this one wont. Is it just because I found it online?

 

UPDATE: Ok so I got the build to work. BUT now I cant get the fonts to load in the game error log keeps saying No Fonts!

Share this post


Link to post
Share on other sites
11 minutes ago, merilwen91 said:

I found a game font online Alagard. Free to use but as I try and get the font to work it wont. I've tried other ones Bradley Hand ITC it worked. But for some reason this one wont. Is it just because I found it online?

 

Did you install the font in your computer?

Share this post


Link to post
Share on other sites
56 minutes ago, Gravelord said:

Why is there such a run around for something so simple as adding/replacing a font? Is there a technical reason as to why one cannot simply use a font file type and drag/drop? 

 

The short answer is that the MonoGame library we use dictates how we load content. There are easy workarounds for graphics and audio to not use their content system but not for shaders or fonts. (This isn't necessarily a bad thing.)

 

What this content app basically does, is it takes the font files and creates an image with all of the letters on it along with a map for Intersect to read on where each letter exists. All of this is loaded onto the graphics card when the engine starts.  Depending on how many characters your game allows these images and maps can get really really large so trying to create them every time the engine is ran would be unbearable.

 

We can't simply draw from font files themselves because we'd have to load the characters into memory every single time we use them, that would destroy our fps because sending graphics from the cpu to the graphic card takes way too much time.

 

This isn't to say that we're incapable of creating easier/better ways of doing this but there are far more important tasks at hand -- we don't have time to replace working systems at the moment.

 

Hope this helps!

 

Share this post


Link to post
Share on other sites

Assuming you're talking about the client/resources/config.xml you'd still be required to use the MonoGame content manager to actually create the font files. The MonoGame fonts have to exist in the games /resources/fonts folder. The fonts installed in the system folders of your players do not matter whatsoever.

 

If you're talking about the config files included in the download with the content manager (arial12.xml or whatever) then yes you can change the font name in there to whatever and it will work.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this