cw.fonts classclient
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
cw.fonts:Add.Methods
cw.fonts:Add(name, fontTable, bForce)
client gamemodes/catwork/gamemode/core/libraries/cl_fonts.lua:44Creates 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
nilWhether 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
nilif the font was not added
cw.fonts:GetMultiplied(name, multiplier)
client gamemodes/catwork/gamemode/core/libraries/cl_fonts.lua:105Returns 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
nameif the font was not added
See also
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 (
namefollowed bysize), ornameif the font was not added