From ZDoom Wiki
Jump to navigation Jump to search

void SetFont (str fontlump);


Sets the current font (within only the script) to fontlump, which is a lump you can make using imagetool. In addition to anything defined in FONTDEFS, ZDoom has the following available fonts:

Fixed width, this is the same font used in the console
The standard small font (shown for between level text). Default.
An alternate small font, found only in Strife. In other games, this is an alias to SMALLFONT.
Larger version of the font (used for level names on intermission screens).

Once the font is set, the remaining Print, PrintBold, HudMessage and HudMessageBold commands will use that font. You may also check if the font exists by using CheckFont.


This example is a rather useful script that displays an objective for all the players, and each objective only appears once ever.

#define numobjs 4
str objs[4] =
{"Gain access to the warehouse",
"Restart the generator",
"Defeat the intruders and\nsecure the warehouse",
"Evacuate to the helipad"};

script 255 (int num)
	if (num >= 1 && num <= numobjs)
		if (objs[num - 1] != "")
			HudMessageBold(s:"New objective:\n", l:objs[num - 1];
				HUDMSG_TYPEON | HUDMSG_LOG, 0, CR_TAN, 1.5, 0.5, 5.0, 0.01, 1.0);
			objs[num - 1] = "";

The first block of code sets up the data for the objectives. This can be freely modified. In the script, the first “if” statement checks if the objective number is valid, and the second checks if the objective has not already been shown. Then the font is set to the large intermission font. Finally the objective is displayed and then removed from the list.

It is also interesting to note that in combination with HudMessage, SetFont can be used to display pictures. Simply place an image into your wad and use SetFont with the image's name. Then create a HudMessage with the letter “A” as the text.

script 2 (void)
	HudMessage(s:"A"; HUDMSG_PLAIN, 0, CR_UNTRANSLATED, 0.1, 0.8, 3.7);

See also