Structs:Font

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


The Font struct contains functions and data related to the use of fonts in ZScript.

Methods

Static

Static methods require the Font. prefix.

  • int FindFontColor(Name color)
Retrieves a font color. The argument color must be a color name defined in the TEXTCOLO lump.
  • Font FindFont(Name fontname)
Returns a pointer to a font.
  • Font GetFont(Name fontname)
(Need more info)

Dynamic

Dynamic methods must be called on a font-type pointer.

  • int GetCharWidth(int code)
Returns the width of the provided character in the given font.
  • int StringWidth(String code)
Returns the width of the provided string in the given font in pixels.
code: a text string.
  • int GetMaxAscender(String code)
(Need more info)
  • bool CanPrint(String code)
Returns true if the provided string can be printed in the given font.
  • int GetHeight()
Returns the height of the given font in pixels.
  • int GetDisplacement()
(Need more info)
  • String GetCursor()
Returns the character used as a cursor in the given font (see FONTDEFS).
  • double GetBottomAlignOffset(int code)
(Need more info)
  • double GetDisplayTopOffset(int code)
(Need more info)
  • BrokenLines BreakLines(String text, int maxlen)
Breaks the given string into multiple lines (according to the maximum length provided with maxlen), puts them in an instance of a BrokenLines class and returns a pointer to that instance.
BrokenLines methods Count(), StringWidth(int line) and StringAt(int line) can be used to interact with the text.
  • int GetGlyphHeight(int code)
Returns the height of the specified glyph in pixels. For example, myfont.GetGlyphHeight("0") will return the height of the 0 glyph in myfont font.
  • int GetDefaultKerning()
(Need more info)

Font colors

Most string drawing functions in ZScript have a translation argument that allows applying a color translation to the text. The possible color values are specified in the EColorRange enum in the Font class, and they can be retrieved with Font.<desired color>.

Colors can also be specified inside the strings directly, by using the code \c# where # is the desired color letter. The table below lists both the EColorRange values and the \c codes:

The following text colors are supported:

ZScript constant code color Zscript Constant code color
CR_BRICK a ██ reddish brick CR_LIGHTBLUE n ██ light blue
CR_TAN b ██ tan CR_CREAM o ██ cream
CR_GREY or CR_GRAY c ██ gray CR_OLIVE p ██ olive
CR_GREEN d ██ green CR_DARKGREEN q ██ dark green
CR_BROWN e ██ brown CR_DARKRED r ██ dark red
CR_GOLD f ██ gold CR_DARKBROWN s ██ dark brown
CR_RED g ██ red CR_PURPLE t ██ purple
CR_BLUE h ██ blue CR_DARKGRAY u ██ dark gray
CR_ORANGE i ██ orange CR_CYAN v ██ cyan
CR_WHITE j ██ white CR_ICE w ██ ice
CR_YELLOW k ██ yellow CR_FIRE x ██ fire
CR_UNTRANSLATED l use original colors CR_SAPPHIRE y ██ sapphire
CR_BLACK m ██ black CR_TEAL z ██ teal
- Default color for Print messages * Default color for chat messages
+ Default color for PrintBold messages ! Default color for team chat messages