update.
[chise/xemacs-chise.git.1] / lisp / faces.el
index 568c7ae..a4f56ea 100644 (file)
@@ -761,7 +761,10 @@ See `face-property-instance' for the semantics of the DOMAIN argument."
     (and (face-equal-loop common-props face1 face2 domain)
         (cond ((eq 'tty (device-type device))
                (face-equal-loop tty-props face1 face2 domain))
+              ;; #### Why isn't this (console-on-window-system-p (device-console device))?
+              ;; #### FIXME!
               ((or (eq 'x (device-type device))
+                   (eq 'gtk (device-type device))
                    (eq 'mswindows (device-type device)))
                (face-equal-loop win-props face1 face2 domain))
               (t t)))))
@@ -844,10 +847,21 @@ the function to be called on it."
 
 
       (setq temp-sp (copy-specifier sp))
-      (if (and (or (eq locale 'global) (eq locale 'all) (not locale))
-              (not (face-property face property 'global)))
-         (copy-specifier (face-property 'default property)
-                         temp-sp 'global))
+      (if (or (eq locale 'global) (eq locale 'all) (not locale))
+         (when (not (specifier-specs temp-sp 'global))
+           ;; Try fallback via the official ways and then do it "by hand"
+           (let* ((fallback (specifier-fallback sp))
+                  (fallback-sp 
+                   (cond ((specifierp fallback) fallback)
+                         ;; just an inst list
+                         (fallback
+                          (make-specifier-and-init (specifier-type sp)
+                                                   fallback))
+                         ((eq (get-face face) (get-face 'default))
+                          (error "Unable to find global specification"))
+                         ;; If no fallback we snoop from default
+                         (t (face-property 'default property)))))
+             (copy-specifier fallback-sp temp-sp 'global))))
       (if (and (valid-specifier-locale-p locale)
               (not (specifier-specs temp-sp locale)))
          (error "Property must have a specification in locale %S" locale))
@@ -983,6 +997,27 @@ multi-charset environments."
                  (face-property-instance unfrobbed-face 'font domain))
           (set-face-property face 'font (vector frobbed-face) the-locale tags)))))))
 
+;; WE DEMAND FOUNDRY FROBBING!
+
+;; Family frobbing
+;; Thx Jan Vroonhof, Ref xemacs-beta <87oflypbum.fsf@petteflet.ntlworld.com>
+;; Brainlessly derived from make-face-size by Stephen; don't blame Jan.
+;; I'm long since flown to Rio, it does you little good to blame me, either.
+(defun make-face-family (face family &optional locale tags)
+  "Set FACE's family to FAMILY in LOCALE, if possible.
+
+Add/replace settings specified by TAGS only."
+  (frob-face-property face 'font
+                     ;; uses dynamic scope of family
+                     #'(lambda (f d)
+                         ;; keep the dependency on font.el for now
+                         (let ((fo (font-create-object (font-instance-name f)
+                                                       d)))
+                           (set-font-family fo family)
+                           (font-create-name fo d)))
+                     nil locale tags))
+
+;; Style (ie, typographical face) frobbing
 (defun make-face-bold (face &optional locale tags)
   "Make FACE bold in LOCALE, if possible.
 This will attempt to make the font bold for X/MSW locales and will set the
@@ -1018,7 +1053,10 @@ circumstances."
      (when (featurep 'tty)
        (set-face-highlight-p face t locale (cons 'tty tags))))
    (lambda ()
-     ;; handle X/MS Windows specific entries
+     ;; handle window-system specific entries
+     (when (featurep 'gtk)
+       (frob-face-property face 'font 'gtk-make-font-bold
+                          '(gtk) locale tags))
      (when (featurep 'x)
        (frob-face-property face 'font 'x-make-font-bold
                           '(x) locale tags))
@@ -1045,7 +1083,10 @@ how this function works."
      (when (featurep 'tty)
        (set-face-underline-p face t locale (cons 'tty tags))))
    (lambda ()
-     ;; handle X specific entries
+     ;; handle window-system specific entries
+     (when (featurep 'gtk)
+       (frob-face-property face 'font 'gtk-make-font-italic
+                          '(gtk) locale tags))
      (when (featurep 'x)
        (frob-face-property face 'font 'x-make-font-italic
                           '(x) locale tags))
@@ -1073,7 +1114,10 @@ argument and for more specifics on exactly how this function works."
        (set-face-highlight-p face t locale (cons 'tty tags))
        (set-face-underline-p face t locale (cons 'tty tags))))
    (lambda ()
-     ;; handle X specific entries
+     ;; handle window-system specific entries
+     (when (featurep 'gtk)
+       (frob-face-property face 'font 'gtk-make-font-bold-italic
+                          '(gtk) locale tags))
      (when (featurep 'x)
        (frob-face-property face 'font 'x-make-font-bold-italic
                           '(x) locale tags))
@@ -1100,7 +1144,10 @@ specifics on exactly how this function works."
      (when (featurep 'tty)
        (set-face-highlight-p face nil locale (cons 'tty tags))))
    (lambda ()
-     ;; handle X specific entries
+     ;; handle window-system specific entries
+     (when (featurep 'gtk)
+       (frob-face-property face 'font 'gtk-make-font-unbold
+                          '(gtk) locale tags))
      (when (featurep 'x)
        (frob-face-property face 'font 'x-make-font-unbold
                           '(x) locale tags))
@@ -1127,7 +1174,10 @@ specifics on exactly how this function works."
      (when (featurep 'tty)
        (set-face-underline-p face nil locale (cons 'tty tags))))
    (lambda ()
-     ;; handle X specific entries
+     ;; handle window-system specific entries
+     (when (featurep 'gtk)
+       (frob-face-property face 'font 'gtk-make-font-unitalic
+                          '(gtk) locale tags))
      (when (featurep 'x)
        (frob-face-property face 'font 'x-make-font-unitalic
                           '(x) locale tags))
@@ -1141,6 +1191,23 @@ specifics on exactly how this function works."
      ([bold-italic] . [bold]))))
 
 
+;; Size frobbing
+;; Thx Jan Vroonhof, Ref xemacs-beta <87oflypbum.fsf@petteflet.ntlworld.com>
+;; Jan had a separate helper function 
+(defun make-face-size (face size &optional locale tags)
+  "Adjust FACE to SIZE in LOCALE, if possible.
+
+Add/replace settings specified by TAGS only."
+  (frob-face-property face 'font
+                     ;; uses dynamic scope of size
+                     #'(lambda (f d)
+                         ;; keep the dependency on font.el for now
+                         (let ((fo (font-create-object (font-instance-name f)
+                                                       d)))
+                           (set-font-size fo size)
+                           (font-create-name fo d)))
+                     nil locale tags))
+
 ;; Why do the following two functions lose so badly in so many
 ;; circumstances?
 
@@ -1477,6 +1544,8 @@ and 'global)."
     ;; Then do any device-specific initialization.
     (cond ((eq 'x (device-type device))
           (x-init-device-faces device))
+         ((eq 'gtk (device-type device))
+          (gtk-init-device-faces device))
          ((eq 'mswindows (device-type device))
           (mswindows-init-device-faces device))
          ;; Nothing to do for TTYs?
@@ -1492,6 +1561,8 @@ and 'global)."
     ;; Then do any frame-specific initialization.
     (cond ((eq 'x (frame-type frame))
           (x-init-frame-faces frame))
+         ((eq 'gtk (frame-type frame))
+          (gtk-init-frame-faces frame))
          ((eq 'mswindows (frame-type frame))
           (mswindows-init-frame-faces frame))
          ;; Is there anything which should be done for TTY's?
@@ -1508,7 +1579,9 @@ and 'global)."
   (loop for face in (face-list) do
        (init-face-from-resources face 'global))
   ;; Further X frobbing.
-  (x-init-global-faces)
+  (and (featurep 'x) (x-init-global-faces))
+  (and (featurep 'gtk) (gtk-init-global-faces))
+
   ;; for bold and the like, make the global specification be bold etc.
   ;; if the user didn't already specify a value.  These will also be
   ;; frobbed further in init-other-random-faces.
@@ -1541,10 +1614,12 @@ and 'global)."
 (defun face-complain-about-font (face device)
   (if (symbolp face) (setq face (symbol-name face)))
 ;;  (if (not inhibit-font-complaints)
-  (display-warning
-   'font
-   (let ((default-name (face-font-name 'default device)))
-     (format "%s: couldn't deduce %s %s version of the font
+  ;; complaining for printers is generally annoying.
+  (unless (device-printer-p device)
+    (display-warning
+       'font
+      (let ((default-name (face-font-name 'default device)))
+       (format "%s: couldn't deduce %s %s version of the font
 %S.
 
 Please specify X resources to make the %s face
@@ -1554,14 +1629,14 @@ For example, you could add one of the following to $HOME/Emacs:
 Emacs.%s.attributeFont: -dt-*-medium-i-*
 or
 Emacs.%s.attributeForeground: hotpink\n"
-             invocation-name
-             (if (string-match "\\`[aeiouAEIOU]" face) "an" "a")
-             face
-             default-name
-             face
-             face
-             face
-             ))))
+               invocation-name
+               (if (string-match "\\`[aeiouAEIOU]" face) "an" "a")
+               face
+               default-name
+               face
+               face
+               face
+               )))))
 
 
 ;; #### This is quite a mess.  We should use the custom mechanism for
