How to: Edit the GameFont & Religions

Louis the XIV

Sun King
Joined
Jun 23, 2020
Messages
837
Location
Court of Versailles
Hi fellow civ fanatics!
In this tutorial you will learn how to edit a religion and how to edit the game font in 3 easy steps.
Trust me, it's not at all as hard as you think.
REQUIRMENTS:
-Gimp 2.10.22
-Notepad or any XML editor


NOTE: I will not be explaining in detail how to edit the religions. To see more detail visit Ralendil's how to edit Religions tutorial.

Step 1: Editing the Religion
First what you want to do is open the Assets/XML/GameInfo/CIV4ReligionInfos.xml.
You should either do this in a separate mod or create a back up of the original file. I use notepad to open xml files but any other xml editor is efficient.
Then lets say you are doing a mod about Europe and want the Orthodoxy religion instead of Taoism, simply change the <Description>Orthodoxy</Description> then change the sound to CHRISTIAN and there you have it! Now you will need a button for your religion, simply change this path:
Art/Interface/Buttons/Religions/Taoism.dds to Art/Interface/Buttons/Religions/Orthodoxy.dds and remember the path and put in an Orthodox cross or whatever you want in the Religions folder. Remember it has to be dds format.

Set 2: Adding religious Buildings&Units
Go to Assets/XML/Buildings/CIV4BuilgingInfos.xml.
Open it and search for 'Taoism', then first will appear the TAOIST TEMPLE. Change the <Description>Orthodox Temple</Description> then also change the ArtDefines TAOIST_TEMPLE to CHRISTIAN_TEMPLE. At the end also change the sound to CHRISTIAN. Do the same for all the other religious buildings.
For the unit go to Assets/XML/Units/CIV4UnitInfos.xml. Search for Taoist and change the description to Orthodox missionary and the art defines to CHRISTIAN_MISSIONARY.

Step 3: Editing the Game Font.tga (the hard part)
NOTE: In the game font if you even misplace the button by 1 mm then the result will be a mess so be careful!

Open Assets/res/GameFonts/GameFont.tga with Gimp. I am using the previous version of Gimp but it's basically the same.
This part is more complicated so you will need to pay close attention.
After you open the Game font you should see this
upload_2020-10-19_10-14-8.png


Click the fifth tool on the second row called eraser tool and erase the Taoist button as well as the holy city button.

upload_2020-10-19_10-21-50.png


The best way to change a religion is to copy the button from an existing mod, in my example I will be using the Orthodox button from Dawn of Civilization but the Sword of Islam also has it.
Open the game font in another mod that has Orthodoxy and select the third tool on the first row, the crop tool
That tool will let you select only what you want.
Don't worry about messing with the gamefont from another mod cause after this you will discard the changes.
upload_2020-10-19_10-22-28.png


right click Edit > Copy Visible.
Go to your original game font and click the first tool on the first row, the move tool and click Paste.

upload_2020-10-19_10-24-15.png

Then using the move tool move it in the right place.
Now click File > Export As > and then click Export. If it asks you to replace anything click YES.
Then this will show up:
upload_2020-10-19_10-26-23.png

just click Export.
Then click exit and Discard changes, as well as the tga file you took the Orthodox button from, click exit and Discard changes.

Well congratulations! You learned to edit a gamfont and to add a religion in 3 easy steps!
If you didn't understand something very clearly feel free to ask me.
 
Last edited:
Why not use Game Font Editor?

Also each GameFont has an ID, which is assigned in CvGameTextMgr::assignFontIds(). If you want to, then you can mod how the GameFont tga files are converted into ints and that way alter the order of icons, add a new type or whatever. Odds are that you won't need to touch this, but I added it anyway for completion of this topic.
 
Why not use Game Font Editor?

Also each GameFont has an ID, which is assigned in CvGameTextMgr::assignFontIds(). If you want to, then you can mod how the GameFont tga files are converted into ints and that way alter the order of icons, add a new type or whatever. Odds are that you won't need to touch this, but I added it anyway for completion of this topic.
Thanks for letting me know.
So do you think it's possible to make there be 2 holy cities for each religion if the CvGameTextmgr (I'm guessing it's c++) is edited in the correct way?
The reason I don't use GameFont editor is because to add a new button you have to make its shadow or something like that, anyway I would rather use something simple as GIMP.
 

I fully agree. :thumbsup:

Editing GameFonts before we had the GameFont Editor was extremely annoying.
It was incredibly easy to break them and thus having to waste enormous efforts to repair.

But with the GameFont Editor even beginners in graphical modding can modify GameFonts easily.
There is almost no risk to break them. It is extremely simple and efficient to use.

GameFont Editor is one of the best modding tools ever created. :worship:
(It is really beginner friendly and does not require too much graphical skills.)
 
So do you think it's possible to make there be 2 holy cities for each religion if the CvGameTextmgr (I'm guessing it's c++) is edited in the correct way?
I assume you mean two icons because two holy cities with the same icon is unrelated to GameFont.

