How exactly do i add new fonts to the game, as unicode fonts?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
aJynks
Posts: 11
Joined: Fri Aug 30, 2024 6:19 pm

How exactly do i add new fonts to the game, as unicode fonts?

Post by aJynks »

Hi there...

I'm just beginning with scripting and finding it a little more challenging than I thought as, imo, the docs are more for reference than for telling you how things are actually done! I'm getting most of my info from the zdoomWiki..

I have this test code...

Code: Select all

class testText : EventHandler {
    override void RenderOverlay(RenderEvent c) {
        //HUDFont myfont = HUDFont.Create(smallfont);
        HUDFont myfont = HUDFont.Create(infofont);
        
        Statusbar.DrawString(myfont, "This is a Testing", (53,-43),
        Statusbar.DI_SCREEN_LEFT_BOTTOM | Statusbar.DI_TEXT_ALIGN_RIGHT,
        Font.CR_RED);
    }
}
This works perfectly using the "smallfont"... but if I use my testFont.. it errors.

I have made a directory /fonts/infofont and in it I have placed png files of all the font characters, as exported from "UDFC_TEST_KOREANS" exporter. The thing is that the docs do not tell you, or at least I do not understand where it tells me, how to use the fonts. All it says is literally
To add a Unicode font, follow these steps:
  • Generate a series of PNG images where each image represents one glyph of the font. This can be done with a font generator, like this one.
  • Make sure the name of each image is the Unicode codepoint of the character it represents, in hexadecimal notation. For example the image with the glyph for Latin Capital Letter A must be named 0041.png; glyph with the number 1 should be named 0031.png, and so on. If you're using a font generator, it should take care of this automatically.
  • Place all of the images under the /fonts/<yourfontname>/ folder in your PK3 archive.
So... how exactly do I use this font now that it is "created"?

testFont Files @ufile.io (free anonymous file share website)

PS : this is a cross post form DoomWorld, as I noticed this fourm has a dedicated zscript section, I thought it would be a better place to hang.
PSS : Is there a zscripting / mod editing discord I can hang out in?
aJynks
Posts: 11
Joined: Fri Aug 30, 2024 6:19 pm

Re: How exactly do i add new fonts to the game, as unicode fonts?

Post by aJynks »

seems that "Font.GetFont("infofont")" works....

HUDFont myfont = HUDFont.Create(Font.GetFont("infofont"));
Blue Shadow
Posts: 5019
Joined: Sun Nov 14, 2010 12:59 am

Re: How exactly do i add new fonts to the game, as unicode fonts?

Post by Blue Shadow »

Your error was that you didn't enclose infofont within quotes (it worked with smallfont because it already exists as a Font):

Code: Select all

HUDFont myfont = HUDFont.Create("infofont");
That should do it.
aJynks wrote: Fri Sep 06, 2024 6:29 pm PSS : Is there a zscripting / mod editing discord I can hang out in?
Try the ZDoom Discord server.
aJynks
Posts: 11
Joined: Fri Aug 30, 2024 6:19 pm

Re: How exactly do i add new fonts to the game, as unicode fonts?

Post by aJynks »

thank you!

Return to “Scripting”