Skip to content

Font Library

Comprehensive font management system for the Lilia framework.


Overview

The font library provides comprehensive functionality for managing custom fonts in the Lilia framework. It handles font registration, loading, and automatic font creation for UI elements throughout the gamemode. The library operates on both server and client sides, with the server storing font metadata and the client handling actual font creation and rendering. It includes automatic font generation for various sizes and styles, dynamic font loading based on configuration, and intelligent font name parsing for automatic font creation. The library ensures consistent typography across all UI elements and provides easy access to predefined font variants for different use cases.


lia.font.loadFonts()

Create all registered fonts on the client and count successes/failures.

After registration or config load to ensure fonts exist before drawing.

Example Usage:

    hook.Add("RefreshFonts", "ReloadAllFonts", function()
        lia.font.loadFonts()
    end)

lia.font.register(fontName, fontData)

Register a single font definition and create it clientside if possible.

During font setup or dynamically when encountering unknown font names.

Parameters:

string fontName Unique font identifier.

table fontData surface.CreateFont data table.

Example Usage:

    lia.font.register("liaDialogHeader", {
        font = "Montserrat Bold",
        size = 28,
        weight = 800,
        antialias = true
    })

lia.font.getAvailableFonts()

List all registered font identifiers.

Populate dropdowns or config options for font selection.

Returns:

table Sorted array of font names.

Example Usage:

    for _, name in ipairs(lia.font.getAvailableFonts()) do
        print("Font:", name)
    end

lia.font.getBoldFontName(fontName)

Convert a base font name to its bold variant.

When auto-registering bold/shadow variants of LiliaFont entries.

Parameters:

string fontName Base font name.

Returns:

string Best-effort bold font name.

Example Usage:

    local boldName = lia.font.getBoldFontName("Montserrat Medium")
    lia.font.register("DialogTitle", {font = boldName, size = 26, weight = 800})

lia.font.registerFonts(fontName)

Register the full suite of Lilia fonts (regular, bold, italic, sizes).

On config load or when switching the base font setting.

Parameters:

string fontName optional Base font name; defaults to config Font.

Example Usage:

    concommand.Add("lia_reload_fonts", function()
        local base = lia.config.get("Font", "Montserrat Medium")
        lia.font.registerFonts(base)
        timer.Simple(0.1, lia.font.loadFonts)
    end)