Font Awesome icons for the interface. Maps the icon names ('fa-plus', 'fa-shield-halved' and so on) to the glyphs of the bundled Font Awesome Free fonts, and draws them as text of any size and color with FontAwesome:draw. Three fonts are created from the CreateFonts hook: 'FluxFontAwesome' holds the solid icons, 'FluxFontAwesomeRegular' the outlined variants and 'FluxFontAwesomeBrands' the brand logos. An icon is drawn from the solid font unless it only exists as a brand, or the ID carries one of the Font Awesome style prefixes ('far fa-heart' draws the outlined heart, 'fab fa-github' the GitHub logo). The icon data comes from cl_icons.lua, which scripts/update.js generates from the @fortawesome/fontawesome-free npm package together with the TrueType fonts in content/resource/fonts of the gamemode, which the package spec sends to clients.

Summary

Functions

Stores the generated icon data.

Methods

get(id)client
Returns the glyph of the specified icon.
Returns the name of the font an icon is drawn with, scaled to the specified size.
Returns the dimensions of the specified icon when drawn at the specified size.
Returns the style an icon is drawn in: the one its ID asks for when the icon exists in that font, the icon's own style otherwise.

Functions

FontAwesome.load(data)

client packages/fontawesome/lib/cl_fontawesome.lua:38

Stores the generated icon data. Called by cl_icons.lua once it has been included.

Parameters

  • data Map with the fields version (String), fonts (Map style to font data with the fields family, weight and file_name), icons (Map icon ID to Number codepoint), styles (Map icon ID to String style of the icons that are not in the solid font) and regular (Map icon ID to true for the icons that also exist in the regular font)

Methods

FontAwesome:draw(id, x, y, size, color, x_align, y_align, outline_width, outline_color)

client packages/fontawesome/lib/cl_fontawesome.lua:155

Draws an icon on the screen. The 'fa-' prefix of the ID can be omitted. Draws nothing if there is no such icon.

Parameters

  • id String icon ID, such as 'fa-plus', 'plus' or 'far fa-heart'
  • x Number
  • y Number
  • size Number optional, defaults to 16 font size of the icon
  • color Color optional, defaults to color_white
  • x_align Number optional, defaults to TEXT_ALIGN_LEFT TEXT_ALIGN enum
  • y_align Number optional, defaults to TEXT_ALIGN_TOP TEXT_ALIGN enum
  • outline_width Number optional, defaults to nil draws the icon outlined if specified
  • outline_color Color optional, defaults to nil

Returns

  • Number width
  • Number height of the drawn icon; nil if there is no such icon

Returns the glyph of the specified icon.

Parameters

  • id String icon ID, such as 'fa-plus'

Returns

  • String the glyph, or the ID itself if there is no such icon

FontAwesome:get_font(id, size)

client packages/fontawesome/lib/cl_fontawesome.lua:124

Returns the name of the font an icon is drawn with, scaled to the specified size.

Parameters

  • id String icon ID, such as 'fa-plus' or 'fab fa-github'
  • size Number optional, defaults to nil font size, the unscaled font is returned if omitted

Returns

  • String font name, or the solid font if there is no such icon

FontAwesome:get_icon_size(id, size)

client packages/fontawesome/lib/cl_fontawesome.lua:139

Returns the dimensions of the specified icon when drawn at the specified size.

Parameters

  • id String icon ID, such as 'fa-plus'
  • size Number optional, defaults to 16 font size of the icon

Returns

  • Number width
  • Number height

FontAwesome:get_style(id)

client packages/fontawesome/lib/cl_fontawesome.lua:108

Returns the style an icon is drawn in: the one its ID asks for when the icon exists in that font, the icon's own style otherwise.

Parameters

  • id String icon ID, such as 'fa-plus' or 'far fa-heart'

Returns

  • String 'solid', 'regular' or 'brands'; nil if there is no such icon

Defined in