Skip to content

Instantly share code, notes, and snippets.

@lokedhs
Created August 20, 2022 10:35
Show Gist options
  • Save lokedhs/afcd0054b94a8cc8c0c0f8dc1d8a63bf to your computer and use it in GitHub Desktop.
Save lokedhs/afcd0054b94a8cc8c0c0f8dc1d8a63bf to your computer and use it in GitHub Desktop.
(defun compute-font-dpi ()
(let* ((display (clim-clx:clx-port-display (clim:find-port)))
(db (xlib:root-resources (xlib:display-default-screen display)))
(res (xlib:get-resource db :|dpi| :|Dpi| '(:xft) '(:|Xft|)))
(default-sizes '(:normal 14 :tiny 8 :very-small 10 :small 12 :large 18 :very-large 20 :huge 24)))
(when res
(alexandria:when-let ((font-size (parse-integer res :junk-allowed t)))
(let* ((default-dpi 96)
(font-scale (/ font-size default-dpi)))
(setq climi::+font-sizes+
(loop
for (type size) on default-sizes by #'cddr
append (list type (* size font-scale)))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment