aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-08-03 07:12:34 +0000
committerRichard M. Stallman1993-08-03 07:12:34 +0000
commitf3f31ccf987cfe869948af93bb462e5d6ec0d924 (patch)
tree146f2f65485c1094174142fc675cc8980628006d
parent23524fb9509369fc89f843fbbad0a3de06bb0d1d (diff)
downloademacs-f3f31ccf987cfe869948af93bb462e5d6ec0d924.tar.gz
emacs-f3f31ccf987cfe869948af93bb462e5d6ec0d924.zip
Make boldness and italicness affect subsequently created frames.
(make-face-bold, make-face-italic, make-face-bold-italic) (make-face-unbold, make-face-unitalic): Update global-face-data. Ignore a list found in the font slot. (make-face-bold-internal, make-face-italic-internal): (make-face-bold-italic-internal): New subroutines. (x-create-frame-with-faces): If global-face-data's font slot indicates bold and/or italic, make it so.
-rw-r--r--lisp/faces.el320
1 files changed, 196 insertions, 124 deletions
diff --git a/lisp/faces.el b/lisp/faces.el
index a79803c71ca..37212d90ad5 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -50,19 +50,24 @@
50(defsubst face-font (face &optional frame) 50(defsubst face-font (face &optional frame)
51 "Return the font name of face FACE, or nil if it is unspecified. 51 "Return the font name of face FACE, or nil if it is unspecified.
52If the optional argument FRAME is given, report on face FACE in that frame. 52If the optional argument FRAME is given, report on face FACE in that frame.
53Otherwise report on the defaults for face FACE (for new frames)." 53If FRAME is t, report on the defaults for face FACE (for new frames).
54 The font default for a face is either nil, or a list
55 of the form (bold), (italic) or (bold italic).
56If FRAME is omitted or nil, use the selected frame."
54 (aref (internal-get-face face frame) 3)) 57 (aref (internal-get-face face frame) 3))
55 58
56(defsubst face-foreground (face &optional frame) 59(defsubst face-foreground (face &optional frame)
57 "Return the foreground color name of face FACE, or nil if unspecified. 60 "Return the foreground color name of face FACE, or nil if unspecified.
58If the optional argument FRAME is given, report on face FACE in that frame. 61If the optional argument FRAME is given, report on face FACE in that frame.
59Otherwise report on the defaults for face FACE (for new frames)." 62If FRAME is t, report on the defaults for face FACE (for new frames).
63If FRAME is omitted or nil, use the selected frame."
60 (aref (internal-get-face face frame) 4)) 64 (aref (internal-get-face face frame) 4))
61 65
62(defsubst face-background (face &optional frame) 66(defsubst face-background (face &optional frame)
63 "Return the background color name of face FACE, or nil if unspecified. 67 "Return the background color name of face FACE, or nil if unspecified.
64If the optional argument FRAME is given, report on face FACE in that frame. 68If the optional argument FRAME is given, report on face FACE in that frame.
65Otherwise report on the defaults for face FACE (for new frames)." 69If FRAME is t, report on the defaults for face FACE (for new frames).
70If FRAME is omitted or nil, use the selected frame."
66 (aref (internal-get-face face frame) 5)) 71 (aref (internal-get-face face frame) 5))
67 72
68;;(defsubst face-background-pixmap (face &optional frame) 73;;(defsubst face-background-pixmap (face &optional frame)
@@ -74,7 +79,8 @@ Otherwise report on the defaults for face FACE (for new frames)."
74(defsubst face-underline-p (face &optional frame) 79(defsubst face-underline-p (face &optional frame)
75 "Return t if face FACE is underlined. 80 "Return t if face FACE is underlined.
76If the optional argument FRAME is given, report on face FACE in that frame. 81If the optional argument FRAME is given, report on face FACE in that frame.
77Otherwise report on the defaults for face FACE (for new frames)." 82If FRAME is t, report on the defaults for face FACE (for new frames).
83If FRAME is omitted or nil, use the selected frame."
78 (aref (internal-get-face face frame) 7)) 84 (aref (internal-get-face face frame) 7))
79 85
80 86
@@ -462,35 +468,34 @@ also the same size as FACE on FRAME."
462 468
463 469
464(defun x-make-font-bold (font) 470(defun x-make-font-bold (font)
465 "Given an X font specification, this attempts to make a `bold' version 471 "Given an X font specification, make a bold version of it.
466of it. If it fails, it returns nil." 472If that can't be done, return nil."
467 (x-frob-font-weight font "bold")) 473 (x-frob-font-weight font "bold"))
468 474
469(defun x-make-font-demibold (font) 475(defun x-make-font-demibold (font)
470 "Given an X font specification, this attempts to make a `demibold' version 476 "Given an X font specification, make a demibold version of it.
471of it. If it fails, it returns nil." 477If that can't be done, return nil."
472 (x-frob-font-weight font "demibold")) 478 (x-frob-font-weight font "demibold"))
473 479
474(defun x-make-font-unbold (font) 480(defun x-make-font-unbold (font)
475 "Given an X font specification, this attempts to make a non-bold version 481 "Given an X font specification, make a non-bold version of it.
476of it. If it fails, it returns nil." 482If that can't be done, return nil."
477 (x-frob-font-weight font "medium")) 483 (x-frob-font-weight font "medium"))
478 484
479(defun x-make-font-italic (font) 485(defun x-make-font-italic (font)
480 "Given an X font specification, this attempts to make an `italic' version 486 "Given an X font specification, make an italic version of it.
481of it. If it fails, it returns nil." 487If that can't be done, return nil."
482 (x-frob-font-slant font "i")) 488 (x-frob-font-slant font "i"))
483 489
484(defun x-make-font-oblique (font) ; you say tomayto... 490(defun x-make-font-oblique (font) ; you say tomayto...
485 "Given an X font specification, this attempts to make an `italic' version 491 "Given an X font specification, make an oblique version of it.
486of it. If it fails, it returns nil." 492If that can't be done, return nil."
487 (x-frob-font-slant font "o")) 493 (x-frob-font-slant font "o"))
488 494
489(defun x-make-font-unitalic (font) 495(defun x-make-font-unitalic (font)
490 "Given an X font specification, this attempts to make a non-italic version 496 "Given an X font specification, make a non-italic version of it.
491of it. If it fails, it returns nil." 497If that can't be done, return nil."
492 (x-frob-font-slant font "r")) 498 (x-frob-font-slant font "r"))
493
494 499
495;;; non-X-specific interface 500;;; non-X-specific interface
496 501
@@ -498,133 +503,191 @@ of it. If it fails, it returns nil."
498 "Make the font of the given face be bold, if possible. 503 "Make the font of the given face be bold, if possible.
499If NOERROR is non-nil, return nil on failure." 504If NOERROR is non-nil, return nil on failure."
500 (interactive (list (read-face-name "Make which face bold: "))) 505 (interactive (list (read-face-name "Make which face bold: ")))
501 (let ((ofont (face-font face frame)) 506 (if (eq frame t)
502 font f2) 507 (set-face-font face (if (memq 'italic (face-font face t))
503 (if (null frame) 508 '(bold italic) '(bold))
504 (let ((frames (frame-list))) 509 t)
505 (while frames 510 (let ((ofont (face-font face frame))
506 (make-face-bold face (car frames) noerror) 511 font f2)
507 (setq frames (cdr frames)))) 512 (if (null frame)
508 (setq face (internal-get-face face frame)) 513 (let ((frames (frame-list)))
509 (setq font (or (face-font face frame) 514 ;; Make this face bold in global-face-data.
510 (face-font face t) 515 (make-face-bold face t noerror)
511 (face-font 'default frame) 516 ;; Make this face bold in each frame.
512 (cdr (assq 'font (frame-parameters frame))))) 517 (while frames
513 (or (and (setq f2 (x-make-font-bold font)) 518 (make-face-bold face (car frames) noerror)
514 (internal-try-face-font face f2 frame)) 519 (setq frames (cdr frames))))
515 (and (setq f2 (x-make-font-demibold font)) 520 (setq face (internal-get-face face frame))
516 (internal-try-face-font face f2 frame)))) 521 (setq font (or (face-font face frame)
517 (or (not (equal ofont (face-font face))) 522 (face-font face t)))
518 (and (not noerror) 523 (if (listp font)
519 (error "No bold version of %S" font))))) 524 (setq font nil))
525 (setq font (or font
526 (face-font 'default frame)
527 (cdr (assq 'font (frame-parameters frame)))))
528 (make-face-bold-internal face frame))
529 (or (not (equal ofont (face-font face)))
530 (and (not noerror)
531 (error "No bold version of %S" font))))))
532
533(defun make-face-bold-internal (face frame)
534 (or (and (setq f2 (x-make-font-bold font))
535 (internal-try-face-font face f2 frame))
536 (and (setq f2 (x-make-font-demibold font))
537 (internal-try-face-font face f2 frame))))
520 538
521(defun make-face-italic (face &optional frame noerror) 539(defun make-face-italic (face &optional frame noerror)
522 "Make the font of the given face be italic, if possible. 540 "Make the font of the given face be italic, if possible.
523If NOERROR is non-nil, return nil on failure." 541If NOERROR is non-nil, return nil on failure."
524 (interactive (list (read-face-name "Make which face italic: "))) 542 (interactive (list (read-face-name "Make which face italic: ")))
525 (let ((ofont (face-font face frame)) 543 (if (eq frame t)
526 font f2) 544 (set-face-font face (if (memq 'bold (face-font face t))
527 (if (null frame) 545 '(bold italic) '(italic))
528 (let ((frames (frame-list))) 546 t)
529 (while frames 547 (let ((ofont (face-font face frame))
530 (make-face-italic face (car frames) noerror) 548 font f2)
531 (setq frames (cdr frames)))) 549 (if (null frame)
532 (setq face (internal-get-face face frame)) 550 (let ((frames (frame-list)))
533 (setq font (or (face-font face frame) 551 ;; Make this face italic in global-face-data.
534 (face-font face t) 552 (make-face-italic face t noerror)
535 (face-font 'default frame) 553 ;; Make this face italic in each frame.
536 (cdr (assq 'font (frame-parameters frame))))) 554 (while frames
537 (or (and (setq f2 (x-make-font-italic font)) 555 (make-face-italic face (car frames) noerror)
538 (internal-try-face-font face f2 frame)) 556 (setq frames (cdr frames))))
539 (and (setq f2 (x-make-font-oblique font)) 557 (setq face (internal-get-face face frame))
540 (internal-try-face-font face f2 frame)))) 558 (setq font (or (face-font face frame)
541 (or (not (equal ofont (face-font face))) 559 (face-font face t)))
542 (and (not noerror) 560 (if (listp font)
543 (error "No italic version of %S" font))))) 561 (setq font nil))
562 (setq font (or font
563 (face-font 'default frame)
564 (cdr (assq 'font (frame-parameters frame)))))
565 (make-face-italic-internal face frame))
566 (or (not (equal ofont (face-font face)))
567 (and (not noerror)
568 (error "No italic version of %S" font))))))
569
570(defun make-face-italic-internal (face frame)
571 (or (and (setq f2 (x-make-font-italic font))
572 (internal-try-face-font face f2 frame))
573 (and (setq f2 (x-make-font-oblique font))
574 (internal-try-face-font face f2 frame))))
544 575
545(defun make-face-bold-italic (face &optional frame noerror) 576(defun make-face-bold-italic (face &optional frame noerror)
546 "Make the font of the given face be bold and italic, if possible. 577 "Make the font of the given face be bold and italic, if possible.
547If NOERROR is non-nil, return nil on failure." 578If NOERROR is non-nil, return nil on failure."
548 (interactive (list (read-face-name "Make which face bold-italic: "))) 579 (interactive (list (read-face-name "Make which face bold-italic: ")))
549 (let ((ofont (face-font face frame)) 580 (if (eq frame t)
550 font f2 f3) 581 (set-face-font face '(bold italic) t)
551 (if (null frame) 582 (let ((ofont (face-font face frame))
552 (let ((frames (frame-list))) 583 font)
553 (while frames 584 (if (null frame)
554 (make-face-bold-italic face (car frames) noerror) 585 (let ((frames (frame-list)))
555 (setq frames (cdr frames)))) 586 ;; Make this face bold-italic in global-face-data.
556 (setq face (internal-get-face face frame)) 587 (make-face-bold-italic face t noerror)
557 (setq font (or (face-font face frame) 588 ;; Make this face bold in each frame.
558 (face-font face t) 589 (while frames
559 (face-font 'default frame) 590 (make-face-bold-italic face (car frames) noerror)
560 (cdr (assq 'font (frame-parameters frame))))) 591 (setq frames (cdr frames))))
561 (or (and (setq f2 (x-make-font-italic font)) 592 (setq face (internal-get-face face frame))
562 (not (equal font f2)) 593 (setq font (or (face-font face frame)
563 (setq f3 (x-make-font-bold f2)) 594 (face-font face t)))
564 (not (equal f2 f3)) 595 (if (listp font)
565 (internal-try-face-font face f3 frame)) 596 (setq font nil))
566 (and (setq f2 (x-make-font-oblique font)) 597 (setq font (or font
567 (not (equal font f2)) 598 (face-font 'default frame)
568 (setq f3 (x-make-font-bold f2)) 599 (cdr (assq 'font (frame-parameters frame)))))
569 (not (equal f2 f3)) 600 (make-face-bold-italic-internal face frame))
570 (internal-try-face-font face f3 frame)) 601 (or (not (equal ofont (face-font face)))
571 (and (setq f2 (x-make-font-italic font)) 602 (and (not noerror)
572 (not (equal font f2)) 603 (error "No bold italic version of %S" font))))))
573 (setq f3 (x-make-font-demibold f2)) 604
574 (not (equal f2 f3)) 605(defun make-face-bold-italic-internal (face frame)
575 (internal-try-face-font face f3 frame)) 606 (let (f2 f3)
576 (and (setq f2 (x-make-font-oblique font)) 607 (or (and (setq f2 (x-make-font-italic font))
577 (not (equal font f2)) 608 (not (equal font f2))
578 (setq f3 (x-make-font-demibold f2)) 609 (setq f3 (x-make-font-bold f2))
579 (not (equal f2 f3)) 610 (not (equal f2 f3))
580 (internal-try-face-font face f3 frame)))) 611 (internal-try-face-font face f3 frame))
581 (or (not (equal ofont (face-font face))) 612 (and (setq f2 (x-make-font-oblique font))
582 (and (not noerror) 613 (not (equal font f2))
583 (error "No bold italic version of %S" font))))) 614 (setq f3 (x-make-font-bold f2))
615 (not (equal f2 f3))
616 (internal-try-face-font face f3 frame))
617 (and (setq f2 (x-make-font-italic font))
618 (not (equal font f2))
619 (setq f3 (x-make-font-demibold f2))
620 (not (equal f2 f3))
621 (internal-try-face-font face f3 frame))
622 (and (setq f2 (x-make-font-oblique font))
623 (not (equal font f2))
624 (setq f3 (x-make-font-demibold f2))
625 (not (equal f2 f3))
626 (internal-try-face-font face f3 frame)))))
584 627
585(defun make-face-unbold (face &optional frame noerror) 628(defun make-face-unbold (face &optional frame noerror)
586 "Make the font of the given face be non-bold, if possible. 629 "Make the font of the given face be non-bold, if possible.
587If NOERROR is non-nil, return nil on failure." 630If NOERROR is non-nil, return nil on failure."
588 (interactive (list (read-face-name "Make which face non-bold: "))) 631 (interactive (list (read-face-name "Make which face non-bold: ")))
589 (let ((ofont (face-font face frame)) 632 (if (eq frame t)
590 font font1) 633 (set-face-font face (if (memq 'italic (face-font face t))
591 (if (null frame) 634 '(italic) nil)
592 (let ((frames (frame-list))) 635 t)
593 (while frames 636 (let ((ofont (face-font face frame))
594 (make-face-unbold face (car frames) noerror) 637 font font1)
595 (setq frames (cdr frames)))) 638 (if (null frame)
596 (setq face (internal-get-face face frame)) 639 (let ((frames (frame-list)))
597 (setq font1 (or (face-font face frame) 640 ;; Make this face unbold in global-face-data.
598 (face-font face t) 641 (make-face-unbold face t noerror)
599 (face-font 'default frame) 642 ;; Make this face unbold in each frame.
600 (cdr (assq 'font (frame-parameters frame))))) 643 (while frames
601 (setq font (x-make-font-unbold font1)) 644 (make-face-unbold face (car frames) noerror)
602 (if font (internal-try-face-font face font frame))) 645 (setq frames (cdr frames))))
603 (or (not (equal ofont (face-font face))) 646 (setq face (internal-get-face face frame))
604 (and (not noerror) 647 (setq font1 (or (face-font face frame)
605 (error "No unbold version of %S" font1))))) 648 (face-font face t)))
649 (if (listp font1)
650 (setq font1 nil))
651 (setq font1 (or font1
652 (face-font 'default frame)
653 (cdr (assq 'font (frame-parameters frame)))))
654 (setq font (x-make-font-unbold font1))
655 (if font (internal-try-face-font face font frame)))
656 (or (not (equal ofont (face-font face)))
657 (and (not noerror)
658 (error "No unbold version of %S" font1))))))
606 659
607(defun make-face-unitalic (face &optional frame noerror) 660(defun make-face-unitalic (face &optional frame noerror)
608 "Make the font of the given face be non-italic, if possible. 661 "Make the font of the given face be non-italic, if possible.
609If NOERROR is non-nil, return nil on failure." 662If NOERROR is non-nil, return nil on failure."
610 (interactive (list (read-face-name "Make which face non-italic: "))) 663 (interactive (list (read-face-name "Make which face non-italic: ")))
611 (let ((ofont (face-font face frame)) 664 (if (eq frame t)
612 font font1) 665 (set-face-font face (if (memq 'bold (face-font face t))
613 (if (null frame) 666 '(bold) nil)
614 (let ((frames (frame-list))) 667 t)
615 (while frames 668 (let ((ofont (face-font face frame))
616 (make-face-unitalic face (car frames) noerror) 669 font font1)
617 (setq frames (cdr frames)))) 670 (if (null frame)
618 (setq face (internal-get-face face frame)) 671 (let ((frames (frame-list)))
619 (setq font1 (or (face-font face frame) 672 ;; Make this face unitalic in global-face-data.
620 (face-font face t) 673 (make-face-unitalic face t noerror)
621 (face-font 'default frame) 674 ;; Make this face unitalic in each frame.
622 (cdr (assq 'font (frame-parameters frame))))) 675 (while frames
623 (setq font (x-make-font-unitalic font1)) 676 (make-face-unitalic face (car frames) noerror)
624 (if font (internal-try-face-font face font frame))) 677 (setq frames (cdr frames))))
625 (or (not (equal ofont (face-font face))) 678 (setq face (internal-get-face face frame))
626 (and (not noerror) 679 (setq font1 (or (face-font face frame)
627 (error "No unitalic version of %S" font1))))) 680 (face-font face t)))
681 (if (listp font1)
682 (setq font1 nil))
683 (setq font1 (or font1
684 (face-font 'default frame)
685 (cdr (assq 'font (frame-parameters frame)))))
686 (setq font (x-make-font-unitalic font1))
687 (if font (internal-try-face-font face font frame)))
688 (or (not (equal ofont (face-font face)))
689 (and (not noerror)
690 (error "No unitalic version of %S" font1))))))
628 691
629(defvar list-faces-sample-text 692(defvar list-faces-sample-text
630 "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ" 693 "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@@ -827,6 +890,15 @@ selected frame."
827 ;; Also fill them in from X resources. 890 ;; Also fill them in from X resources.
828 (while rest 891 (while rest
829 (setcdr (car rest) (copy-sequence (cdr (car rest)))) 892 (setcdr (car rest) (copy-sequence (cdr (car rest))))
893 (if (listp (face-font (cdr (car rest))))
894 (let ((bold (memq 'bold (face-font (cdr (car rest)))))
895 (italic (memq 'italic (face-font (cdr (car rest))))))
896 (if (and bold italic)
897 (make-face-bold-italic (car (car rest)) frame)
898 (if bold
899 (make-face-bold (car (car rest)) frame)
900 (if italic
901 (make-face-italic (car (car rest)) frame))))))
830 (make-face-x-resource-internal (cdr (car rest)) frame t) 902 (make-face-x-resource-internal (cdr (car rest)) frame t)
831 (setq rest (cdr rest))) 903 (setq rest (cdr rest)))
832 904