Lua API
  • 🔎Overview
  • Introduction
    • 🚀Creating scripts
      • 🧠First Steps
      • 🖥️Adding UI
      • 📚Creating Libraries
  • API
    • 🌐Global Functions
    • ⚙️Instances
      • 🔢Math
      • ☎️Events
        • event_t
      • 🎮Game
        • global_vars_t
        • cengine_client
          • cnet_chan
        • ccsgo_input
        • cinput_system
        • cgame_ui_funcs
        • ccvar
          • convar
      • 🕹️Mods
        • events_t
      • ✏️Draw
        • ⚙️Types
          • ⚙️rect
          • ⚙️vec2
          • ⚙️color
          • ⚙️accessor
        • 🖥️Adapter
        • ✏️Layer
          • outline_mode
          • rounding
          • glow_parts
          • text_params
            • text_alignment
          • shadow_dir
          • command
            • render_mode
        • 🖼️Managed
          • 🖼️texture
            • svg_texture
            • animated_texture
          • 🖼️shader
          • ™️font_base
            • font
            • font_gdi
            • glyph_t
            • font_flags
      • 🙋Entities
        • entity_list_t
          • entity_entry_t
        • base_entity
          • schema_accessor_t
          • cs2_weapon_base_gun
          • cs2_player_pawn
          • cs2_player_controller
          • cs2_weapon_base
          • cs2_grenade_projectile
        • ccsweapon_base_vdata
          • cfiring_mode
        • chandle
        • csweapon_mode
        • csweapon_type
        • weapon_id
        • csweapon_category
        • observer_mode_t
      • 🖥️Gui
        • ⚙️Types
          • ⚙️bits
          • ⚙️control_id
        • context
          • user_t
        • context_input
          • mouse_button
        • notification_system
          • notification
        • control
          • control_type
          • value_param
          • checkbox
          • slider
          • label
          • selectable
          • button
          • color_picker
          • spacer
          • text_input
          • combo_box
          • image
        • container
          • control_container
            • layout
            • group
      • ⚙️Utils
    • ⚙️Types
      • ⚙️ptr
      • ⚙️ref_holder_t
      • ⚙️vector
      • ⚙️vector4d
      • 🎮veccolor
      • 🎮color
      • 🎮cview_setup
      • 🎮cuser_cmd
      • 🎮game_event_t
    • 🟰Enums
      • 🟰client_frame_stage
      • 🟰input_bit_mask
Powered by GitBook

© 2025 - FATALITY

On this page
  • height
  • ascent
  • descent
  • line_gap
  • kerning_gap
  • outline_alpha
  • flags
  • y_offset
  • x_offset
  • fallback_font
  • dropshadow_color
  • get_kerned_char_width
  • get_kerning
  • get_text_size
  • wrap_text
  • get_glyph
  • get_texture
Export as PDF
  1. API
  2. Instances
  3. Draw
  4. Managed

font_base

PreviousshaderNextfont

Last updated 3 months ago

This type represents the base class for font types. You cannot create an instance of this type. Instead, use the children types.

This type inherits type. All of its base methods and fields are also available in this type.

Definitions:

  • codepoint: Unicode representation of the character.

  • kerning: a distance between two characters.

  • glyph: visual representation of a character.

height

Type: float

Font height, in pixels.


ascent

Type: float

Font ascent value, in pixels.


descent

Type: float

Font descent value, in pixels.


line_gap

Type: float

Font line gap, in pixels.


kerning_gap

Type: float

Font kerning gap, in pixels.


outline_alpha

Type: float

Font outline opacity (0 to 1). Defaults to 0.45.


flags

Font flags. Use bit library to read flags.


y_offset

Type: int

Glyph Y offset, in pixels. Will alter the location of a glyph in the atlas. Changing this value after the font was created is meaningless.


x_offset

Type: int

Glyph X offset, in pixels. Will alter the location of a glyph in the atlas. Changing this value after the font was created is meaningless.


fallback_font

Type: font_base

Fallback font to use, in case a glyph is not found in this font. Is it useful when one font does not have codepoints for specific symbols, that are present in another font, but you still want to prefer this font's glyphs over other font.


dropshadow_color

Shadow color. Only R, G, B values are used.


get_kerned_char_width

Returns character width, included with kerning.

Arguments

Name

Type

Description

left

int

Previous character codepoint.

right

int

Current character codepoint.

Returns

Type

Description

float

Distance, in pixels.

Example

local w = font:get_kerned_char_width(prev_cp, cp);

get_kerning

Returns kerning value for a single character. If kerning is disabled, will instead return kerning gap.

Arguments

Name

Type

Description

cp

int

Codepoint.

Returns

Type

Description

float

Kerning value, in pixels.

Example

local k = font:get_kerning(cp);

get_text_size

Returns text area size.

Arguments

Name

Type

Description

text

string

Text.

skip_scaling

bool

If set to true, will skip global DPI scaling. Defaults to false.

til_newline

bool

Calculate size only until a line break is met. Defaults to false.

Returns

Type

Description

Text area size.

Example

local sz = font:get_text_size('Hello!');

wrap_text

Wraps text to meet the desired width. Wrapping is done by breaking text by words and inserting line breaks in between. If one of the words is longer than the target width, will instead use that word's width.

Arguments

Name

Type

Description

text

string

Text to wrap.

width

float

Target width.

Returns

Type

Description

string

Wrapped text.

Example

local shorter = font:wrap_text('This is some very long text!', 50);

get_glyph

Returns glyph information for a character.

Arguments

Name

Type

Description

codepoint

int

Codepoint.

Returns

Type

Description

Glyph information.

Example

local glyph = font:get_glyph(cp);

get_texture

Returns a texture atlas that contains the provided glyph.

Arguments

Name

Type

Description

gl

Character glyph.

Returns

Type

Description

int

Texture pointer, or nil if not found.

Example

local atlas = font:get_texture(glyph);

Type:

Type:

⚙️
✏️
🖼️
™️
managed
font_flags
color
vec2
glyph_t
glyph_t