comparison lisp/x-faces.el @ 5118:e0db3c197671 ben-lisp-object

merge up to latest default branch, doesn't compile yet
author Ben Wing <ben@xemacs.org>
date Sat, 26 Dec 2009 21:18:49 -0600
parents de99c4dbad18
children 49480d838d32
comparison
equal deleted inserted replaced
5117:3742ea8250b5 5118:e0db3c197671
1 ;;; x-faces.el --- X-specific face frobnication, aka black magic. 1 ;;; x-faces.el --- X-specific face frobnication, aka black magic.
2 2
3 ;; Copyright (C) 1992-4, 1997 Free Software Foundation, Inc. 3 ;; Copyright (C) 1992-1994, 1997, 2006 Free Software Foundation, Inc.
4 ;; Copyright (C) 1995, 1996, 2002, 2004 Ben Wing. 4 ;; Copyright (C) 1995, 1996, 2002, 2004 Ben Wing.
5 5
6 ;; Author: Jamie Zawinski <jwz@jwz.org> 6 ;; Author: Jamie Zawinski <jwz@jwz.org>
7 ;; Maintainer: XEmacs Development Team 7 ;; Maintainer: XEmacs Development Team
8 ;; Keywords: extensions, internal, dumped 8 ;; Keywords: extensions, internal, dumped
63 ;;; Code: 63 ;;; Code:
64 64
65 (globally-declare-fboundp 65 (globally-declare-fboundp
66 '(x-get-resource-and-maybe-bogosity-check 66 '(x-get-resource-and-maybe-bogosity-check
67 x-get-resource x-init-pointer-shape)) 67 x-get-resource x-init-pointer-shape))
68
69 (if (featurep 'xft-fonts)
70 (require 'fontconfig)
71 (globally-declare-boundp
72 '(fc-font-name-weight-bold fc-font-name-weight-black
73 fc-font-name-weight-demibold fc-font-name-weight-medium
74 fc-font-name-slant-oblique fc-font-name-slant-italic
75 fc-font-name-slant-roman))
76 (globally-declare-fboundp
77 '(fc-font-match fc-pattern-del-size fc-pattern-get-size
78 fc-pattern-add-size fc-pattern-del-style fc-pattern-duplicate
79 fc-copy-pattern-partial fc-pattern-add-weight fc-pattern-del-weight
80 fc-try-font fc-pattern-del-slant fc-pattern-add-slant fc-name-parse
81 fc-name-unparse fc-pattern-get-pixelsize)))
68 82
69 (defconst x-font-regexp nil) 83 (defconst x-font-regexp nil)
70 (defconst x-font-regexp-head nil) 84 (defconst x-font-regexp-head nil)
71 (defconst x-font-regexp-head-2 nil) 85 (defconst x-font-regexp-head-2 nil)
72 (defconst x-font-regexp-weight nil) 86 (defconst x-font-regexp-weight nil)
76 (defconst x-font-regexp-foundry-and-family nil) 90 (defconst x-font-regexp-foundry-and-family nil)
77 (defconst x-font-regexp-registry-and-encoding nil) 91 (defconst x-font-regexp-registry-and-encoding nil)
78 (defconst x-font-regexp-spacing nil) 92 (defconst x-font-regexp-spacing nil)
79 93
80 ;;; Regexps matching font names in "Host Portable Character Representation." 94 ;;; Regexps matching font names in "Host Portable Character Representation."
95 ;;; #### But more recently Latin-1 is permitted, and Xft needs it in C (?).
81 ;;; 96 ;;;
82 (let ((- "[-?]") 97 (let ((- "[-?]")
83 (foundry "[^-]*") 98 (foundry "[^-]*")
84 (family "[^-]*") 99 (family "[^-]*")
85 (weight "\\(bold\\|demibold\\|medium\\|black\\)") ; 1 100 (weight "\\(bold\\|demibold\\|medium\\|black\\)") ; 1
132 (setq x-font-regexp-spacing 147 (setq x-font-regexp-spacing
133 (concat - "\\(" spacing "\\)" - avgwidth 148 (concat - "\\(" spacing "\\)" - avgwidth
134 - registry - encoding "\\'")) 149 - registry - encoding "\\'"))
135 ) 150 )
136 151
152 (defun x-font-xlfd-font-name-p (font)
153 "Check if FONT is an XLFD font name"
154 (and (stringp font)
155 (string-match x-font-regexp font)))
156
137 ;; A "loser font" is something like "8x13" -> "8x13bold". 157 ;; A "loser font" is something like "8x13" -> "8x13bold".
138 ;; These are supported only through extreme generosity. 158 ;; These are supported only through extreme generosity.
139 (defconst x-loser-font-regexp "\\`[0-9]+x[0-9]+\\'") 159 (defconst x-loser-font-regexp "\\`[0-9]+x[0-9]+\\'")
140 160
141 (defun x-frob-font-weight (font which) 161 (defun x-frob-font-weight (font which)
165 (t nil))) 185 (t nil)))
166 186
167 (defun x-make-font-bold (font &optional device) 187 (defun x-make-font-bold (font &optional device)
168 "Given an X font specification, this attempts to make a `bold' font. 188 "Given an X font specification, this attempts to make a `bold' font.
169 If it fails, it returns nil." 189 If it fails, it returns nil."
190 (if (featurep 'xft-fonts)
191 (if (x-font-xlfd-font-name-p font)
192 (x-make-font-bold-core font device)
193 (x-make-font-bold-xft font device))
194 (x-make-font-bold-core font device)))
195
196 (defun x-make-font-bold-xft (font &optional device)
197 (let ((pattern (fc-font-match (or device (default-x-device))
198 (fc-name-parse font))))
199 (if pattern
200 (let ((size (fc-pattern-get-size pattern 0))
201 (copy (fc-copy-pattern-partial pattern (list "family"))))
202 (fc-pattern-del-weight copy)
203 (fc-pattern-del-style copy)
204 (when copy
205 (or
206 ;; try bold font
207 (let ((copy-2 (fc-pattern-duplicate copy)))
208 (fc-pattern-add-weight copy-2 fc-font-name-weight-bold)
209 (when (fc-try-font copy-2 device)
210 (fc-pattern-add-size copy-2 size)
211 (fc-name-unparse copy-2)))
212 ;; try black font
213 (let ((copy-2 (fc-pattern-duplicate copy)))
214 (fc-pattern-add-weight copy-2 fc-font-name-weight-black)
215 (when (fc-try-font copy-2 device)
216 (fc-pattern-add-size copy-2 size)
217 (fc-name-unparse copy-2)))
218 ;; try demibold font
219 (let ((copy-2 (fc-pattern-duplicate copy)))
220 (fc-pattern-add-weight copy-2 fc-font-name-weight-demibold)
221 (when (fc-try-font copy-2 device)
222 (fc-pattern-add-size copy-2 size)
223 (fc-name-unparse copy-2)))))))))
224
225 (defun x-make-font-bold-core (font &optional device)
170 ;; Certain Type1 fonts know "bold" as "black"... 226 ;; Certain Type1 fonts know "bold" as "black"...
171 (or (try-font-name (x-frob-font-weight font "bold") device) 227 (or (try-font-name (x-frob-font-weight font "bold") device)
172 (try-font-name (x-frob-font-weight font "black") device) 228 (try-font-name (x-frob-font-weight font "black") device)
173 (try-font-name (x-frob-font-weight font "demibold") device))) 229 (try-font-name (x-frob-font-weight font "demibold") device)))
174 230
175 (defun x-make-font-unbold (font &optional device) 231 (defun x-make-font-unbold (font &optional device)
176 "Given an X font specification, this attempts to make a non-bold font. 232 "Given an X font specification, this attempts to make a non-bold font.
177 If it fails, it returns nil." 233 If it fails, it returns nil."
234 (if (featurep 'xft-fonts)
235 (if (x-font-xlfd-font-name-p font)
236 (x-make-font-unbold-core font device)
237 (x-make-font-unbold-xft font device))
238 (x-make-font-unbold-core font device)))
239
240 (defun x-make-font-unbold-xft (font &optional device)
241 (let ((pattern (fc-font-match (or device (default-x-device))
242 (fc-name-parse font))))
243 (when pattern
244 (fc-pattern-del-weight pattern)
245 (fc-pattern-add-weight pattern fc-font-name-weight-medium)
246 (if (fc-try-font pattern device)
247 (fc-name-unparse pattern)))))
248
249 (defun x-make-font-unbold-core (font &optional device)
178 (try-font-name (x-frob-font-weight font "medium") device)) 250 (try-font-name (x-frob-font-weight font "medium") device))
179 251
180 (defcustom try-oblique-before-italic-fonts nil 252 (defcustom try-oblique-before-italic-fonts nil
181 "*If nil, italic fonts are searched before oblique fonts. 253 "*If nil, italic fonts are searched before oblique fonts.
182 If non-nil, oblique fonts are tried before italic fonts. This is mostly 254 If non-nil, oblique fonts are tried before italic fonts. This is mostly
187 'try-oblique-before-italic-fonts) 259 'try-oblique-before-italic-fonts)
188 260
189 (defun x-make-font-italic (font &optional device) 261 (defun x-make-font-italic (font &optional device)
190 "Given an X font specification, this attempts to make an `italic' font. 262 "Given an X font specification, this attempts to make an `italic' font.
191 If it fails, it returns nil." 263 If it fails, it returns nil."
264 (if (featurep 'xft-fonts)
265 (if (x-font-xlfd-font-name-p font)
266 (x-make-font-italic-core font device)
267 (x-make-font-italic-xft font device))
268 (x-make-font-italic-core font device)))
269
270 (defun x-make-font-italic-xft (font &optional device)
271 (let ((pattern (fc-font-match (or device (default-x-device))
272 (fc-name-parse font))))
273 (if pattern
274 (let ((size (fc-pattern-get-size pattern 0))
275 (copy (fc-copy-pattern-partial pattern (list "family"))))
276 (when copy
277 (fc-pattern-del-slant copy)
278 (fc-pattern-del-style copy)
279 ;; #### can't we do this with one ambiguous pattern?
280 (let ((pattern-oblique (fc-pattern-duplicate copy))
281 (pattern-italic (fc-pattern-duplicate copy)))
282 (fc-pattern-add-slant pattern-oblique fc-font-name-slant-oblique)
283 (fc-pattern-add-slant pattern-italic fc-font-name-slant-italic)
284 (let ((have-oblique (fc-try-font pattern-oblique device))
285 (have-italic (fc-try-font pattern-italic device)))
286 (if try-oblique-before-italic-fonts
287 (if have-oblique
288 (progn
289 (if size
290 (fc-pattern-add-size pattern-oblique size))
291 (fc-name-unparse pattern-oblique))
292 (if have-italic
293 (progn
294 (if size
295 (fc-pattern-add-size pattern-italic size))
296 (fc-name-unparse pattern-italic))))
297 (if have-italic
298 (progn
299 (if size
300 (fc-pattern-add-size pattern-italic size))
301 (fc-name-unparse pattern-italic))
302 (if have-oblique
303 (progn
304 (if size
305 (fc-pattern-add-size pattern-oblique size))
306 (fc-name-unparse pattern-oblique))))))))))))
307
308 (defun x-make-font-italic-core (font &optional device)
192 (if try-oblique-before-italic-fonts 309 (if try-oblique-before-italic-fonts
193 (or (try-font-name (x-frob-font-slant font "o") device) 310 (or (try-font-name (x-frob-font-slant font "o") device)
194 (try-font-name (x-frob-font-slant font "i") device)) 311 (try-font-name (x-frob-font-slant font "i") device))
195 (or (try-font-name (x-frob-font-slant font "i") device) 312 (or (try-font-name (x-frob-font-slant font "i") device)
196 (try-font-name (x-frob-font-slant font "o") device)))) 313 (try-font-name (x-frob-font-slant font "o") device))))
197 314
198 (defun x-make-font-unitalic (font &optional device) 315 (defun x-make-font-unitalic (font &optional device)
199 "Given an X font specification, this attempts to make a non-italic font. 316 "Given an X font specification, this attempts to make a non-italic font.
200 If it fails, it returns nil." 317 If it fails, it returns nil."
318 (if (featurep 'xft-fonts)
319 (if (x-font-xlfd-font-name-p font)
320 (x-make-font-unitalic-core font device)
321 (x-make-font-unitalic-xft font device))
322 (x-make-font-unitalic-core font device)))
323
324 (defun x-make-font-unitalic-xft (font &optional device)
325 (let ((pattern (fc-font-match (or device (default-x-device))
326 (fc-name-parse font))))
327 (when pattern
328 (fc-pattern-del-slant pattern)
329 (fc-pattern-add-slant pattern fc-font-name-slant-roman)
330 (if (fc-try-font pattern device)
331 (fc-name-unparse pattern)))))
332
333 (defun x-make-font-unitalic-core (font &optional device)
201 (try-font-name (x-frob-font-slant font "r") device)) 334 (try-font-name (x-frob-font-slant font "r") device))
202 335
203 (defun x-make-font-bold-italic (font &optional device) 336 (defun x-make-font-bold-italic (font &optional device)
204 "Given an X font specification, this attempts to make a `bold-italic' font. 337 "Given an X font specification, this attempts to make a `bold-italic' font.
205 If it fails, it returns nil." 338 If it fails, it returns nil."
339 (if (featurep 'xft-fonts)
340 (if (x-font-xlfd-font-name-p font)
341 (x-make-font-bold-italic-core font device)
342 (x-make-font-bold-italic-xft font device))
343 (x-make-font-bold-italic-core font device)))
344
345 (defun x-make-font-bold-italic-xft (font &optional device)
346 (let ((italic (x-make-font-italic-xft font device)))
347 (if italic
348 (x-make-font-bold-xft italic device))))
349
350 (defun x-make-font-bold-italic-core (font &optional device)
206 ;; This is haired up to avoid loading the "intermediate" fonts. 351 ;; This is haired up to avoid loading the "intermediate" fonts.
207 (if try-oblique-before-italic-fonts 352 (if try-oblique-before-italic-fonts
208 (or (try-font-name 353 (or (try-font-name
209 (x-frob-font-slant (x-frob-font-weight font "bold") "o") device) 354 (x-frob-font-slant (x-frob-font-weight font "bold") "o") device)
210 (try-font-name 355 (try-font-name
234 "Return the nominal size of the given font. 379 "Return the nominal size of the given font.
235 This is done by parsing its name, so it's likely to lose. 380 This is done by parsing its name, so it's likely to lose.
236 X fonts can be specified (by the user) in either pixels or 10ths of points, 381 X fonts can be specified (by the user) in either pixels or 10ths of points,
237 and this returns the first one it finds, so you have to decide which units 382 and this returns the first one it finds, so you have to decide which units
238 the returned value is measured in yourself..." 383 the returned value is measured in yourself..."
384 (if (featurep 'xft-fonts)
385 (if (x-font-xlfd-font-name-p font)
386 (x-font-size-core font)
387 (x-font-size-xft font))
388 (x-font-size-core font)))
389
390 ;; this is unbelievable &*@#
391 (defun x-font-size-xft (font)
392 (let ((pattern (fc-font-match (default-x-device)
393 (fc-name-parse font))))
394 (when pattern
395 (let ((pixelsize (fc-pattern-get-pixelsize pattern 0)))
396 (if (floatp pixelsize) (round pixelsize) pixelsize)))))
397
398 (defun x-font-size-core (font)
239 (if (font-instance-p font) (setq font (font-instance-name font))) 399 (if (font-instance-p font) (setq font (font-instance-name font)))
240 (cond ((or (string-match x-font-regexp font) 400 (cond ((or (string-match x-font-regexp font)
241 (string-match x-font-regexp-head-2 font)) 401 (string-match x-font-regexp-head-2 font))
242 (string-to-int (substring font (match-beginning 6) (match-end 6)))) 402 (string-to-int (substring font (match-beginning 6) (match-end 6))))
243 ((or (string-match x-font-regexp-pixel font) 403 ((or (string-match x-font-regexp-pixel font)
352 (defun x-find-smaller-font (font &optional device) 512 (defun x-find-smaller-font (font &optional device)
353 "Load a new, slightly smaller version of the given font (or font name). 513 "Load a new, slightly smaller version of the given font (or font name).
354 Returns the font if it succeeds, nil otherwise. 514 Returns the font if it succeeds, nil otherwise.
355 If scalable fonts are available, this returns a font which is 1 point smaller. 515 If scalable fonts are available, this returns a font which is 1 point smaller.
356 Otherwise, it returns the next smaller version of this font that is defined." 516 Otherwise, it returns the next smaller version of this font that is defined."
517 (if (featurep 'xft-fonts)
518 (if (x-font-xlfd-font-name-p font)
519 (x-find-smaller-font-core font device)
520 (x-find-smaller-font-xft font device))
521 (x-find-smaller-font-core font device)))
522
523 (defun x-find-xft-font-of-size (font new-size-proc &optional device)
524 (let* ((pattern (fc-font-match (or device (default-x-device))
525 (fc-name-parse font))))
526 (when pattern
527 (let ((size (fc-pattern-get-size pattern 0)))
528 (if (floatp size)
529 (let ((copy (fc-pattern-duplicate pattern)))
530 (fc-pattern-del-size copy)
531 (fc-pattern-add-size copy (funcall new-size-proc size))
532 (if (fc-try-font font device)
533 (fc-name-unparse copy))))))))
534
535 (defun x-find-smaller-font-xft (font &optional device)
536 (x-find-xft-font-of-size font #'(lambda (old-size) (- old-size 1.0)) device))
537
538 (defun x-find-smaller-font-core (font &optional device)
357 (x-frob-font-size font nil device)) 539 (x-frob-font-size font nil device))
358 540
359 (defun x-find-larger-font (font &optional device) 541 (defun x-find-larger-font (font &optional device)
360 "Load a new, slightly larger version of the given font (or font name). 542 "Load a new, slightly larger version of the given font (or font name).
361 Returns the font if it succeeds, nil otherwise. 543 Returns the font if it succeeds, nil otherwise.
362 If scalable fonts are available, this returns a font which is 1 point larger. 544 If scalable fonts are available, this returns a font which is 1 point larger.
363 Otherwise, it returns the next larger version of this font that is defined." 545 Otherwise, it returns the next larger version of this font that is defined."
546 (if (featurep 'xft-fonts)
547 (if (x-font-xlfd-font-name-p font)
548 (x-find-larger-font-core font device)
549 (x-find-larger-font-xft font device))
550 (x-find-larger-font-core font device)))
551
552 (defun x-find-larger-font-xft (font &optional device)
553 (x-find-xft-font-of-size font #'(lambda (old-size) (+ old-size 1.0)) device))
554
555 (defun x-find-larger-font-core (font &optional device)
364 (x-frob-font-size font t device)) 556 (x-frob-font-size font t device))
365 557
366 (defalias 'x-make-face-bold 'make-face-bold) 558 (defalias 'x-make-face-bold 'make-face-bold)
367 (defalias 'x-make-face-italic 'make-face-italic) 559 (defalias 'x-make-face-italic 'make-face-italic)
368 (defalias 'x-make-face-bold-italic 'make-face-bold-italic) 560 (defalias 'x-make-face-bold-italic 'make-face-bold-italic)
393 "/usr/local/X11R5/lib/X11/" 585 "/usr/local/X11R5/lib/X11/"
394 "/usr/local/lib/X11R6/X11/" 586 "/usr/local/lib/X11R6/X11/"
395 "/usr/local/lib/X11R5/X11/" 587 "/usr/local/lib/X11R5/X11/"
396 "/usr/X11/lib/X11/" 588 "/usr/X11/lib/X11/"
397 "/usr/lib/X11/" 589 "/usr/lib/X11/"
590 "/usr/share/X11/"
398 "/usr/local/lib/X11/" 591 "/usr/local/lib/X11/"
592 "/usr/local/share/X11/"
399 "/usr/X386/lib/X11/" 593 "/usr/X386/lib/X11/"
400 "/usr/x386/lib/X11/" 594 "/usr/x386/lib/X11/"
401 "/usr/XFree86/lib/X11/" 595 "/usr/XFree86/lib/X11/"
402 "/usr/unsupported/lib/X11/" 596 "/usr/unsupported/lib/X11/"
403 "/usr/athena/lib/X11/" 597 "/usr/athena/lib/X11/"
407 "/usr/openwin/share/lib/X11/") 601 "/usr/openwin/share/lib/X11/")
408 "Search path used by `x-color-list-internal' to find rgb.txt.") 602 "Search path used by `x-color-list-internal' to find rgb.txt.")
409 603
410 (defvar x-color-list-internal-cache) 604 (defvar x-color-list-internal-cache)
411 605
606 ;; Ben originally coded this in 2005/01 to return a list of lists each
607 ;; containing a single string. This is apparently derived from use of
608 ;; this list in completion, but in fact `read-color-completion-table'
609 ;; already does this wrapping. So I'm changing this to return a list of
610 ;; strings as the TTY code does, and as expected by r-c-c-t.
611 ;; -- sjt 2007-10-06
612
613 ;; This function is probably also used by the GTK platform. Cf.
614 ;; gtk_color_list in src/objects-gtk.c.
412 (defun x-color-list-internal () 615 (defun x-color-list-internal ()
413 (if (boundp 'x-color-list-internal-cache) 616 (if (boundp 'x-color-list-internal-cache)
414 x-color-list-internal-cache 617 x-color-list-internal-cache
415 (let ((rgb-file (locate-file "rgb.txt" x-library-search-path)) 618 (let ((rgb-file (locate-file "rgb.txt" x-library-search-path))
416 clist color p) 619 clist color p)
427 (forward-char 1)) 630 (forward-char 1))
428 (skip-chars-forward "0-9 \t") 631 (skip-chars-forward "0-9 \t")
429 (setq p (point)) 632 (setq p (point))
430 (end-of-line) 633 (end-of-line)
431 (setq color (buffer-substring p (point)) 634 (setq color (buffer-substring p (point))
432 clist (cons (list color) clist)) 635 clist (cons color clist))
433 ;; Ugh. If we want to be able to complete the lowercase form 636 ;; Ugh. If we want to be able to complete the lowercase form
434 ;; of the color name, we need to add it twice! Yuck. 637 ;; of the color name, we need to add it twice! Yuck.
435 (let ((dcase (downcase color))) 638 (let ((dcase (downcase color)))
436 (or (string= dcase color) 639 (or (string= dcase color)
437 (push (list dcase) clist))) 640 (push dcase clist)))
438 (forward-char 1)) 641 (forward-char 1))
439 (kill-buffer (current-buffer)))) 642 (kill-buffer (current-buffer))))
440 (setq x-color-list-internal-cache clist) 643 (setq x-color-list-internal-cache clist)
441 x-color-list-internal-cache))) 644 x-color-list-internal-cache)))
442 645
457 ;;; 660 ;;;
458 ;;; This had better not signal an error. The frame is in an intermediate 661 ;;; This had better not signal an error. The frame is in an intermediate
459 ;;; state where signalling an error or entering the debugger would likely 662 ;;; state where signalling an error or entering the debugger would likely
460 ;;; result in a crash. 663 ;;; result in a crash.
461 664
665 ;; When we initialise a face from an X resource, note that we did so.
666 ;;
667 ;; Now in specifier.el so run-time checks for it on non-X builds don't
668 ;; error.
669
670 ; (define-specifier-tag 'x-resource)
671
462 (defun x-init-face-from-resources (face &optional locale set-anyway) 672 (defun x-init-face-from-resources (face &optional locale set-anyway)
463 673
464 ;; 674 ;;
465 ;; These are things like "attributeForeground" instead of simply 675 ;; These are things like "attributeForeground" instead of simply
466 ;; "foreground" because people tend to do things like "*foreground", 676 ;; "foreground" because people tend to do things like "*foreground",
485 ;; function uses the list cdrs. We want to remove (x 695 ;; function uses the list cdrs. We want to remove (x
486 ;; default) and (default) specs, not (default x) and (x) 696 ;; default) and (default) specs, not (default x) and (x)
487 ;; specs. 697 ;; specs.
488 (x-tag-set '(x default)) 698 (x-tag-set '(x default))
489 (tty-tag-set '(tty default)) 699 (tty-tag-set '(tty default))
700 (our-tag-set '(x x-resource))
490 (device-class nil) 701 (device-class nil)
491 (face-sym (face-name face)) 702 (face-sym (face-name face))
492 (name (symbol-name face-sym)) 703 (name (symbol-name face-sym))
493 (fn (x-get-resource-and-maybe-bogosity-check 704 (fn (x-get-resource-and-maybe-bogosity-check
494 (concat name ".attributeFont") 705 (concat name ".attributeFont")
542 (setq device-class (device-class locale)))) 753 (setq device-class (device-class locale))))
543 754
544 (if device-class 755 (if device-class
545 (setq tag-set (cons device-class tag-set) 756 (setq tag-set (cons device-class tag-set)
546 x-tag-set (cons device-class x-tag-set) 757 x-tag-set (cons device-class x-tag-set)
547 tty-tag-set (cons device-class tty-tag-set))) 758 tty-tag-set (cons device-class tty-tag-set)
759 our-tag-set (cons device-class our-tag-set)))
548 760
549 ;; 761 ;;
550 ;; If this is the default face, then any unspecified properties should 762 ;; If this is the default face, then any unspecified properties should
551 ;; be defaulted from the global properties. Can't do this for 763 ;; be defaulted from the global properties. Can't do this for
552 ;; frames or devices because then, common resource specs like 764 ;; frames or devices because then, common resource specs like
586 x-tag-set) 798 x-tag-set)
587 ;; If there's no device class then we're initializing 799 ;; If there's no device class then we're initializing
588 ;; globally. This means we should override global 800 ;; globally. This means we should override global
589 ;; defaults for all X device classes. 801 ;; defaults for all X device classes.
590 (remove-specifier (face-font face) locale x-tag-set nil)) 802 (remove-specifier (face-font face) locale x-tag-set nil))
591 (set-face-font face fn locale 'x append)) 803 (set-face-font face fn locale our-tag-set append)
804
805 ;; And retain some of the fallbacks in the generated default face,
806 ;; since we don't want to try andale-mono's ISO-10646-1 encoding for
807 ;; Amharic or Thai.
808 (when (and (specifierp (face-font face))
809 (consp (specifier-fallback (face-font face))))
810 (loop
811 for (tag-set . instantiator)
812 in (specifier-fallback (face-font face))
813 if (memq 'x-coverage-instantiator tag-set)
814 do (add-spec-list-to-specifier
815 (face-font face)
816 (list (cons (or locale 'global)
817 (list (cons tag-set instantiator))))
818 append))))
819
592 ;; Kludge-o-rooni. Set the foreground and background resources for 820 ;; Kludge-o-rooni. Set the foreground and background resources for
593 ;; X devices only -- otherwise things tend to get all messed up 821 ;; X devices only -- otherwise things tend to get all messed up
594 ;; if you start up an X frame and then later create a TTY frame. 822 ;; if you start up an X frame and then later create a TTY frame.
595 (when fg 823 (when fg
596 (if device-class 824 (if device-class
597 (remove-specifier-specs-matching-tag-set-cdrs (face-foreground face) 825 (remove-specifier-specs-matching-tag-set-cdrs (face-foreground face)
598 locale 826 locale
599 x-tag-set) 827 x-tag-set)
600 (remove-specifier (face-foreground face) locale x-tag-set nil)) 828 (remove-specifier (face-foreground face) locale x-tag-set nil))
601 (set-face-foreground face fg locale 'x append)) 829 (set-face-foreground face fg locale our-tag-set append))
602 (when bg 830 (when bg
603 (if device-class 831 (if device-class
604 (remove-specifier-specs-matching-tag-set-cdrs (face-background face) 832 (remove-specifier-specs-matching-tag-set-cdrs (face-background face)
605 locale 833 locale
606 x-tag-set) 834 x-tag-set)
607 (remove-specifier (face-background face) locale x-tag-set nil)) 835 (remove-specifier (face-background face) locale x-tag-set nil))
608 (set-face-background face bg locale 'x append)) 836 (set-face-background face bg locale our-tag-set append))
609 (when bgp 837 (when bgp
610 (if device-class 838 (if device-class
611 (remove-specifier-specs-matching-tag-set-cdrs (face-background-pixmap 839 (remove-specifier-specs-matching-tag-set-cdrs (face-background-pixmap
612 face) 840 face)
613 locale 841 locale
614 x-tag-set) 842 x-tag-set)
615 (remove-specifier (face-background-pixmap face) locale x-tag-set nil)) 843 (remove-specifier (face-background-pixmap face) locale x-tag-set nil))
616 (set-face-background-pixmap face bgp locale nil append)) 844 (set-face-background-pixmap face bgp locale our-tag-set append))
617 (when ulp 845 (when ulp
618 (if device-class 846 (if device-class
619 (remove-specifier-specs-matching-tag-set-cdrs (face-property 847 (remove-specifier-specs-matching-tag-set-cdrs (face-property
620 face 'underline) 848 face 'underline)
621 locale 849 locale
622 tty-tag-set) 850 tty-tag-set)
623 (remove-specifier (face-property face 'underline) locale 851 (remove-specifier (face-property face 'underline) locale
624 tty-tag-set nil)) 852 tty-tag-set nil))
625 (set-face-underline-p face ulp locale nil append)) 853 (set-face-underline-p face ulp locale our-tag-set append))
626 (when stp 854 (when stp
627 (if device-class 855 (if device-class
628 (remove-specifier-specs-matching-tag-set-cdrs (face-property 856 (remove-specifier-specs-matching-tag-set-cdrs (face-property
629 face 'strikethru) 857 face 'strikethru)
630 locale 858 locale
631 tty-tag-set) 859 tty-tag-set)
632 (remove-specifier (face-property face 'strikethru) 860 (remove-specifier (face-property face 'strikethru)
633 locale tty-tag-set nil)) 861 locale tty-tag-set nil))
634 (set-face-strikethru-p face stp locale nil append)) 862 (set-face-strikethru-p face stp locale our-tag-set append))
635 (when hp 863 (when hp
636 (if device-class 864 (if device-class
637 (remove-specifier-specs-matching-tag-set-cdrs (face-property 865 (remove-specifier-specs-matching-tag-set-cdrs (face-property
638 face 'highlight) 866 face 'highlight)
639 locale 867 locale
640 tty-tag-set) 868 tty-tag-set)
641 (remove-specifier (face-property face 'highlight) 869 (remove-specifier (face-property face 'highlight)
642 locale tty-tag-set nil)) 870 locale tty-tag-set nil))
643 (set-face-highlight-p face hp locale nil append)) 871 (set-face-highlight-p face hp locale our-tag-set append))
644 (when dp 872 (when dp
645 (if device-class 873 (if device-class
646 (remove-specifier-specs-matching-tag-set-cdrs (face-property 874 (remove-specifier-specs-matching-tag-set-cdrs (face-property
647 face 'dim) 875 face 'dim)
648 locale 876 locale
649 tty-tag-set) 877 tty-tag-set)
650 (remove-specifier (face-property face 'dim) locale tty-tag-set nil)) 878 (remove-specifier (face-property face 'dim) locale tty-tag-set nil))
651 (set-face-dim-p face dp locale nil append)) 879 (set-face-dim-p face dp locale our-tag-set append))
652 (when bp 880 (when bp
653 (if device-class 881 (if device-class
654 (remove-specifier-specs-matching-tag-set-cdrs (face-property 882 (remove-specifier-specs-matching-tag-set-cdrs (face-property
655 face 'blinking) 883 face 'blinking)
656 locale 884 locale
657 tty-tag-set) 885 tty-tag-set)
658 (remove-specifier (face-property face 'blinking) locale 886 (remove-specifier (face-property face 'blinking) locale
659 tty-tag-set nil)) 887 tty-tag-set nil))
660 (set-face-blinking-p face bp locale nil append)) 888 (set-face-blinking-p face bp locale our-tag-set append))
661 (when rp 889 (when rp
662 (if device-class 890 (if device-class
663 (remove-specifier-specs-matching-tag-set-cdrs (face-property 891 (remove-specifier-specs-matching-tag-set-cdrs (face-property
664 face 'reverse) 892 face 'reverse)
665 locale 893 locale
666 tty-tag-set) 894 tty-tag-set)
667 (remove-specifier (face-property face 'reverse) locale 895 (remove-specifier (face-property face 'reverse) locale
668 tty-tag-set nil)) 896 tty-tag-set nil))
669 (set-face-reverse-p face rp locale nil append)) 897 (set-face-reverse-p face rp locale our-tag-set append))
670 )) 898 ))
671 899
672 ;; GNU Emacs compatibility. (move to obsolete.el?) 900 ;; GNU Emacs compatibility. (move to obsolete.el?)
673 (defalias 'make-face-x-resource-internal 'x-init-face-from-resources) 901 (defalias 'make-face-x-resource-internal 'x-init-face-from-resources)
674 902