Defines the client-side cw.fonts library, which creates fonts and makes resized copies of them on demand.

surface.CreateFont is replaced to go through cw.fonts:Add, with the engine function kept as the global CreateFont, so that cw.fonts:GetSize and cw.fonts:GetMultiplied can return any font at another size. The file also creates Catwork's own fonts, such as cwMainText and cw.menuTextBig.

Summary

Methods

Creates a font and stores its data so other sizes of it can be made.
Returns the data of a font added with cw.fonts:Add.
Returns a copy of a font with its size multiplied, creating it the first time.
Returns a copy of a font at another size, creating it the first time.

Methods

cw.fonts:Add(name, fontTable, bForce)

client gamemodes/catwork/gamemode/core/libraries/cl_fonts.lua:44

Creates a font and stores its data so other sizes of it can be made.

extended is always turned on so the font loads every character. Does nothing if the font already exists, unless bForce is set.

cw.fonts:Add('cwMyFont', {
  font = 'Roboto',
  size = 18,
  weight = 500
})

Parameters

  • name String Name of the font
  • fontTable Map Font data as taken by the engine's surface.CreateFont
  • bForce Boolean optional, defaults to nil Whether to recreate a font that already exists

Returns the data of a font added with cw.fonts:Add.

Parameters

  • name String Name of the font

Returns

  • Map The font data, or nil if the font was not added

cw.fonts:GetMultiplied(name, multiplier)

client gamemodes/catwork/gamemode/core/libraries/cl_fonts.lua:105

Returns a copy of a font with its size multiplied, creating it the first time.

Parameters

  • name String Name of a font added with cw.fonts:Add
  • multiplier Number Factor applied to the font's size

Returns

  • String Name of the sized font, or name if the font was not added

See also

cw.fonts:GetSize(name, size)

client gamemodes/catwork/gamemode/core/libraries/cl_fonts.lua:70

Returns a copy of a font at another size, creating it the first time.

draw.SimpleText('Hello', cw.fonts:GetSize('cwMainText', 24), x, y)

Parameters

  • name String Name of a font added with cw.fonts:Add
  • size Number Font size

Returns

  • String Name of the sized font (name followed by size), or name if the font was not added

See also

Defined in