;;; -*- lexical-binding: t; -*-

(defvar syd-fixed-pitch-font
  (font-spec :family "VictorMono Nerd Font" :size 13)
  "Default fixed-pitch (monospace) font.")

(defvar syd-variable-pitch-font
  (font-spec :family "IBM Plex Serif" :size 15)
  "Default variable-pitch font.")

(defvar syd-alt-fixed-pitch-font
  (font-spec :family "JuliaMono" :size 16)
  "A monospace font secondary to `syd-fixed-pitch-font'.")

(defun syd-init-fonts-h ()
  "Loads `syd-fixed-pitch-font' and `syd-variable-pitch-font'."
  (dolist (map `((default . ,syd-fixed-pitch-font)
                 (fixed-pitch . ,syd-fixed-pitch-font)
                 (variable-pitch . ,syd-variable-pitch-font)))
    (pcase-let ((`(,face . ,font) map))
      (set-face-attribute face nil
                          :width 'normal :weight 'normal
                          :slant 'normal :font font))))

(let ((hook-point (if (daemonp)
                'server-after-make-frame-hook
              'after-init-hook)))
  (add-hook hook-point #'syd-init-fonts-h -10))

;; Use JuliaMono as a fallback for some glyphs that VictorMono does not cover.
(dolist (char-range '((#x0250 . #x02af) ; IPA extensions
                      (#x2200 . #x22FF))) ; Mathematical operators
  (set-fontset-font "fontset-default" char-range "JuliaMono"))

(provide 'syd/fonts)
