Paste number 58764: Select a font based on resolution #1

Index of paste annotations: 3 | 2 | 1

Paste number 58764: Select a font based on resolution #1
Pasted by: z0d
When:1 year, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+19CC
Channel:None
Paste contents:
Raw Source | XML | Display As
;;; Select a font based on resolution
(defvar z0d:font-table
  '(((1280 . 800) "DejaVu Sans Mono-10")
    ((1280 . 1024) "DejaVu Sans Mono-11")
    ((1680 . 1050) "DejaVu Sans Mono-12")
    (t "DejaVu Sans Mono-10")))

(defun z0d:choose-font ()
  (let ((font (assoc (cons (x-display-pixel-width)
                           (x-display-pixel-height))
                     z0d:font-table)))
    (or (cadr font)
        (cadr (assoc t z0d:font-table))
        "DejaVu Sans Mono-10")))

Annotations for this paste:

Annotation number 3: #3
Pasted by: z0d
When:1 year, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+19CC#3
Paste contents:
Raw Source | Display As
;;; Select a font based on resolution
(defvar z0d:font-table
  '(((1280 . 800) "DejaVu Sans Mono-10")
    ((1280 . 1024) "DejaVu Sans Mono-11")
    ((1680 . 1050) "DejaVu Sans Mono-12")
    (t "DejaVu Sans Mono-10")))

(defvar z0d:frame-alist
  '((cursor-color . "Gray40")
    (tool-bar-lines . nil)))

(defun z0d:choose-font ()
  "Return a font from z0d:font-table or return nil."
  (let ((font (assoc (cons (x-display-pixel-width)
                           (x-display-pixel-height))
                     z0d:font-table)))
    (or (cadr font)
        (cadr (assoc t z0d:font-table))
        nil)))

;;; Should it be a function?
(defvar z0d:default-frame-alist
  (let ((font (z0d:choose-font)))
    (if font
        (cons `(font . ,font)
              z0d:frame-alist)
        z0d:frame-alist)))

(when window-system
  (setq default-frame-alist z0d:default-frame-alist))

Annotation number 2: Final(?) version
Pasted by: z0d
When:1 year, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+19CC#2
Paste contents:
Raw Source | Display As
;;; Select a font based on resolution
(defvar z0d:font-table
  '(((1280 . 800) "DejaVu Sans Mono-10")
    ((1280 . 1024) "DejaVu Sans Mono-11")
    ((1680 . 1050) "DejaVu Sans Mono-12")
    (t "DejaVu Sans Mono-10")))

(defvar z0d:frame-alist
  '((cursor-color . "Gray40")
    (tool-bar-lines . nil)))

(defun z0d:choose-font ()
  "Return a font from z0d:font-table or return nil."
  (let ((font (assoc (cons (x-display-pixel-width)
                           (x-display-pixel-height))
                     z0d:font-table)))
    (or (cadr font)
        (cadr (assoc t z0d:font-table))
        nil)))

(defvar z0d:default-frame-alist
  (let ((font (z0d:choose-font)))
    (if font
        (cons `(font . ,font)
              z0d:frame-alist)
        z0d:frame-alist)))

(when window-system
  (setq default-frame-alist z0d:default-frame-alist))

Annotation number 1: #2
Pasted by: z0d
When:1 year, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+19CC#1
Paste contents:
Raw Source | Display As
;;; Select a font based on resolution
(defvar z0d:font-table
  '(((1280 . 800) "DejaVu Sans Mono-10")
    ((1280 . 1024) "DejaVu Sans Mono-11")
    ((1680 . 1050) "DejaVu Sans Mono-12")
    (t "DejaVu Sans Mono-10")))

(defun z0d:choose-font ()
  (let ((font (assoc (cons (x-display-pixel-width)
                           (x-display-pixel-height))
                     z0d:font-table)))
    (or (cadr font)
        (cadr (assoc t z0d:font-table))
        (cdr (assoc 'font (frame-parameters))))))

Colorize as:
Show Line Numbers
Index of paste annotations: 3 | 2 | 1

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.