Jump to content

How do I make new typefaces and fonts?


Perzival12
 Share

Recommended Posts

In r28 the font engine got replaced, so you could use any FreeType or OpenType font. All you have to do is add it in the right location (it's binaries/data/mods/mod/fonts/ by default, but should work with any mod too) and change you config to use them. Here is how that'd need to look in your config: https://gitea.wildfiregames.com/0ad/0ad/src/commit/6ca52a0b23a311910e259cddf4ddab747374f22d/binaries/data/config/default.cfg#L659-L710

If you are stuck with Hyrule Conquest on a27, check out source/tools/fontbuilder2/fontbuilder.py for how to build the font files.

Link to comment
Share on other sites

On 27/2/2026 at 10:37 PM, Dunedan said:

In r28 the font engine got replaced, so you could use any FreeType or OpenType font. All you have to do is add it in the right location (it's binaries/data/mods/mod/fonts/ by default, but should work with any mod too) and change you config to use them. Here is how that'd need to look in your config: https://gitea.wildfiregames.com/0ad/0ad/src/commit/6ca52a0b23a311910e259cddf4ddab747374f22d/binaries/data/config/default.cfg#L659-L710

So if I want to include my new fonts for download in the mod, I have to include a custom config file specifying them? I can’t just specify them in the GUI file that uses them?

Link to comment
Share on other sites

18 minutes ago, trompetin17 said:

Current code only load the file "config/[yourmodname].cfg"

 

15 minutes ago, trompetin17 said:

In the wiki page have some comment how to replace the font from default if you want this.

 image.png

So, my-mod is the top folder name for the mod, correct?

 

EDIT: Correct. This works. But will take a tooooon of GUI editing to make look good, because the current GUI code uses one font style for almost everything. :)

image.pngimage.pngimage.pngimage.png

 

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, wowgetoffyourcellphone said:

 

So, my-mod is the top folder name for the mod, correct?

 

EDIT: Correct. This works. But will take a tooooon of GUI editing to make look good, because the current GUI code uses one font style for almost everything. :)

image.pngimage.pngimage.pngimage.png

 

btw what font are you using? Im seeing some baseline issue (im working on it also)

  • Thanks 1
Link to comment
Share on other sites

32 minutes ago, Grapjas said:

Would love to see an example because i can't find any on 0 a.d. gitea. And i hope we only have to define it once.

Well like stan said, we have the style.xml file concept so you can create your style file then include in your gui .xml file

https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/binaries/data/mods/public/gui/common/styles.xml#L12

https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/binaries/data/mods/public/gui/common/styles.xml#L66

In 0.A.D we have the page concept where you can define what styles to use (you can examine all page_*):

https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/binaries/data/mods/public/gui/page_pregame.xml#L4

and after that the real GUI xml

https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/binaries/data/mods/public/gui/page_pregame.xml#L15

so when we define any element we use the xml tag "Object" + attrbiute "type" to define what object... and you can apply an style with attrbiute "style"

https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/binaries/data/mods/public/gui/page_pregame.xml#L15

or you can explicitly use the "font" attribute if you wan it.

 

Let me know if that help you :).

 

PD: you can test first adding the font you wanna test and replace/add the "font" tag in a particular object to see if that work, after that you can expand the idea with styles.xml and "style" attribute

 

 

Link to comment
Share on other sites

  

56 minutes ago, trompetin17 said:

Well like stan said, we have the style.xml file concept so you can create your style file then include in your gui .xml file

https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/binaries/data/mods/public/gui/common/styles.xml#L12

https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/binaries/data/mods/public/gui/common/styles.xml#L66

In 0.A.D we have the page concept where you can define what styles to use (you can examine all page_*):

https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/binaries/data/mods/public/gui/page_pregame.xml#L4

and after that the real GUI xml

https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/binaries/data/mods/public/gui/page_pregame.xml#L15

so when we define any element we use the xml tag "Object" + attrbiute "type" to define what object... and you can apply an style with attrbiute "style"

https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/binaries/data/mods/public/gui/page_pregame.xml#L15

or you can explicitly use the "font" attribute if you wan it.

 

Let me know if that help you :).

 

PD: you can test first adding the font you wanna test and replace/add the "font" tag in a particular object to see if that work, after that you can expand the idea with styles.xml and "style" attribute

 

 

this is not what i meant but i seem to have misunderstood something anyway. 

 

Edited by Grapjas
Link to comment
Share on other sites

I don't know if that will make more clear or not:

styles.xml files work a bit like CSS files. Let's consider this file to be mystyle.xml

<?xml version="1.0" encoding="utf-8"?>
<styles>
  <style name="TitleText"
         font="myfont-regular-14"
         textcolor="white"
         text_align="center"
         text_valign="center" />
</styles>

for each gui page you need to include the style e.g mypage.xml

<?xml version="1.0" encoding="utf-8"?>
<page>
  <include>mystyle.xml</include>
</page>

Then you can reference it in stuff contained in that page e.g

<?xml version="1.0" encoding="utf-8"?>
<object name="pgToolTip" style="TitleText" type="text" size="100%-313 25 100% 200" />

or

<?xml version="1.0" encoding="utf-8"?>
<object type="text" name="campaignDesc" style="ModernLabelText" font="myfont-regular-14" size="10 10 100%-10 100%-10">

@trompetin17 unless I'm mistaken this does not exist:

<text font="myfont-regular-14" />

and in config/mymod.cfg

[fonts.myfont]
regular = "DejaVuSansMono.ttf", "FreeMono.ttf"

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...