Jump to content
Sign in to follow this  
jcsnider

Replacing Fonts and Adding Font Characters

Recommended Posts

Replace Fonts/Adding Font Characters in Intersect!

Date: Oct. 2nd 2019

Guide written for Intersect Beta 6+

 

 

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.7 (as of Beta 6) 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.

 

The source files you will need can be found in the sources branch of the Intersect Assets repo.  Download Zip.

 

Table Of Contents:

 

 

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 and font source files by clicking here.  After you download that zip go ahead and extract it anywhere on your machine.

 

 

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

How would I go about changing the chat, and character window font? I was able to change the others no problem, but am having a hard time finding where to set these..

Share this post


Link to post
Share on other sites

You have to type in the font name and size for each UI element in the client/Resources/GUI/layouts/ json files. I can be more specific if need be later. (On Mobile atm)

Share this post


Link to post
Share on other sites

how do i add (♥) symbol in sourcesansproblack? since the beta 6 doesn't change the sourcesansproblack font from the UI, even changing the config.json

@edit

ok after 12 hours i got it, i won the tutorial
now why i can't change the game ui font? only chat text

Share this post


Link to post
Share on other sites

That is unicode character U2665:

c5f73739e297b4bd5f78e0892e71e3f0.png

 

 

The source files for the Beta 6 fonts are here.

 

You need to add the following character range to each font file and then rebuild using the content program as described above:

      <!-- Heart Symbol -->
      <CharacterRegion>
        <Start>&#x2665;</Start>
        <End>&#x2665;</End>
      </CharacterRegion>

 

Then overwrite your fonts with the new ones generated.

 

Edit: Updated the OP with a link to the Intersect-Assets sources branch which contains the sourcesanspro font source files.

Share this post


Link to post
Share on other sites

i did everything

ca3fde05eaf3ecb985ca9558efa7275a.png

but only that i write on the chat changed, the event box text doesn't change

78e3e787fb82e04b4fe6b29ce9ddc91c.png

only with source maybe?

@edit
ok trying to change the sourcesanspro 
got stuck

4ad96bb47a9509fdb8eaaf7794c13943.png

what im doing wrong? the problack work normally, but only the problack version still doesn't show a heart symbol on the game...

6f15b6d06328c12c598f1a0b731d0418.png

@edit2

i found the issue, i have to install the sans pro font then change the name from the spritefont files
GG
:2_grimacing:

Share this post


Link to post
Share on other sites

Fonts for individual UI elements are set in the client/resources/gui/layouts/*.json files. 

 

Open any of the client/resources/gui/layouts/game/event jsons and search for sourcesanspro to see what I mean. The font you want to use must be put in there. 

Share this post


Link to post
Share on other sites
On 10/2/2019 at 9:06 AM, jcsnider said:

Fonts for individual UI elements are set in the client/resources/gui/layouts/*.json files. 

 

Open any of the client/resources/gui/layouts/game/event jsons and search for sourcesanspro to see what I mean. The font you want to use must be put in there. 


i get it, json files can edit the UI elements... thank you <3

@edit 10/03/19
even with that
<!-- Heart Symbol --> <CharacterRegion> <Start>&#x2665;</Start> <End>&#x2665;</End> </CharacterRegion> <<(i put that line on every font file then rebuild all ok, put on the folder then replaced)
it seens not changed, it can't appear the heart ♥ in the opened client...gg :/ maybe when source comes out i can make that

60778b529777283a3a7b728d18b3dea8.png

i even tried to change the holl font with one named 'Cloud' that have that heart symbol ♥ in vanilla, like Arial, but even with that, in game client appears only that strange square :(
sad

1c15da76fec5ec0555438fe23f0141b6.png

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  

×
×
  • Create New...