1 ;;; font.el --- New font model
3 ;; Created: 1997/09/05 15:44:37
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 ;;; Copyright (c) 1995, 1996 by William M. Perry (wmperry@cs.indiana.edu)
9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc.
11 ;;; This file is part of SXEmacs.
13 ;; SXEmacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
18 ;; SXEmacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28 (globally-declare-fboundp
29 '(x-list-fonts internal-facep fontsetp
30 get-font-info get-fontset-info font-color-rgb-components
31 font-rgb-color-p cancel-function-timers run-at-time
32 set-font-oblique-p set-font-italic-p set-font-bold-p
33 font-dropcaps-p font-bigcaps-p font-smallcaps-p font-blink-p
34 font-reverse-p font-strikethru-p font-linethrough-p
35 font-overline-p font-underline-p font-dim-p font-oblique-p
36 font-italic-p font-bold-p))
38 (globally-declare-boundp 'global-face-data)
40 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
41 ;;; The emacsen compatibility package - load it up before anything else
42 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
46 (defvar device-fonts-cache)
50 (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
51 nil ;; We've got what we needed
52 ;; We have the old custom-library, hack around it!
53 (defmacro defgroup (&rest args)
55 (defmacro defcustom (var value doc &rest args)
56 `(defvar ,var ,value ,doc))))
58 (if (not (fboundp 'try-font-name))
59 (defun try-font-name (fontname &rest args)
61 ((x) (car-safe (x-list-fonts fontname)))
64 (if (not (fboundp 'facep))
66 "Return t if X is a face name or an internal face vector."
67 (if (not window-system)
68 nil ; FIXME if FSF ever does TTY faces
69 (and (or (internal-facep face)
70 (and (symbolp face) (assq face global-face-data)))
73 (if (not (fboundp 'set-face-property))
74 (defun set-face-property (face property value &optional locale
76 "Change a property of FACE."
78 (put face property value))))
80 (if (not (fboundp 'face-property))
81 (defun face-property (face property &optional locale tag-set exact-p)
82 "Return FACE's value of the given PROPERTY."
83 (and (symbolp face) (get face property))))
88 (unless (fboundp #'<<)
96 (unless (fboundp #'>>)
97 (defun >> (value count)
98 (<< value (- count)))))
101 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
102 ;;; Lots of variables / keywords for use later in the program
103 ;;; Not much should need to be modified
104 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
105 (defconst font-running-xemacs (string-match "XEmacs" (emacs-version))
106 "Whether we are running in XEmacs or not.")
108 (defmacro define-font-keywords (&rest keys)
110 (let ((keywords (quote ,keys)))
112 (or (boundp (car keywords))
113 (set (car keywords) (car keywords)))
114 (setq keywords (cdr keywords))))))
116 (defconst font-window-system-mappings
117 '((x . (x-font-create-name x-font-create-object))
118 (gtk . (x-font-create-name x-font-create-object))
119 (tty . (tty-font-create-plist tty-font-create-object)))
120 "An assoc list mapping device types to a list of translations.
122 The first function creates a font name from a font descriptor object.
123 The second performs the reverse translation.")
125 (defconst x-font-weight-mappings
126 '((:extra-light . "extralight")
128 (:demi-light . "demilight")
133 (:demi-bold . "demibold")
135 (:extra-bold . "extrabold"))
136 "An assoc list mapping keywords to actual Xwindow specific strings
137 for use in the 'weight' field of an X font string.")
139 (defconst font-possible-weights
140 (mapcar 'car x-font-weight-mappings))
142 (defvar font-rgb-file nil
143 "Where the RGB file was found.")
145 (defvar font-maximum-slippage "1pt"
146 "How much a font is allowed to vary from the desired size.")
148 ;; Canonical (internal) sizes are in points.
150 (define-font-keywords :family :style :size :registry :encoding)
152 (define-font-keywords
153 :weight :extra-light :light :demi-light :medium :normal :demi-bold
156 (defvar font-style-keywords nil)
158 (defsubst set-font-family (fontobj family)
159 (aset fontobj 1 family))
161 (defsubst set-font-weight (fontobj weight)
162 (aset fontobj 3 weight))
164 (defsubst set-font-style (fontobj style)
165 (aset fontobj 5 style))
167 (defsubst set-font-size (fontobj size)
168 (aset fontobj 7 size))
170 (defsubst set-font-registry (fontobj reg)
171 (aset fontobj 9 reg))
173 (defsubst set-font-encoding (fontobj enc)
174 (aset fontobj 11 enc))
176 (defsubst font-family (fontobj)
179 (defsubst font-weight (fontobj)
182 (defsubst font-style (fontobj)
185 (defsubst font-size (fontobj)
188 (defsubst font-registry (fontobj)
191 (defsubst font-encoding (fontobj)
195 (defmacro define-new-mask (attr mask)
197 (setq font-style-keywords
198 (cons (cons (quote ,attr)
200 (quote ,(intern (format "set-font-%s-p" attr)))
201 (quote ,(intern (format "font-%s-p" attr)))))
202 font-style-keywords))
203 (defconst ,(intern (format "font-%s-mask" attr)) (<< 1 ,mask)
205 "Bitmask for whether a font is to be rendered in %s or not."
207 (defun ,(intern (format "font-%s-p" attr)) (fontobj)
208 ,(format "Whether FONTOBJ will be renderd in `%s' or not." attr)
209 (if (/= 0 (& (font-style fontobj)
210 ,(intern (format "font-%s-mask" attr))))
213 (defun ,(intern (format "set-font-%s-p" attr)) (fontobj val)
214 ,(format "Set whether FONTOBJ will be renderd in `%s' or not."
218 (set-font-style fontobj (| (font-style fontobj)
220 (format "font-%s-mask" attr)))))
221 ((,(intern (format "font-%s-p" attr)) fontobj)
222 (set-font-style fontobj (- (font-style fontobj)
224 (format "font-%s-mask" attr)))))))
228 (define-new-mask bold (setq mask (1+ mask)))
229 (define-new-mask italic (setq mask (1+ mask)))
230 (define-new-mask oblique (setq mask (1+ mask)))
231 (define-new-mask dim (setq mask (1+ mask)))
232 (define-new-mask underline (setq mask (1+ mask)))
233 (define-new-mask overline (setq mask (1+ mask)))
234 (define-new-mask linethrough (setq mask (1+ mask)))
235 (define-new-mask strikethru (setq mask (1+ mask)))
236 (define-new-mask reverse (setq mask (1+ mask)))
237 (define-new-mask blink (setq mask (1+ mask)))
238 (define-new-mask smallcaps (setq mask (1+ mask)))
239 (define-new-mask bigcaps (setq mask (1+ mask)))
240 (define-new-mask dropcaps (setq mask (1+ mask))))
242 (defvar font-caps-display-table
243 (let ((table (make-display-table))
245 ;; Standard ASCII characters
247 (aset table (+ i ?a) (+ i ?A))
249 ;; Now ISO translations
251 (while (< i 247) ;; Agrave - Ouml
252 (aset table i (- i 32))
255 (while (< i 255) ;; Oslash - Thorn
256 (aset table i (- i 32))
260 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
261 ;;; Utility functions
262 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
263 (defsubst set-font-style-by-keywords (fontobj styles)
264 (make-local-variable 'font-func)
265 (declare (special font-func))
268 (setq font-func (car-safe (cdr-safe (assq (car styles) font-style-keywords)))
270 (and (fboundp font-func) (funcall font-func fontobj t)))
271 (setq font-func (car-safe (cdr-safe (assq styles font-style-keywords))))
272 (and (fboundp font-func) (funcall font-func fontobj t))))
274 (defsubst font-properties-from-style (fontobj)
275 (let (;(style (font-style fontobj))
276 (todo font-style-keywords)
279 (setq func (cdr (cdr (car todo)))
280 type (car (pop todo)))
281 (if (funcall func fontobj)
282 (setq retval (cons type retval))))
285 (defun font-unique (list)
291 (if (member cur retval)
293 (setq retval (cons cur retval))))
296 (defun font-higher-weight (w1 w2)
297 (let ((index1 (length (memq w1 font-possible-weights)))
298 (index2 (length (memq w2 font-possible-weights))))
307 (defun font-spatial-to-canonical (spec &optional device)
308 "Convert SPEC (in inches, millimeters, points, picas, or pixels) into points.
310 Canonical sizes are in points. If SPEC is null, nil is returned. If SPEC is
311 a number, it is interpreted as the desired point size and returned unchanged.
312 Otherwise SPEC must be a string consisting of a number and an optional type.
313 The type may be the strings \"px\", \"pix\", or \"pixel\" (pixels), \"pt\" or
314 \"point\" (points), \"pa\" or \"pica\" (picas), \"in\" or \"inch\" (inches), \"cm\"
315 (centimeters), or \"mm\" (millimeters).
317 1 in = 2.54 cm = 6 pa = 25.4 mm = 72 pt. Pixel size is device-dependent."
326 ;; If for any reason we get null for any of this, default
327 ;; to 1024x768 resolution on a 17" screen
328 (pix-width (float (or (device-pixel-width device) 1024)))
329 (mm-width (float (or (device-mm-width device) 293)))
332 ;; the following string-match is broken, there will never be a
333 ;; left operand detected
334 ((string-match #r"^ *\([-+*/]\) *" spec) ; math! whee!
335 (let ((math-func (intern (match-string 1 spec)))
336 (other (font-spatial-to-canonical
337 (substring spec (match-end 0) nil)))
338 (default (font-spatial-to-canonical
339 (font-default-size-for-device device))))
340 (if (fboundp math-func)
342 spec (int-to-string (funcall math-func default other)))
344 spec (int-to-string other)))))
345 ((string-match "[^0-9.]+$" spec)
346 (setq type (substring spec (match-beginning 0))
347 spec (substring spec 0 (match-beginning 0))))
351 (setq num (string-to-number spec))
353 ((member type '("pixel" "px" "pix"))
354 (setq retval (* num (/ pix-width mm-width) (/ 25.4 72.0))))
355 ((member type '("point" "pt"))
357 ((member type '("pica" "pa"))
358 (setq retval (* num 12.0)))
359 ((member type '("inch" "in"))
360 (setq retval (* num 72.0)))
362 (setq retval (* num (/ 72.0 25.4))))
364 (setq retval (* num 10 (/ 72.0 25.4))))
371 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
372 ;;; The main interface routines - constructors and accessor functions
373 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
374 (defun make-font (&rest args)
376 (if (stringp (plist-get args :family))
377 (list (plist-get args :family))
378 (plist-get args :family))
380 (plist-get args :weight)
382 (if (numberp (plist-get args :style))
383 (plist-get args :style)
386 (plist-get args :size)
388 (plist-get args :registry)
390 (plist-get args :encoding)))
392 (defun font-create-name (fontobj &optional device)
393 "Return a font name constructed from FONTOBJ, appropriate for DEVICE."
394 (let* ((type (device-type device))
395 (func (car (cdr-safe (assq type font-window-system-mappings)))))
396 (and func (fboundp func) (funcall func fontobj device))))
399 (defun font-create-object (fontname &optional device)
400 "Return a font descriptor object for FONTNAME, appropriate for DEVICE."
401 (let* ((type (device-type device))
402 (func (car (cdr (cdr-safe (assq type font-window-system-mappings))))))
403 (and func (fboundp func) (funcall func fontname device))))
405 (defun font-combine-fonts-internal (fontobj-1 fontobj-2)
406 (let ((retval (make-font))
407 (size-1 (and (font-size fontobj-1)
408 (font-spatial-to-canonical (font-size fontobj-1))))
409 (size-2 (and (font-size fontobj-2)
410 (font-spatial-to-canonical (font-size fontobj-2)))))
411 (set-font-weight retval (font-higher-weight (font-weight fontobj-1)
412 (font-weight fontobj-2)))
413 (set-font-family retval (font-unique (append (font-family fontobj-1)
414 (font-family fontobj-2))))
415 (set-font-style retval (| (font-style fontobj-1) (font-style fontobj-2)))
416 (set-font-registry retval (or (font-registry fontobj-1)
417 (font-registry fontobj-2)))
418 (set-font-encoding retval (or (font-encoding fontobj-1)
419 (font-encoding fontobj-2)))
420 (set-font-size retval (cond
421 ((and size-1 size-2 (>= size-2 size-1))
422 (font-size fontobj-2))
424 (font-size fontobj-1))
426 (font-size fontobj-1))
428 (font-size fontobj-2))
433 (defun font-combine-fonts (&rest args)
436 (error "Wrong number of arguments to font-combine-fonts"))
440 (let ((retval (font-combine-fonts-internal (nth 0 args) (nth 1 args))))
441 (setq args (cdr (cdr args)))
443 (setq retval (font-combine-fonts-internal retval (car args))
448 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
449 ;;; The window-system dependent code (TTY-style)
450 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
451 (defun tty-font-create-object (fontname &optional device)
452 "Return a font descriptor object for FONTNAME, appropriate for TTY devices."
453 (make-font :size "12pt"))
455 (defun tty-font-create-plist (fontobj &optional device)
456 "Return a font name constructed from FONTOBJ, appropriate for TTY devices."
458 (cons 'underline (font-underline-p fontobj))
459 (cons 'highlight (if (or (font-bold-p fontobj)
460 (memq (font-weight fontobj) '(:bold :demi-bold)))
462 (cons 'dim (font-dim-p fontobj))
463 (cons 'blinking (font-blink-p fontobj))
464 (cons 'reverse (font-reverse-p fontobj))))
467 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
468 ;;; The window-system dependent code (X-style)
469 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
470 (defvar font-x-font-regexp (or (and font-running-xemacs
471 (boundp 'x-font-regexp)
477 ;(weight #r"\(bold\|demibold\|medium\|black\)")
478 (weight\? #r"\([^-]*\)")
479 ;(slant #r"\([ior]\)")
480 (slant\? #r"\([^-]?\)")
481 (swidth #r"\([^-]*\)")
482 (adstyle #r"\([^-]*\)")
483 (pixelsize #r"\(\*\|[0-9]+\)")
484 (pointsize #r"\(\*\|0\|[0-9][0-9]+\)")
485 (resx #r"\([*0]\|[0-9][0-9]+\)")
486 (resy #r"\([*0]\|[0-9][0-9]+\)")
488 (avgwidth #r"\(\*\|[0-9]+\)")
492 (concat #r"\`\*?[-?*]"
493 foundry - family - weight\? - slant\? - swidth - adstyle -
494 pixelsize - pointsize - resx - resy - spacing - avgwidth -
495 registry - encoding "\\'"
498 (defvar font-x-registry-and-encoding-regexp
499 (or (and font-running-xemacs
500 (boundp 'x-font-regexp-registry-and-encoding)
501 (symbol-value 'x-font-regexp-registry-and-encoding))
505 (concat - "\\(" registry "\\)" - "\\(" encoding "\\)\\'"))))
507 (defvar font-x-family-mappings
509 ("serif" . ("new century schoolbook"
523 ("sans-serif" . ("lucida"
529 ("elfin" . ("tymes"))
530 ("monospace" . ("courier"
535 ("cursive" . ("sirene"
538 "A list of font family mappings on X devices.")
540 (defun x-font-create-object (fontname &optional device)
541 "Return a font descriptor object for FONTNAME, appropriate for X devices."
542 (let ((case-fold-search t))
543 (if (or (not (stringp fontname))
544 (not (string-match font-x-font-regexp fontname)))
549 (weight (match-string 1 fontname))
550 (slant (match-string 2 fontname))
551 (swidth (match-string 3 fontname))
552 (adstyle (match-string 4 fontname))
553 (pxsize (match-string 5 fontname))
554 (ptsize (match-string 6 fontname))
558 (if (not (string-match x-font-regexp-foundry-and-family fontname))
560 (setq family (list (downcase (match-string 1 fontname)))))
561 (if (string= "*" weight) (setq weight nil))
562 (if (string= "*" slant) (setq slant nil))
563 (if (string= "*" swidth) (setq swidth nil))
564 (if (string= "*" adstyle) (setq adstyle nil))
565 (if (string= "*" pxsize) (setq pxsize nil))
566 (if (string= "*" ptsize) (setq ptsize nil))
567 (if ptsize (setq size (/ (string-to-int ptsize) 10)))
568 (if (and (not size) pxsize) (setq size (concat pxsize "px")))
569 (if weight (setq weight (intern-soft (concat ":" (downcase weight)))))
570 (if (and adstyle (not (equal adstyle "")))
571 (setq family (append family (list (downcase adstyle)))))
572 (setq retval (make-font :family family
575 (set-font-bold-p retval (eq :bold weight))
578 ((member slant '("i" "I"))
579 (set-font-italic-p retval t))
580 ((member slant '("o" "O"))
581 (set-font-oblique-p retval t)))
582 (when (string-match font-x-registry-and-encoding-regexp fontname)
583 (set-font-registry retval (match-string 1 fontname))
584 (set-font-encoding retval (match-string 2 fontname)))
587 (defun x-font-families-for-device (&optional device no-resetp)
588 (ignore-errors (require 'x-font-menu))
589 (or device (setq device (selected-device)))
590 (if (boundp 'device-fonts-cache)
591 (let ((menu (or (cdr-safe (assq device device-fonts-cache)))))
592 (if (and (not menu) (not no-resetp))
594 (declare-fboundp (reset-device-font-menus device))
595 (x-font-families-for-device device t))
596 (let ((scaled (mapcar #'(lambda (x) (if x (aref x 0)))
598 (normal (mapcar #'(lambda (x) (if x (aref x 0)))
600 (sort (font-unique (nconc scaled normal)) 'string-lessp))))
601 (cons "monospace" (mapcar 'car font-x-family-mappings))))
603 (defvar font-default-cache nil)
606 (defun font-default-font-for-device (&optional device)
607 (or device (setq device (selected-device)))
608 (if font-running-xemacs
611 (face-font-name 'default device)))
612 (let ((font (cdr-safe (assq 'font (frame-parameters device)))))
613 (if (and (fboundp 'fontsetp) (fontsetp font))
614 (aref (get-font-info (aref (cdr (get-fontset-info font)) 0)) 2)
618 (defun font-default-object-for-device (&optional device)
619 (let ((font (font-default-font-for-device device)))
620 (or (cdr-safe (assoc font font-default-cache))
621 (let ((object (font-create-object font)))
622 (push (cons font object) font-default-cache)
626 (defun font-default-family-for-device (&optional device)
627 (font-family (font-default-object-for-device (or device (selected-device)))))
630 (defun font-default-registry-for-device (&optional device)
631 (font-registry (font-default-object-for-device (or device (selected-device)))))
634 (defun font-default-encoding-for-device (&optional device)
635 (font-encoding (font-default-object-for-device (or device (selected-device)))))
638 (defun font-default-size-for-device (&optional device)
639 ;; face-height isn't the right thing (always 1 pixel too high?)
640 ;; (if font-running-xemacs
641 ;; (format "%dpx" (face-height 'default device))
642 (font-size (font-default-object-for-device (or device (selected-device)))))
644 (defun x-font-create-name (fontobj &optional device)
645 "Return a font name constructed from FONTOBJ, appropriate for X devices."
646 (if (and (not (or (font-family fontobj)
647 (font-weight fontobj)
649 (font-registry fontobj)
650 (font-encoding fontobj)))
651 (= (font-style fontobj) 0))
653 (or device (setq device (selected-device)))
654 (let* ((default (font-default-object-for-device device))
655 (family (or (font-family fontobj)
656 (font-family default)
657 (x-font-families-for-device device)))
658 (weight (or (font-weight fontobj) :medium))
659 ;(style (font-style fontobj))
660 (size (or (if font-running-xemacs
662 (font-size default)))
663 (registry (or (font-registry fontobj)
664 (font-registry default)
666 (encoding (or (font-encoding fontobj)
667 (font-encoding default)
670 (setq family (list family)))
671 (setq weight (font-higher-weight weight
672 (and (font-bold-p fontobj) :bold)))
674 (setq size (truncate (font-spatial-to-canonical size device))))
675 (setq weight (or (cdr-safe (assq weight x-font-weight-mappings)) "*"))
676 (let ((done nil) ; Did we find a good font yet?
677 (font-name nil) ; font name we are currently checking
678 (cur-family nil) ; current family we are checking
680 (while (and family (not done))
681 (setq cur-family (car family)
683 (if (assoc cur-family font-x-family-mappings)
684 ;; If the family name is an alias as defined by
685 ;; font-x-family-mappings, then append those families
686 ;; to the front of 'family' and continue in the loop.
688 (cdr-safe (assoc cur-family
689 font-x-family-mappings))
691 ;; Not an alias for a list of fonts, so we just check it.
692 ;; First, convert all '-' to spaces so that we don't screw up
693 ;; the oh-so wonderful X font model. Wheee.
694 (let ((x (length cur-family)))
696 (if (= ?- (aref cur-family (1- x)))
697 (aset cur-family (1- x) ? ))
699 ;; We treat oblique and italic as equivalent. Don't ask.
700 (let ((slants '("o" "i")))
701 (while (and slants (not done))
702 (setq font-name (format "-*-%s-%s-%s-*-*-*-%s-*-*-*-*-%s-%s"
704 (if (or (font-italic-p fontobj)
705 (font-oblique-p fontobj))
709 (int-to-string (* 10 size)) "*")
714 done (try-font-name font-name device))))))
715 (if done font-name)))))
718 ;;; Cache building code
720 (defun x-font-build-cache (&optional device)
721 (let ((hash-table (make-hash-table :test 'equal :size 15))
722 (fonts (mapcar 'x-font-create-object
723 (x-list-fonts "-*-*-*-*-*-*-*-*-*-*-*-*-*-*")))
727 (setq cur (car fonts)
729 plist (cl-gethash (car (font-family cur)) hash-table))
730 (if (not (memq (font-weight cur) (plist-get plist 'weights)))
731 (setq plist (plist-put plist 'weights (cons (font-weight cur)
732 (plist-get plist 'weights)))))
733 (if (not (member (font-size cur) (plist-get plist 'sizes)))
734 (setq plist (plist-put plist 'sizes (cons (font-size cur)
735 (plist-get plist 'sizes)))))
736 (if (and (font-oblique-p cur)
737 (not (memq 'oblique (plist-get plist 'styles))))
738 (setq plist (plist-put plist 'styles (cons 'oblique (plist-get plist 'styles)))))
739 (if (and (font-italic-p cur)
740 (not (memq 'italic (plist-get plist 'styles))))
741 (setq plist (plist-put plist 'styles (cons 'italic (plist-get plist 'styles)))))
742 (cl-puthash (car (font-family cur)) plist hash-table))
746 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
747 ;;; Now overwrite the original copy of set-face-font with our own copy that
748 ;;; can deal with either syntax.
749 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
751 (defun font-set-face-font (&optional face font &rest args)
753 ((and (vectorp font) (= (length font) 12))
754 (let ((font-name (font-create-name font)))
755 (set-face-property face 'font-specification font)
757 ((null font-name) ; No matching font!
759 ((listp font-name) ; For TTYs
762 (setq cur (car font-name)
763 font-name (cdr font-name))
764 (apply 'set-face-property face (car cur) (cdr cur) args))))
766 (apply 'set-face-font face font-name args)
767 (apply 'set-face-underline-p face (font-underline-p font) args)
768 (if (and (or (font-smallcaps-p font) (font-bigcaps-p font))
769 (fboundp 'set-face-display-table))
770 (apply 'set-face-display-table
771 face font-caps-display-table args))
772 (apply 'set-face-property face 'strikethru (or
773 (font-linethrough-p font)
774 (font-strikethru-p font))
778 (apply 'set-face-font face font-name args)
780 (let ((args (car-safe args)))
781 (and (or (font-bold-p font)
782 (memq (font-weight font) '(:bold :demi-bold)))
783 (make-face-bold face args t))
784 (and (font-italic-p font) (make-face-italic face args t)))))
785 (apply 'set-face-underline-p face (font-und