Font System
Create resolution-aware fonts that scale properly on all screen sizes.
cLib.CreateFont
cLib.CreateFont(fontID, fontName, size, weight, is3D2D)Parameters:
| Parameter | Type | Description |
|---|---|---|
fontID | string | Unique identifier |
fontName | string | System font name |
size | number | 0-1 for screen %, or absolute |
weight | number | Font weight (default: 500) |
is3D2D | boolean | Use absolute size for 3D2D |
Screen-Relative Fonts
For UI fonts, use values between 0 and 1 representing percentage of screen height:
-- 3% of screen height (large title)
cLib.CreateFont("MyAddon.Title", "Roboto", 0.03, 600)
-- 2% of screen height (subtitle)
cLib.CreateFont("MyAddon.Subtitle", "Roboto", 0.02, 500)
-- 1.5% of screen height (body text)
cLib.CreateFont("MyAddon.Text", "Roboto", 0.015)
-- 1.2% of screen height (small text)
cLib.CreateFont("MyAddon.Small", "Roboto", 0.012)Size Reference (at 1080p)
| Percentage | Pixels | Use Case |
|---|---|---|
| 0.03 | ~32px | Large titles |
| 0.025 | ~27px | Section headers |
| 0.02 | ~22px | Subtitles |
| 0.016 | ~17px | Body text |
| 0.014 | ~15px | Input text |
| 0.012 | ~13px | Small text |
3D2D Fonts
For 3D2D rendering (world text), use absolute pixel sizes:
-- Fixed size for 3D2D text
cLib.CreateFont("MyAddon.WorldTitle", "Bebas Neue", 90, 500, true)
cLib.CreateFont("MyAddon.WorldText", "Arial", 48, 400, true)Usage
-- In paint functions
draw.SimpleText("Hello World", "MyAddon.Title", x, y, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
-- Get text size
surface.SetFont("MyAddon.Title")
local w, h = surface.GetTextSize("Hello World")Built-in Fonts
"cLib.FrameTitle" -- Bebas Neue, 3%
"cLib.Title" -- Roboto, 2.2%, weight 600
"cLib.SubTitle" -- Roboto, 1.6%, weight 500
"cLib.Text" -- Roboto, 1.4%
"cLib.Small" -- Roboto, 1.2%
"cLib.Input" -- Roboto, 1.4%
"cLib.Button" -- Roboto, 1.5%, weight 500
"cLib.Toggle" -- Roboto, 1.0%, weight 500Included Font
cLib includes Bebas Neue font automatically:
cLib.CreateFont("MyAddon.BigTitle", "Bebas Neue", 0.05)