@@ -1703,7 +1778,7 @@ in that frame; otherwise change each frame."
 (make-face 'underline "Underlined text.")
 (or (face-differs-from-default-p 'underline)
     (set-face-underline-p 'underline t 'global '(default)))
-(make-face 'zmacs-region "Used on highlightes region between point and mark.")
+(make-face 'zmacs-region "Used on highlighted region between point and mark.")
 (make-face 'isearch "Used on region matched by isearch.")
 (make-face 'isearch-secondary "Face to use for highlighting all matches.")
 (make-face 'list-mode-item-selected
@@ -1737,6 +1812,7 @@ in that frame; otherwise change each frame."
                     'global)
 (set-face-background-pixmap 'highlight
                            '(((x default mono) . "gray1")
+                             ((gtk default mono) . "gray1")
                              ((mswindows default mono) . "gray1"))
                            'global)
 
@@ -1748,6 +1824,7 @@ in that frame; otherwise change each frame."
                     'global)
 (set-face-background-pixmap 'zmacs-region
                            '(((x default mono) . "gray3")
+                             ((gtk default mono) . "gray3")
                              ((mswindows default mono) . "gray3"))
                            'global)
 
@@ -1755,6 +1832,9 @@ in that frame; otherwise change each frame."
                     '(((x default color) . "gray68")
                       ((x default grayscale) . "gray68")
                       ((x default mono) . [default foreground])
+                      ((gtk default color) . "gray68")
+                      ((gtk default grayscale) . "gray68")
+                      ((gtk default mono) . [default foreground])
                       ((mswindows default color) . "gray68")
                       ((mswindows default grayscale) . "gray68")
                       ((mswindows default mono) . [default foreground]))
@@ -1772,6 +1852,7 @@ in that frame; otherwise change each frame."
                     'global)
 (set-face-background-pixmap 'primary-selection
                            '(((x default mono) . "gray3")
+                             ((gtk default mono) . "gray3")
                              ((mswindows default mono) . "gray3"))
                            'global)
 
@@ -1779,18 +1860,24 @@ in that frame; otherwise change each frame."
                     '(((x default color) . "paleturquoise")
                       ((x default color) . "green")
                       ((x default grayscale) . "gray53")
+                      ((gtk default color) . "paleturquoise")
+                      ((gtk default color) . "green")
+                      ((gtk default grayscale) . "gray53")
                       ((mswindows default color) . "paleturquoise")
                       ((mswindows default color) . "green")
                       ((mswindows default grayscale) . "gray53"))
                     'global)
 (set-face-background-pixmap 'secondary-selection
                            '(((x default mono) . "gray1")
+                             ((gtk default mono) . "gray1")
                              ((mswindows default mono) . "gray1"))
                            'global)
 
 (set-face-background 'isearch
                     '(((x default color) . "paleturquoise")
                       ((x default color) . "green")
+                      ((gtk default color) . "paleturquoise")
+                      ((gtk default color) . "green")
                       ((mswindows default color) . "paleturquoise")
                       ((mswindows default color) . "green"))
                     'global)