38 lines
1.0 KiB
GDScript
38 lines
1.0 KiB
GDScript
class_name UiFonts
|
|
extends RefCounted
|
|
## Shared thematic fonts for menus and HUD. Cinzel is a Roman monumental capital
|
|
## typeface — a deliberate nod to the "-osseum" (Colosseum) in Bullosseum.
|
|
##
|
|
## Fonts load via load_dynamic_font so they resolve identically in the editor,
|
|
## headless tests and exported builds, whether or not the .ttf has been imported.
|
|
|
|
const _DECORATIVE := "res://fonts/CinzelDecorative-Bold.ttf"
|
|
const _ROMAN := "res://fonts/Cinzel.ttf"
|
|
|
|
static var _title: FontFile = null
|
|
static var _body: FontFile = null
|
|
|
|
|
|
## Ornate display face — big banners, menu title, win/lose text.
|
|
static func title() -> FontFile:
|
|
if _title == null:
|
|
_title = _load(_DECORATIVE)
|
|
return _title
|
|
|
|
|
|
## Cleaner monumental face — buttons, labels, body copy.
|
|
static func body() -> FontFile:
|
|
if _body == null:
|
|
_body = _load(_ROMAN)
|
|
return _body
|
|
|
|
|
|
static func _load(path: String) -> FontFile:
|
|
if ResourceLoader.exists(path):
|
|
var res := load(path)
|
|
if res is FontFile:
|
|
return res as FontFile
|
|
var f := FontFile.new()
|
|
f.load_dynamic_font(path)
|
|
return f
|