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
static var _body_bold: FontVariation = 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


## Emboldened Roman face for small, high-legibility bits (keycaps, badges) where
## Cinzel's thin regular strokes wash out. Faked via FontVariation since only the
## regular weight ships, so no extra .ttf is needed.
static func body_bold() -> FontVariation:
	if _body_bold == null:
		_body_bold = FontVariation.new()
		_body_bold.base_font = body()
		_body_bold.variation_embolden = 0.5
	return _body_bold


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