The answer is yes. You should be able to do that and yes it's C++. You can hack it into python, but that would be really ugly and prone to bugs.
PHP:
for (int i = 0; i < GC.getNumReligionInfos(); i++)
{
    GC.getReligionInfo((ReligionTypes) i).setChar(iCurSymbolID);
    ++iCurSymbolID;
    GC.getReligionInfo((ReligionTypes) i).setHolyCityChar(iCurSymbolID);
    ++iCurSymbolID;
}
That's vanilla code. You add another line for setChar. This new set/get char needs new functions in CvReligionInfo and this class will also need to store the char. You will then add the new icon to CvGameTextMgr::buildCityBillboardIconString in order to display it and for good measure the new getChar function should also be python exposed in case you want to use it in a python screen.

I haven't tested this, but unless the exe is doing some black magic I'm unaware of, this should work.

Also icons added after the symbols might not show up on city billboards (the nameplate on cities on the map). This seems to be a game engine limitation, which is intended to reduce memory usage on the GPU. GameFont chars after symbols can however appear elsewhere as in python screens and text. It's only an issue for billboards.

This is one of the places where there is a difference between BTS and Colonization. For whatever reason, CvGameTextMgr::assignFontIds() has been moved into the exe in Colonization, meaning modding GameFont ID allocation has to be a bit more creative. I have done it in Medieval Conquest and it's totally doable, but it's less trivial to do.
 
I thought of doing this as an idea because as you know a lot of religions have more then one holy city/place.
I was hoping to be able to make religions have 3 buttons, the first is the normal religions, the second is the holy city, and the 3rd is the holy place.
For this I think I will need to do a new tag in the ReligionsInfos.xml that defines how much culture etc.. does the 2nd holy city get.
I'm going to try right now but I don't have high hopes, because I have tried and failed many times to compile a dll. Anyway I will let you know if it works!
And thanks for all your help!
 
Are you sure that's the only place the dll has to be edited to make religions have 3 icons in the game font?
EDIT: I'm using BtS so if you can show me how it's done in BtS I would be most grateful.
 
Last edited:
Does this have to be edited as well?
PHP:
    {
        szString = szString + CvWString::format(L"%c", GC.getReligionInfo((ReligionTypes) iI).getChar());
        szString = szString + CvWString::format(L"%c", GC.getReligionInfo((ReligionTypes) iI).getHolyCityChar());
    }
 
Are you sure that's the only place the dll has to be edited to make religions have 3 icons in the game font?
EDIT: I'm using BtS so if you can show me how it's done in BtS I would be most grateful.
I'm 99% sure. However as I wrote, I haven't tried this specific task specifically. I'm however 100% sure it can be done.

Does this have to be edited as well?
PHP:
    {
        szString = szString + CvWString::format(L"%c", GC.getReligionInfo((ReligionTypes) iI).getChar());
        szString = szString + CvWString::format(L"%c", GC.getReligionInfo((ReligionTypes) iI).getHolyCityChar());
    }
That's createTestFontString, which is Firaxis' own GameFont Debug code. You don't have to update it unless you use it.
 
PHP:
for (int i = 0; i < GC.getNumReligionInfos(); i++)
{
    GC.getReligionInfo((ReligionTypes) i).setChar(iCurSymbolID);
    ++iCurSymbolID;
    GC.getReligionInfo((ReligionTypes) i).setHolyCityChar(iCurSymbolID);
    ++iCurSymbolID;
}
I can't find the code. I think the BtS and Vanilla versions are different or this code is in the H file.
 
Is this going to work?
PHP:
    for (int i = 0; i < GC.getNumReligionInfos(); i++)
    {
        GC.getReligionInfo((ReligionTypes) i).setChar(iCurSymbolID);
        ++iCurSymbolID;
        GC.getReligionInfo((ReligionTypes) i).setHolyCityChar(iCurSymbolID);
        ++iCurSymbolID;
        GC.getReligionInfo((ReligionTypes) i).setHolyCityChar(iCurSymbolID);
        ++iCurSymbolID;
    }
 
Is this going to work?
PHP:
    for (int i = 0; i < GC.getNumReligionInfos(); i++)
    {
        GC.getReligionInfo((ReligionTypes) i).setChar(iCurSymbolID);
        ++iCurSymbolID;
        GC.getReligionInfo((ReligionTypes) i).setHolyCityChar(iCurSymbolID);
        ++iCurSymbolID;
        GC.getReligionInfo((ReligionTypes) i).setHolyCityChar(iCurSymbolID);
        ++iCurSymbolID;
    }
No because you will still end up with two chars, not 3. You just overwrite a holy char with another. You need to add another to CvReligionInfo and then you need to mod the code elsewhere to use the two different holy city chars. You also need to add the new holy city code to the savegame. Ideally you should also add AI code to make the AI care for the new holy cities.

To be brutally honest, I start to suspect you might be in over your head with this one. Yes it can be done, but if you have to ask for confirmation on this part, then I start to worry about the parts you haven't done yet. I'm getting the feeling that you haven't tried modding the DLL before and this is not a good first task.
 
Top Bottom