Using another font than the GD default one?

Hi GD Gurus,
I’m using the natve form of GD on Windows 10.
I would like to use ‘Microsoft San Serif Normal’ font for ALL my Text objects.
I have so many different Text objects in different scenes!
Is there a way to define ONCE (not for each individual Text Object) a kind of ‘new default font’ GD would use instead of the default font it is using currently?
When the game is compiled and then installed to a target PC, should I copy?/install? the ‘new default font’ file to a target PC specific directory?
Many thanks in advance,
Regards,
Damien.

1 Like

The font in added to the game on export, so the people who install your game doesn’t have to install the font :slight_smile:

There is no way to change the font of all the text objects at once right from GD. However, if you know how, you could open the project file in a text editor, and search/replace every occurrence of a text object with a default font to use your custom font. But you should check how a text object with default font is stored and how to change it. Of course if you do it make a backup of the project file first.

Hi Lizard,
Thank you so much for your fast reply :slight_smile:
It is the first time I realize a .gdg file is actually an xml file… But it makes perfect sense.
I agree wit you. We “should” never open/edit/modify it with a “normal” editor… or at least with extreme care (hence your recommendation to backup this file first :smiling_imp: )
I was expecting to find the name of the default font in each TextObject contained in this gdg/xml file… and to replace it by the ‘Microsoft Sans Serif’ TrueType font.
But unfortunately the font name is not in the object XML tag (example of one of my many TextObjects below)

Where (in which file?) to find (and potentially modify/hack :stuck_out_tongue: ) the default font name GD is using?

Best Regards,
Damien.

Hum… There is definitely a element in each TextObject
My question should be “What is the exact syntax to use to modify the default font () by the ‘Microsoft Sans Serif’ one”?

Actually, I have never succeeded changing the default font by using the GD ‘Text editor window’!
It is extremely easy to modify the default font size, color, characteristic (Bold, Italic, Underlined). But when I try to change the font file (ex: ‘micross.ttf’ for Microsoft Sans Serif) it does not seem to work… Or I have definitely missed something here! Any help would be REALLY appreciated…

I do not really like the idea of modifying/hacking the .gdg file (or any other file) :stuck_out_tongue: but I’m OK to do it ONLY if this is the ONLY way to use the ‘Microsoft Sans Serif’ font for all my TextObjects :wink:
Thanks,
Damien.

OK… I have found my mistake…

Using the TextObject editor I was just doing a ‘copy & paste’ of the font file name (ex: ‘micross.ttf’) to specify the font I wanted.

BUT you need FIRST to copy the font file itself (from the Windows Font directory - :\Windows\Fonts) to the GD project directory (where the project.gdg file is)

Once you have copied this font file, everything works:

  • Replacing the default font name by the one you want using the GD TextObject Editor
  • Using the GD Action: “Changer la police de en micross.ttf”
  • …and Lizard hack :slight_smile: : patching the gdg/xml file to change for each TextObject the default font name () by micross.ttf

Thanks again Lizard. I have learned a lot of things… And my game is now using the right font :slight_smile:
Best Regards,
Damien.

1 Like

Nice, and sorry for that, I assumed you already had some objects using the custom font, to compare the tags of the objects using default and custom fonts :slight_smile:

Hello. I read your discussion.

I have a slightly different problem. I copied a new font to the project folder and then entered the path from the text object. A really new font will appear in the scene window. But when I release the player, the original font is displayed. In addition, even the scene window, before the player is released, has the last letter cut off. Even if I extend the window of the object.

Could someone please advise what I’m not doing well?

Thank you.

the font type is work fine for me. I set it up inside GDevelop, in the text object’s properties tab. are you sure you’ve set everything up correctly?