From ZDoom Wiki
Jump to navigation Jump to search
Note: This feature is for ZScript only.


native static vararg void DrawText(Font font, int normalcolor, double x, double y, String text, ...)


Used to draw text to the screen. The text is always drawn from the top left point of the bounding box that contains the string. Strings drawn here support escape characters including colors. It's recommended to use the status bar's DrawString function if functionality similar to the HUD is desired. Coordinates are absolute and start from the top left of the screen with positive x values shifting to the right and positive y values shifting downward.

Note: ARGB colors are best specified by a hex value. For instance, if a color of pure red with full opaqueness is desired, the value 0xFFFF0000 should be used. The first FF specifies the alpha, the second FF specifies the level of red, and the next two 00 specify the level of green and blue respectively. If a tag says only "RGB" then the first FF specifying the alpha can be completely left out.

Warning: This can only be called from within functions that are specifically designed to draw HUD elements (e.g. BaseStatusBar's Draw or EventHandler's RenderOverlay).


  • font - The Font to use for drawing the text. Fonts can be created manually or one of the predefined ones can be used. See global variables for available default fonts
  • normalcolor - The color to use for the font. Options include:
  • Font.CR_BRICK
  • Font.CR_TAN
  • Font.CR_GRAY (alternatively Font.CR_GREY)
  • Font.CR_GREEN
  • Font.CR_BROWN
  • Font.CR_GOLD
  • Font.CR_RED
  • Font.CR_BLUE
  • Font.CR_ORANGE
  • Font.CR_WHITE
  • Font.CR_YELLOW
  • Font.CR_UNTRANSLATED (default color for text)
  • Font.CR_BLACK
  • Font.CR_CREAM
  • Font.CR_OLIVE
  • Font.CR_PURPLE
  • Font.CR_CYAN
  • Font.CR_ICE
  • Font.CR_FIRE
  • Font.CR_TEAL
  • x - The x offset for where to draw the text
  • y - The y offset for where to draw the text
  • text - The text to draw to the screen
  • tags - Tags allow for any number of optional arguments to be specified in any order. Tags are set with the following syntax:
Screen.DrawText(myFont, Font.CR_RED, 0, 0, "My string", DTA_Spacing, 5, DTA_Monospace, 1); // etc

with the tag first followed by its value. Valid tags:

  • (int) DTA_CellX - Scale each individual character's width to fit this value. If 0 this is the width of each specific character
  • (int) DTA_CellY - Set the size of the height of each character. This does not scale the character but aligns it to the top of the cell. If 0 this is the font's height + 1
  • (int) DTA_Spacing - Defines the amount of spacing between each individual character
  • Note: Sizes are specified in real pixels and are only scaled by the DTA_CleanNoMove* tags.
  • (int) DTA_TextLen - Cuts the string's tail if it has more characters than this amount
  • (int) DTA_Monospace - Character width is uniform across all characters. Can be one of the following:
  • 0 - Disabled
  • 1 - Align each character to the left of the cell
  • 2 - Align each character to the center of the cell
  • 3 - Align each character to the right of the cell
  • (double) DTA_Alpha - Sets the alpha of the string. A value of 1 is fully opaque while 0 is fully transparent. If less than 1 and DTA_RenderStyle is not specified then the render style is set to Translucent
  • (int) DTA_Color - An ARGB color that the string's final colors (after all other color operations) are blended with
  • (int) DTA_FillColor - An RGB color to stencil on top of the string. If DTA_RenderStyle is not specified then the render style is set to TranslucentStencil if DTA_Alpha is less than one, otherwise setting it to Stencil
  • (bool) DTA_AlphaChannel - If DTA_RenderStyle is not specified then the render style is set to Shaded if a color was specified in DTA_FillColor
  • (int) DTA_ColorOverlay - Applies an ARGB color overlay on top of the string
  • (int) DTA_Desaturate - If DTA_FillColor is set then completely desaturates the string with a value greater than 0. Otherwise scales the desaturation. A value of 255 is fully desaturated while a value of 0 is fully saturated
  • (int) DTA_RenderStyle - Uses FRenderStyle'd definitions to apply a render style to the string. Normal is used if no alpha is specified
  • (int) DTA_LegacyRenderStyle - Similar to DTA_RenderStyle but uses the STYLE_* constants. See: render styles
  • (bool) DTA_Clean - Scale the position and size of the string by CleanXfac and CleanYfac (see global variables for more information)
  • (bool) DTA_CleanNoMove - Similar to DTA_Clean except the string is not repositioned
  • (bool) DTA_CleanNoMove_1 - Similar to DTA_CleanNoMove except it uses CleanXfac_1 and CleanYfac_1 instead (see global variables for more information)
  • (bool) DTA_320x200 - Scale the position and size of the string as though the screen resolution were 320x200
  • (bool) DTA_Bottom320x200 - The same as DTA_320x200 except it scales from the bottom. Used for tall aspect ratios (e.g. 5:4)
  • (bool) DTA_FlipX - Flips each individual character horizontally
  • (bool) DTA_FlipY - Flips each individual character vertically
  • (int) DTA_VirtualWidth - Draws the string as though the screen resolution were this wide
  • (double) DTA_VirtualWidthF - Same as DTA_VirtualWidth but accepts floating point values
  • (int) DTA_VirtualHeight - Draws the string as though the screen resolution were this tall
  • (double) DTA_VirtualHeightF - Same as DTA_VirtualHeight but accepts floating point values
  • (int) DTA_ClipTop - Clip anything above this position on the screen
  • (int) DTA_ClipBottom - Clip anything below this position on the screen
  • (int) DTA_ClipLeft - Clip anything to the left of this position on the screen
  • (int) DTA_ClipRight - Clip anything to the right of this position on the screen
  • Note: Clipping rectangles take precedence over the DTA_Clip* tags
  • (bool) DTA_KeepRatio - If the virtual width or height are set, force a 4:3 aspect ratio when drawing the string


Nuvolachalk.png Note: This article lists no examples. If you make use of this feature in your own project(s) or know of any basic examples that could be shared, please add them. This will make it easier to understand for future authors seeking assistance. Your contributions are greatly appreciated.