forked from genewildish/Mainline
feat: Implement an interactive font face picker at startup, allowing selection of specific font faces from a font file.
This commit is contained in:
@@ -4,6 +4,35 @@ Configuration constants, CLI flags, and glyph tables.
|
||||
|
||||
import sys
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _arg_value(flag):
|
||||
"""Get value following a CLI flag, if present."""
|
||||
if flag not in sys.argv:
|
||||
return None
|
||||
i = sys.argv.index(flag)
|
||||
return sys.argv[i + 1] if i + 1 < len(sys.argv) else None
|
||||
|
||||
|
||||
def _arg_int(flag, default):
|
||||
"""Get int CLI argument with safe fallback."""
|
||||
raw = _arg_value(flag)
|
||||
if raw is None:
|
||||
return default
|
||||
try:
|
||||
return int(raw)
|
||||
except ValueError:
|
||||
return default
|
||||
|
||||
|
||||
def _resolve_font_path(raw_path):
|
||||
"""Resolve font path; relative paths are anchored to repo root."""
|
||||
p = Path(raw_path).expanduser()
|
||||
if p.is_absolute():
|
||||
return str(p)
|
||||
repo_root = Path(__file__).resolve().parent.parent
|
||||
return str((repo_root / p).resolve())
|
||||
# ─── RUNTIME ──────────────────────────────────────────────
|
||||
HEADLINE_LIMIT = 1000
|
||||
FEED_TIMEOUT = 10
|
||||
@@ -17,7 +46,12 @@ NTFY_POLL_INTERVAL = 15 # seconds between polls
|
||||
MESSAGE_DISPLAY_SECS = 30 # how long a message holds the screen
|
||||
|
||||
# ─── FONT RENDERING ──────────────────────────────────────
|
||||
FONT_PATH = "/Users/genejohnson/Documents/CS Bishop Drawn/CSBishopDrawn-Italic.otf"
|
||||
FONT_PATH = _resolve_font_path(
|
||||
_arg_value('--font-file')
|
||||
or "/Users/genejohnson/Documents/CS Bishop Drawn/CSBishopDrawn-Italic.otf"
|
||||
)
|
||||
FONT_INDEX = max(0, _arg_int('--font-index', 0))
|
||||
FONT_PICKER = '--no-font-picker' not in sys.argv
|
||||
FONT_SZ = 60
|
||||
RENDER_H = 8 # terminal rows per rendered text line
|
||||
|
||||
@@ -33,3 +67,12 @@ GRAD_SPEED = 0.08 # gradient traversal speed (cycles/sec, ~12s full swee
|
||||
# ─── GLYPHS ───────────────────────────────────────────────
|
||||
GLITCH = "░▒▓█▌▐╌╍╎╏┃┆┇┊┋"
|
||||
KATA = "ハミヒーウシナモニサワツオリアホテマケメエカキムユラセネスタヌヘ"
|
||||
|
||||
|
||||
def set_font_selection(font_path=None, font_index=None):
|
||||
"""Set runtime primary font selection."""
|
||||
global FONT_PATH, FONT_INDEX
|
||||
if font_path is not None:
|
||||
FONT_PATH = _resolve_font_path(font_path)
|
||||
if font_index is not None:
|
||||
FONT_INDEX = max(0, int(font_index))
|
||||
|
||||
Reference in New Issue
Block a user