annotate lisp/x-faces.el @ 5890:8704b7957585

#'set-locale-for-language-environment, bind a local variable correctly. lisp/ChangeLog addition: 2015-04-11 Aidan Kehoe <kehoea@parhasard.net> * mule/mule-cmds.el (set-locale-for-language-environment): Bind `position' as a local variable here, as was the original intention.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 11 Apr 2015 18:34:14 +0100
parents c39052c921b5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;;; x-faces.el --- X-specific face frobnication, aka black magic.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
3 ;; Copyright (C) 1992-1994, 1997, 2006 Free Software Foundation, Inc.
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
4 ;; Copyright (C) 1995, 1996, 2002, 2004 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;; Author: Jamie Zawinski <jwz@jwz.org>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; Maintainer: XEmacs Development Team
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 ;; Keywords: extensions, internal, dumped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5267
diff changeset
12 ;; XEmacs is free software: you can redistribute it and/or modify it
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5267
diff changeset
13 ;; under the terms of the GNU General Public License as published by the
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5267
diff changeset
14 ;; Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5267
diff changeset
15 ;; option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5267
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5267
diff changeset
18 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5267
diff changeset
19 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5267
diff changeset
20 ;; for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5267
diff changeset
23 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 ;;; Synched up with: Not synched.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 ;; This file is dumped with XEmacs (when X support is compiled in).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 ;; Modified by: Chuck Thompson
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 ;; Modified by: Ben Wing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 ;; Modified by: Martin Buchholz
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 ;; This file does the magic to parse X font names, and make sure that the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 ;; default and modeline attributes of new frames are specified enough.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 ;; The resource-manager syntax for faces is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
2703
2f2d12f4f93a [xemacs-hg @ 2005-03-31 11:28:41 by aidan]
aidan
parents: 2527
diff changeset
40 ;; XEmacs.bold.attributeFont: font-name
2f2d12f4f93a [xemacs-hg @ 2005-03-31 11:28:41 by aidan]
aidan
parents: 2527
diff changeset
41 ;; XEmacs.bold.attributeForeground: fg
2f2d12f4f93a [xemacs-hg @ 2005-03-31 11:28:41 by aidan]
aidan
parents: 2527
diff changeset
42 ;; XEmacs.bold.attributeBackground: bg
2f2d12f4f93a [xemacs-hg @ 2005-03-31 11:28:41 by aidan]
aidan
parents: 2527
diff changeset
43 ;; XEmacs.bold.attributeBackgroundPixmap: file
2f2d12f4f93a [xemacs-hg @ 2005-03-31 11:28:41 by aidan]
aidan
parents: 2527
diff changeset
44 ;; XEmacs.bold.attributeUnderline: true/false
2f2d12f4f93a [xemacs-hg @ 2005-03-31 11:28:41 by aidan]
aidan
parents: 2527
diff changeset
45 ;; XEmacs.bold.attributeStrikethru: true/false
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 ;; You can specify the properties of a face on a per-frame basis. For
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 ;; example, to have the "isearch" face use a red foreground on frames
2703
2f2d12f4f93a [xemacs-hg @ 2005-03-31 11:28:41 by aidan]
aidan
parents: 2527
diff changeset
49 ;; named "XEmacs" (the default) but use a blue foreground on frames that
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 ;; you create named "debugger", you could do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
2703
2f2d12f4f93a [xemacs-hg @ 2005-03-31 11:28:41 by aidan]
aidan
parents: 2527
diff changeset
52 ;; XEmacs*XEmacs.isearch.attributeForeground: red
2f2d12f4f93a [xemacs-hg @ 2005-03-31 11:28:41 by aidan]
aidan
parents: 2527
diff changeset
53 ;; XEmacs*debugger.isearch.attributeForeground: blue
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 ;; Generally things that make faces won't set any of the face attributes if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 ;; you have already given them values via the resource database. You can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 ;; also change this stuff from your .emacs file, by using the functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 ;; set-face-foreground, set-face-font, etc. See the code in this file, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 ;; in faces.el.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
63 (globally-declare-fboundp
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
64 '(x-get-resource-and-maybe-bogosity-check
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
65 x-get-resource x-init-pointer-shape))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
66
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
67 (if (featurep 'xft-fonts)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
68 (require 'fontconfig)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
69 (globally-declare-boundp
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
70 '(fc-font-name-weight-bold fc-font-name-weight-black
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
71 fc-font-name-weight-demibold fc-font-name-weight-medium
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
72 fc-font-name-slant-oblique fc-font-name-slant-italic
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
73 fc-font-name-slant-roman))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
74 (globally-declare-fboundp
3918
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
75 '(fc-font-match fc-pattern-del-size fc-pattern-get-size
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
76 fc-pattern-add-size fc-pattern-del-style fc-pattern-duplicate
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
77 fc-copy-pattern-partial fc-pattern-add-weight fc-pattern-del-weight
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
78 fc-try-font fc-pattern-del-slant fc-pattern-add-slant fc-name-parse
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
79 fc-name-unparse fc-pattern-get-pixelsize)))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
80
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 (defconst x-font-regexp nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 (defconst x-font-regexp-head nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 (defconst x-font-regexp-head-2 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 (defconst x-font-regexp-weight nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 (defconst x-font-regexp-slant nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 (defconst x-font-regexp-pixel nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 (defconst x-font-regexp-point nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 (defconst x-font-regexp-foundry-and-family nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 (defconst x-font-regexp-registry-and-encoding nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 (defconst x-font-regexp-spacing nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 ;;; Regexps matching font names in "Host Portable Character Representation."
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
93 ;;; #### But more recently Latin-1 is permitted, and Xft needs it in C (?).
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 (let ((- "[-?]")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 (foundry "[^-]*")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 (family "[^-]*")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 (weight "\\(bold\\|demibold\\|medium\\|black\\)") ; 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 ; (weight\? "\\(\\*\\|bold\\|demibold\\|medium\\|\\)") ; 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 (weight\? "\\([^-]*\\)") ; 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 (slant "\\([ior]\\)") ; 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 ; (slant\? "\\([ior?*]?\\)") ; 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 (slant\? "\\([^-]?\\)") ; 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 ; (swidth "\\(\\*\\|normal\\|semicondensed\\|\\)") ; 3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 (swidth "\\([^-]*\\)") ; 3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 ; (adstyle "\\(\\*\\|sans\\|\\)") ; 4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 (adstyle "\\([^-]*\\)") ; 4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 (pixelsize "\\(\\*\\|[0-9]+\\)") ; 5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 (pointsize "\\(\\*\\|0\\|[0-9][0-9]+\\)") ; 6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 ; (resx "\\(\\*\\|[0-9][0-9]+\\)") ; 7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 ; (resy "\\(\\*\\|[0-9][0-9]+\\)") ; 8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 (resx "\\([*0]\\|[0-9][0-9]+\\)") ; 7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 (resy "\\([*0]\\|[0-9][0-9]+\\)") ; 8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 (spacing "[cmp?*]")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 (avgwidth "\\(\\*\\|[0-9]+\\)") ; 9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 (registry "[^-]*") ; some fonts have omitted registries
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 ; (encoding ".+") ; note that encoding may contain "-"...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 (encoding "[^-]+") ; false!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 (setq x-font-regexp
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
121 (concat "\\`\\*?[-?*]"
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
122 foundry - family - weight\? - slant\? - swidth - adstyle -
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
123 pixelsize - pointsize - resx - resy - spacing - avgwidth -
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
124 registry - encoding "\\'"
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
125 ))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 (setq x-font-regexp-head
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
127 (concat "\\`[-?*]" foundry - family - weight\? - slant\?
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
128 "\\([-*?]\\|\\'\\)"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 (setq x-font-regexp-head-2
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
130 (concat "\\`[-?*]" foundry - family - weight\? - slant\?
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
131 - swidth - adstyle - pixelsize - pointsize
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
132 "\\([-*?]\\|\\'\\)"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
133 (setq x-font-regexp-slant (concat - slant -))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
134 (setq x-font-regexp-weight (concat - weight -))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 ;; if we can't match any of the more specific regexps (unfortunate) then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 ;; look for digits; assume 2+ digits is 10ths of points, and 1-2 digits
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 ;; is pixels. Bogus as hell.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
138 (setq x-font-regexp-pixel "[-?*]\\([0-9][0-9]?\\)[-?*]")
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
139 (setq x-font-regexp-point "[-?*]\\([0-9][0-9]+\\)[-?*]")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 ;; the following two are used by x-font-menu.el.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 (setq x-font-regexp-foundry-and-family
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
142 (concat "\\`[-?*]" foundry - "\\(" family "\\)" -))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 (setq x-font-regexp-registry-and-encoding
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
144 (concat - "\\(" registry "\\)" - "\\(" encoding "\\)\\'"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 (setq x-font-regexp-spacing
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
146 (concat - "\\(" spacing "\\)" - avgwidth
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
147 - registry - encoding "\\'"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
150 (defun x-font-xlfd-font-name-p (font)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
151 "Check if FONT is an XLFD font name"
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
152 (and (stringp font)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
153 (string-match x-font-regexp font)))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
154
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 ;; A "loser font" is something like "8x13" -> "8x13bold".
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 ;; These are supported only through extreme generosity.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
157 (defconst x-loser-font-regexp "\\`[0-9]+x[0-9]+\\'")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 (defun x-frob-font-weight (font which)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 (if (font-instance-p font) (setq font (font-instance-name font)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 (cond ((null font) nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 ((or (string-match x-font-regexp font)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 (string-match x-font-regexp-head font)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 (string-match x-font-regexp-weight font))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 (concat (substring font 0 (match-beginning 1)) which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 (substring font (match-end 1))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 ((string-match x-loser-font-regexp font)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 (concat font which))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 (t nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 (defun x-frob-font-slant (font which)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 (if (font-instance-p font) (setq font (font-instance-name font)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 (cond ((null font) nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 ((or (string-match x-font-regexp font)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 (string-match x-font-regexp-head font))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 (concat (substring font 0 (match-beginning 2)) which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 (substring font (match-end 2))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 ((string-match x-font-regexp-slant font)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 (concat (substring font 0 (match-beginning 1)) which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 (substring font (match-end 1))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 ((string-match x-loser-font-regexp font)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 (concat font which))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 (t nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 (defun x-make-font-bold (font &optional device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 "Given an X font specification, this attempts to make a `bold' font.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 If it fails, it returns nil."
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
188 (if (featurep 'xft-fonts)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
189 (if (x-font-xlfd-font-name-p font)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
190 (x-make-font-bold-core font device)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
191 (x-make-font-bold-xft font device))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
192 (x-make-font-bold-core font device)))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
193
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
194 (defun x-make-font-bold-xft (font &optional device)
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
195 (let ((pattern (fc-font-match (or device (default-x-device))
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
196 (fc-name-parse font))))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
197 (if pattern
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
198 (let ((size (fc-pattern-get-size pattern 0))
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
199 (copy (fc-copy-pattern-partial pattern (list "family"))))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
200 (fc-pattern-del-weight copy)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
201 (fc-pattern-del-style copy)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
202 (when copy
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
203 (or
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
204 ;; try bold font
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
205 (let ((copy-2 (fc-pattern-duplicate copy)))
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
206 (fc-pattern-add-weight copy-2 fc-font-name-weight-bold)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
207 (when (fc-try-font copy-2 device)
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
208 (fc-pattern-add-size copy-2 size)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
209 (fc-name-unparse copy-2)))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
210 ;; try black font
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
211 (let ((copy-2 (fc-pattern-duplicate copy)))
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
212 (fc-pattern-add-weight copy-2 fc-font-name-weight-black)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
213 (when (fc-try-font copy-2 device)
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
214 (fc-pattern-add-size copy-2 size)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
215 (fc-name-unparse copy-2)))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
216 ;; try demibold font
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
217 (let ((copy-2 (fc-pattern-duplicate copy)))
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
218 (fc-pattern-add-weight copy-2 fc-font-name-weight-demibold)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
219 (when (fc-try-font copy-2 device)
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
220 (fc-pattern-add-size copy-2 size)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
221 (fc-name-unparse copy-2)))))))))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
222
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
223 (defun x-make-font-bold-core (font &optional device)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 ;; Certain Type1 fonts know "bold" as "black"...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 (or (try-font-name (x-frob-font-weight font "bold") device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 (try-font-name (x-frob-font-weight font "black") device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 (try-font-name (x-frob-font-weight font "demibold") device)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 (defun x-make-font-unbold (font &optional device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 "Given an X font specification, this attempts to make a non-bold font.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 If it fails, it returns nil."
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
232 (if (featurep 'xft-fonts)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
233 (if (x-font-xlfd-font-name-p font)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
234 (x-make-font-unbold-core font device)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
235 (x-make-font-unbold-xft font device))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
236 (x-make-font-unbold-core font device)))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
237
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
238 (defun x-make-font-unbold-xft (font &optional device)
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
239 (let ((pattern (fc-font-match (or device (default-x-device))
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
240 (fc-name-parse font))))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
241 (when pattern
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
242 (fc-pattern-del-weight pattern)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
243 (fc-pattern-add-weight pattern fc-font-name-weight-medium)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
244 (if (fc-try-font pattern device)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
245 (fc-name-unparse pattern)))))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
246
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
247 (defun x-make-font-unbold-core (font &optional device)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 (try-font-name (x-frob-font-weight font "medium") device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 (defcustom try-oblique-before-italic-fonts nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 "*If nil, italic fonts are searched before oblique fonts.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 If non-nil, oblique fonts are tried before italic fonts. This is mostly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 applicable to adobe-courier fonts"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 :group 'x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 (define-obsolete-variable-alias '*try-oblique-before-italic-fonts*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 'try-oblique-before-italic-fonts)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 (defun x-make-font-italic (font &optional device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 "Given an X font specification, this attempts to make an `italic' font.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 If it fails, it returns nil."
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
262 (if (featurep 'xft-fonts)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
263 (if (x-font-xlfd-font-name-p font)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
264 (x-make-font-italic-core font device)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
265 (x-make-font-italic-xft font device))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
266 (x-make-font-italic-core font device)))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
267
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
268 (defun x-make-font-italic-xft (font &optional device)
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
269 (let ((pattern (fc-font-match (or device (default-x-device))
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
270 (fc-name-parse font))))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
271 (if pattern
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
272 (let ((size (fc-pattern-get-size pattern 0))
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
273 (copy (fc-copy-pattern-partial pattern (list "family"))))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
274 (when copy
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
275 (fc-pattern-del-slant copy)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
276 (fc-pattern-del-style copy)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
277 ;; #### can't we do this with one ambiguous pattern?
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
278 (let ((pattern-oblique (fc-pattern-duplicate copy))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
279 (pattern-italic (fc-pattern-duplicate copy)))
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
280 (fc-pattern-add-slant pattern-oblique fc-font-name-slant-oblique)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
281 (fc-pattern-add-slant pattern-italic fc-font-name-slant-italic)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
282 (let ((have-oblique (fc-try-font pattern-oblique device))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
283 (have-italic (fc-try-font pattern-italic device)))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
284 (if try-oblique-before-italic-fonts
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
285 (if have-oblique
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
286 (progn
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
287 (if size
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
288 (fc-pattern-add-size pattern-oblique size))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
289 (fc-name-unparse pattern-oblique))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
290 (if have-italic
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
291 (progn
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
292 (if size
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
293 (fc-pattern-add-size pattern-italic size))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
294 (fc-name-unparse pattern-italic))))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
295 (if have-italic
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
296 (progn
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
297 (if size
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
298 (fc-pattern-add-size pattern-italic size))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
299 (fc-name-unparse pattern-italic))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
300 (if have-oblique
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
301 (progn
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
302 (if size
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
303 (fc-pattern-add-size pattern-oblique size))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
304 (fc-name-unparse pattern-oblique))))))))))))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
305
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
306 (defun x-make-font-italic-core (font &optional device)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 (if try-oblique-before-italic-fonts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 (or (try-font-name (x-frob-font-slant font "o") device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 (try-font-name (x-frob-font-slant font "i") device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 (or (try-font-name (x-frob-font-slant font "i") device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 (try-font-name (x-frob-font-slant font "o") device))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 (defun x-make-font-unitalic (font &optional device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 "Given an X font specification, this attempts to make a non-italic font.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 If it fails, it returns nil."
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
316 (if (featurep 'xft-fonts)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
317 (if (x-font-xlfd-font-name-p font)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
318 (x-make-font-unitalic-core font device)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
319 (x-make-font-unitalic-xft font device))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
320 (x-make-font-unitalic-core font device)))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
321
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
322 (defun x-make-font-unitalic-xft (font &optional device)
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
323 (let ((pattern (fc-font-match (or device (default-x-device))
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
324 (fc-name-parse font))))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
325 (when pattern
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
326 (fc-pattern-del-slant pattern)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
327 (fc-pattern-add-slant pattern fc-font-name-slant-roman)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
328 (if (fc-try-font pattern device)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
329 (fc-name-unparse pattern)))))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
330
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
331 (defun x-make-font-unitalic-core (font &optional device)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 (try-font-name (x-frob-font-slant font "r") device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 (defun x-make-font-bold-italic (font &optional device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 "Given an X font specification, this attempts to make a `bold-italic' font.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 If it fails, it returns nil."
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
337 (if (featurep 'xft-fonts)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
338 (if (x-font-xlfd-font-name-p font)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
339 (x-make-font-bold-italic-core font device)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
340 (x-make-font-bold-italic-xft font device))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
341 (x-make-font-bold-italic-core font device)))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
342
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
343 (defun x-make-font-bold-italic-xft (font &optional device)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
344 (let ((italic (x-make-font-italic-xft font device)))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
345 (if italic
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
346 (x-make-font-bold-xft italic device))))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
347
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
348 (defun x-make-font-bold-italic-core (font &optional device)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 ;; This is haired up to avoid loading the "intermediate" fonts.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
350 (if try-oblique-before-italic-fonts
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 (or (try-font-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 (x-frob-font-slant (x-frob-font-weight font "bold") "o") device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 (try-font-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 (x-frob-font-slant (x-frob-font-weight font "bold") "i") device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 (try-font-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 (x-frob-font-slant (x-frob-font-weight font "black") "o") device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 (try-font-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 (x-frob-font-slant (x-frob-font-weight font "black") "i") device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 (try-font-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 (x-frob-font-slant (x-frob-font-weight font "demibold") "o") device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 (try-font-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 (x-frob-font-slant (x-frob-font-weight font "demibold") "i") device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 (or (try-font-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 (x-frob-font-slant (x-frob-font-weight font "bold") "i") device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 (try-font-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 (x-frob-font-slant (x-frob-font-weight font "bold") "o") device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 (try-font-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 (x-frob-font-slant (x-frob-font-weight font "black") "i") device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 (try-font-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 (x-frob-font-slant (x-frob-font-weight font "black") "o") device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 (try-font-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 (x-frob-font-slant (x-frob-font-weight font "demibold") "i") device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 (try-font-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 (x-frob-font-slant (x-frob-font-weight font "demibold") "o") device))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 (defun x-font-size (font)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 "Return the nominal size of the given font.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 This is done by parsing its name, so it's likely to lose.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 X fonts can be specified (by the user) in either pixels or 10ths of points,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 and this returns the first one it finds, so you have to decide which units
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 the returned value is measured in yourself..."
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
382 (if (featurep 'xft-fonts)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
383 (if (x-font-xlfd-font-name-p font)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
384 (x-font-size-core font)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
385 (x-font-size-xft font))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
386 (x-font-size-core font)))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
387
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
388 ;; this is unbelievable &*@#
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
389 (defun x-font-size-xft (font)
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
390 (let ((pattern (fc-font-match (default-x-device)
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
391 (fc-name-parse font))))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
392 (when pattern
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
393 (let ((pixelsize (fc-pattern-get-pixelsize pattern 0)))
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
394 (if (floatp pixelsize) (round pixelsize) pixelsize)))))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
395
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
396 (defun x-font-size-core (font)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 (if (font-instance-p font) (setq font (font-instance-name font)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 (cond ((or (string-match x-font-regexp font)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 (string-match x-font-regexp-head-2 font))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 (string-to-int (substring font (match-beginning 6) (match-end 6))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 ((or (string-match x-font-regexp-pixel font)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 (string-match x-font-regexp-point font))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 (string-to-int (substring font (match-beginning 1) (match-end 1))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 (t nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 ;; Given a font name, this function returns a list describing all fonts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 ;; of all sizes that otherwise match the given font spec. Each element
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 ;; in the list is a list of three items: the pixel size of the font,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 ;; the point size (in 1/10ths of a point) of the font, and the fully-
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 ;; qualified font name. The first two values may be zero; this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 ;; refers to a scalable font.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 (defun x-available-font-sizes (font device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 (if (font-instance-p font) (setq font (font-instance-name font)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 (cond ((string-match x-font-regexp font)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 ;; turn pixelsize, pointsize, and avgwidth into wildcards
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 (setq font
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 (concat (substring font 0 (match-beginning 5)) "*"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 (substring font (match-end 5) (match-beginning 6)) "*"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 (substring font (match-end 6) (match-beginning 9)) "*"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 (substring font (match-end 9) (match-end 0)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 ((string-match x-font-regexp-head-2 font)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 ;; turn pixelsize and pointsize into wildcards
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 (setq font
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 (concat (substring font 0 (match-beginning 5)) "*"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 (substring font (match-end 5) (match-beginning 6)) "*"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 (substring font (match-end 6) (match-end 0)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 ((string-match "[-?*]\\([0-9]+\\)[-?*]" font)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 ;; Turn the first integer we match into a wildcard.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 ;; This is pretty dubious...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 (setq font
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 (concat (substring font 0 (match-beginning 1)) "*"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 (substring font (match-end 1) (match-end 0))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 (sort
5267
668c73e222fd Change forms like (delq nil (mapcar ...)) to (mapcan ...).
Aidan Kehoe <kehoea@parhasard.net>
parents: 5176
diff changeset
435 (mapcan (function
668c73e222fd Change forms like (delq nil (mapcar ...)) to (mapcan ...).
Aidan Kehoe <kehoea@parhasard.net>
parents: 5176
diff changeset
436 (lambda (name)
668c73e222fd Change forms like (delq nil (mapcar ...)) to (mapcan ...).
Aidan Kehoe <kehoea@parhasard.net>
parents: 5176
diff changeset
437 (and (string-match x-font-regexp name)
668c73e222fd Change forms like (delq nil (mapcar ...)) to (mapcan ...).
Aidan Kehoe <kehoea@parhasard.net>
parents: 5176
diff changeset
438 (list
668c73e222fd Change forms like (delq nil (mapcar ...)) to (mapcan ...).
Aidan Kehoe <kehoea@parhasard.net>
parents: 5176
diff changeset
439 (list
668c73e222fd Change forms like (delq nil (mapcar ...)) to (mapcan ...).
Aidan Kehoe <kehoea@parhasard.net>
parents: 5176
diff changeset
440 (string-to-int (substring name (match-beginning 5)
668c73e222fd Change forms like (delq nil (mapcar ...)) to (mapcan ...).
Aidan Kehoe <kehoea@parhasard.net>
parents: 5176
diff changeset
441 (match-end 5)))
668c73e222fd Change forms like (delq nil (mapcar ...)) to (mapcan ...).
Aidan Kehoe <kehoea@parhasard.net>
parents: 5176
diff changeset
442 (string-to-int (substring name (match-beginning 6)
668c73e222fd Change forms like (delq nil (mapcar ...)) to (mapcan ...).
Aidan Kehoe <kehoea@parhasard.net>
parents: 5176
diff changeset
443 (match-end 6)))
668c73e222fd Change forms like (delq nil (mapcar ...)) to (mapcan ...).
Aidan Kehoe <kehoea@parhasard.net>
parents: 5176
diff changeset
444 name)))))
668c73e222fd Change forms like (delq nil (mapcar ...)) to (mapcan ...).
Aidan Kehoe <kehoea@parhasard.net>
parents: 5176
diff changeset
445 (font-list font device))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 (function (lambda (x y) (if (= (nth 1 x) (nth 1 y))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 (< (nth 0 x) (nth 0 y))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 (< (nth 1 x) (nth 1 y)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 ;; Given a font name, this attempts to construct a valid font name for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 ;; DEVICE whose size is the next smaller (if UP-P is nil) or larger
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 ;; (if UP-P is t) size and whose other characteristics are the same
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 ;; as the given font.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 (defun x-frob-font-size (font up-p device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 (if (stringp font) (setq font (make-font-instance font device)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 (if (font-instance-p font) (setq font (font-instance-truename font)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 (let ((available (and font
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 (x-available-font-sizes font device))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 (cond
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 ((null available) nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 ((or (= 0 (nth 0 (car available)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 (= 0 (nth 1 (car available))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 ;; R5 scalable fonts: change size by 1 point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 ;; If they're scalable the first font will have pixel or point = 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 ;; Sometimes one is 0 and the other isn't (if it's a bitmap font that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 ;; can be scaled), sometimes both are (if it's a true outline font).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 (let ((name (nth 2 (car available)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 old-size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 (or (string-match x-font-regexp font) (error "can't parse %S" font))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 (setq old-size (string-to-int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 (substring font (match-beginning 6) (match-end 6))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 (or (> old-size 0) (error "font truename has 0 pointsize?"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 (or (string-match x-font-regexp name) (error "can't parse %S" name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 ;; turn pixelsize into a wildcard, and make pointsize be +/- 10,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 ;; which is +/- 1 point. All other fields stay the same as they
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 ;; were in the "template" font returned by x-available-font-sizes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 ;; #### But this might return the same font: for example, if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 ;; truename of "-*-courier-medium-r-normal--*-230-75-75-m-0-*"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 ;; is "...-240-..." (instead of 230) then this loses, because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 ;; the 230 that was passed in as an arg got turned into 240
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 ;; by the call to font-instance-truename; then we decrement that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 ;; by 10 and return the result which is the same. I think the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 ;; way to fix this is to make this be a loop that keeps trying
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 ;; progressively larger pointsize deltas until it finds one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 ;; whose truename differs. Have to be careful to avoid infinite
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 ;; loops at the upper end...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 (concat (substring name 0 (match-beginning 5)) "*"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 (substring name (match-end 5) (match-beginning 6))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 (int-to-string (+ old-size (if up-p 10 -10)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 (substring name (match-end 6) (match-end 0)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 ;; non-scalable fonts: take the next available size.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 (let ((rest available)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 (last nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 (while rest
801
2b676dc88c66 [xemacs-hg @ 2002-04-01 03:58:02 by ben]
ben
parents: 502
diff changeset
500 (cond ((and (not up-p) (equalp font (nth 2 (car rest))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 (setq result last
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 rest nil))
801
2b676dc88c66 [xemacs-hg @ 2002-04-01 03:58:02 by ben]
ben
parents: 502
diff changeset
503 ((and up-p (equalp font (and last (nth 2 last))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 (setq result (car rest)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 rest nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 (setq last (car rest))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 (setq rest (cdr rest)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 (nth 2 result))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 (defun x-find-smaller-font (font &optional device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 "Load a new, slightly smaller version of the given font (or font name).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 Returns the font if it succeeds, nil otherwise.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 If scalable fonts are available, this returns a font which is 1 point smaller.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 Otherwise, it returns the next smaller version of this font that is defined."
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
515 (if (featurep 'xft-fonts)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
516 (if (x-font-xlfd-font-name-p font)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
517 (x-find-smaller-font-core font device)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
518 (x-find-smaller-font-xft font device))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
519 (x-find-smaller-font-core font device)))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
520
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
521 (defun x-find-xft-font-of-size (font new-size-proc &optional device)
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
522 (let* ((pattern (fc-font-match (or device (default-x-device))
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
523 (fc-name-parse font))))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
524 (when pattern
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
525 (let ((size (fc-pattern-get-size pattern 0)))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
526 (if (floatp size)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
527 (let ((copy (fc-pattern-duplicate pattern)))
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
528 (fc-pattern-del-size copy)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3125
diff changeset
529 (fc-pattern-add-size copy (funcall new-size-proc size))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
530 (if (fc-try-font font device)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
531 (fc-name-unparse copy))))))))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
532
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
533 (defun x-find-smaller-font-xft (font &optional device)
4021
cef5f57bb9e2 [xemacs-hg @ 2007-06-21 13:39:08 by aidan]
aidan
parents: 3918
diff changeset
534 (x-find-xft-font-of-size font #'(lambda (old-size) (- old-size 1.0)) device))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
535
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
536 (defun x-find-smaller-font-core (font &optional device)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 (x-frob-font-size font nil device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 (defun x-find-larger-font (font &optional device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 "Load a new, slightly larger version of the given font (or font name).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 Returns the font if it succeeds, nil otherwise.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 If scalable fonts are available, this returns a font which is 1 point larger.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 Otherwise, it returns the next larger version of this font that is defined."
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
544 (if (featurep 'xft-fonts)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
545 (if (x-font-xlfd-font-name-p font)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
546 (x-find-larger-font-core font device)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
547 (x-find-larger-font-xft font device))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
548 (x-find-larger-font-core font device)))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
549
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
550 (defun x-find-larger-font-xft (font &optional device)
4021
cef5f57bb9e2 [xemacs-hg @ 2007-06-21 13:39:08 by aidan]
aidan
parents: 3918
diff changeset
551 (x-find-xft-font-of-size font #'(lambda (old-size) (+ old-size 1.0)) device))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
552
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2703
diff changeset
553 (defun x-find-larger-font-core (font &optional device)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 (x-frob-font-size font t device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 (defalias 'x-make-face-bold 'make-face-bold)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 (defalias 'x-make-face-italic 'make-face-italic)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 (defalias 'x-make-face-bold-italic 'make-face-bold-italic)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 (defalias 'x-make-face-unbold 'make-face-unbold)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 (defalias 'x-make-face-unitalic 'make-face-unitalic)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 (make-obsolete 'x-make-face-bold 'make-face-bold)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 (make-obsolete 'x-make-face-italic 'make-face-italic)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 (make-obsolete 'x-make-face-bold-italic 'make-face-bold-italic)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 (make-obsolete 'x-make-face-unbold 'make-face-unbold)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 (make-obsolete 'x-make-face-unitalic 'make-face-unitalic)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
569
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
570 ;; #### - wrong place for this variable? Exactly. We probably want
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
571 ;; `color-list' to be a console method, so `tty-color-list' becomes
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
572 ;; obsolete, and `read-color-completion-table' conses (mapcar #'list
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
573 ;; (color-list)), optionally caching the results.
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
574
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
575 ;; Ben wanted all of the possibilities from the `configure' script used
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
576 ;; here, but I think this is way too many. I already trimmed the R4 variants
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
577 ;; and a few obvious losers from the list. --Stig
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
578 (defvar x-library-search-path '("/usr/X11R6/lib/X11/"
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
579 "/usr/X11R5/lib/X11/"
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
580 "/usr/lib/X11R6/X11/"
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
581 "/usr/lib/X11R5/X11/"
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
582 "/usr/local/X11R6/lib/X11/"
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
583 "/usr/local/X11R5/lib/X11/"
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
584 "/usr/local/lib/X11R6/X11/"
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
585 "/usr/local/lib/X11R5/X11/"
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
586 "/usr/X11/lib/X11/"
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
587 "/usr/lib/X11/"
3125
d97bc868eaaf [xemacs-hg @ 2005-12-05 09:43:36 by scop]
scop
parents: 3094
diff changeset
588 "/usr/share/X11/"
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
589 "/usr/local/lib/X11/"
3125
d97bc868eaaf [xemacs-hg @ 2005-12-05 09:43:36 by scop]
scop
parents: 3094
diff changeset
590 "/usr/local/share/X11/"
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
591 "/usr/X386/lib/X11/"
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
592 "/usr/x386/lib/X11/"
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
593 "/usr/XFree86/lib/X11/"
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
594 "/usr/unsupported/lib/X11/"
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
595 "/usr/athena/lib/X11/"
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
596 "/usr/local/x11r5/lib/X11/"
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
597 "/usr/lpp/Xamples/lib/X11/"
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
598 "/usr/openwin/lib/X11/"
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
599 "/usr/openwin/share/lib/X11/")
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
600 "Search path used by `x-color-list-internal' to find rgb.txt.")
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
601
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
602 (defvar x-color-list-internal-cache)
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
603
4215
de99c4dbad18 [xemacs-hg @ 2007-10-07 06:54:59 by stephent]
stephent
parents: 4194
diff changeset
604 ;; Ben originally coded this in 2005/01 to return a list of lists each
de99c4dbad18 [xemacs-hg @ 2007-10-07 06:54:59 by stephent]
stephent
parents: 4194
diff changeset
605 ;; containing a single string. This is apparently derived from use of
de99c4dbad18 [xemacs-hg @ 2007-10-07 06:54:59 by stephent]
stephent
parents: 4194
diff changeset
606 ;; this list in completion, but in fact `read-color-completion-table'
de99c4dbad18 [xemacs-hg @ 2007-10-07 06:54:59 by stephent]
stephent
parents: 4194
diff changeset
607 ;; already does this wrapping. So I'm changing this to return a list of
de99c4dbad18 [xemacs-hg @ 2007-10-07 06:54:59 by stephent]
stephent
parents: 4194
diff changeset
608 ;; strings as the TTY code does, and as expected by r-c-c-t.
de99c4dbad18 [xemacs-hg @ 2007-10-07 06:54:59 by stephent]
stephent
parents: 4194
diff changeset
609 ;; -- sjt 2007-10-06
de99c4dbad18 [xemacs-hg @ 2007-10-07 06:54:59 by stephent]
stephent
parents: 4194
diff changeset
610
de99c4dbad18 [xemacs-hg @ 2007-10-07 06:54:59 by stephent]
stephent
parents: 4194
diff changeset
611 ;; This function is probably also used by the GTK platform. Cf.
5176
8b2f75cecb89 rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents: 4822
diff changeset
612 ;; gtk_color_list in src/fontcolor-gtk.c.
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
613 (defun x-color-list-internal ()
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
614 (if (boundp 'x-color-list-internal-cache)
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
615 x-color-list-internal-cache
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
616 (let ((rgb-file (locate-file "rgb.txt" x-library-search-path))
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
617 clist color p)
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
618 (if (not rgb-file)
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
619 ;; prevents multiple searches for rgb.txt if we can't find it
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
620 (setq x-color-list-internal-cache nil)
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
621 (with-current-buffer (get-buffer-create " *colors*")
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
622 (reset-buffer (current-buffer))
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
623 (insert-file-contents rgb-file)
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
624 (while (not (eobp))
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
625 ;; skip over comments
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
626 (while (looking-at "^!")
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
627 (end-of-line)
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
628 (forward-char 1))
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
629 (skip-chars-forward "0-9 \t")
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
630 (setq p (point))
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
631 (end-of-line)
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
632 (setq color (buffer-substring p (point))
4215
de99c4dbad18 [xemacs-hg @ 2007-10-07 06:54:59 by stephent]
stephent
parents: 4194
diff changeset
633 clist (cons color clist))
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
634 ;; Ugh. If we want to be able to complete the lowercase form
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
635 ;; of the color name, we need to add it twice! Yuck.
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
636 (let ((dcase (downcase color)))
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
637 (or (string= dcase color)
4215
de99c4dbad18 [xemacs-hg @ 2007-10-07 06:54:59 by stephent]
stephent
parents: 4194
diff changeset
638 (push dcase clist)))
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
639 (forward-char 1))
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
640 (kill-buffer (current-buffer))))
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
641 (setq x-color-list-internal-cache clist)
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
642 x-color-list-internal-cache)))
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
643
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 872
diff changeset
644
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 ;;; internal routines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
647 ;;; x-init-face-from-resources is responsible for initializing a newly-created
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
648 ;;; face from the resource database.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 ;;;
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
650 ;;; When a new frame is created, it is called from `x-init-frame-faces' called
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
651 ;;; from `init-frame-faces' called from init_frame_faces() from Fmake_frame().
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
652 ;;; In this case it is called once for each existing face, with the
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
653 ;;; newly-created frame as the argument. It then initializes the newly-created
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
654 ;;; faces on that frame.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 ;;;
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
656 ;;; It's also called from `init-device-faces' and `init-global-faces'.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 ;;;
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
658 ;;; This had better not signal an error. The frame is in an intermediate state
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
659 ;;; where signalling an error or entering the debugger would likely result in
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
660 ;;; a crash.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
662 ;; When we initialise a face from an X resource, note that we did so. Now in
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
663 ;; specifier.el so run-time checks for it on non-X builds don't error.
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
664 ;; (define-specifier-tag 'x-resource)
3918
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
665
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 (defun x-init-face-from-resources (face &optional locale set-anyway)
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
667 ;; These are things like "attributeForeground" instead of simply
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
668 ;; "foreground" because people tend to do things like "*foreground", which
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
669 ;; would cause all faces to be fully qualified, making faces inherit
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
670 ;; attributes in a non-useful way. So we've made them slightly less obvious
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
671 ;; to specify in order to make them work correctly in more random
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
672 ;; environments.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 ;; I think these should be called "face.faceForeground" instead of
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
675 ;; "face.attributeForeground", but they're the way they are for hysterical
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
676 ;; reasons. (jwz)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 (let* ((append (if set-anyway nil 'append))
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
678 ;; Some faces are initialized before XEmacs is dumped. In order for
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
679 ;; the X resources to be able to override those settings, such
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
680 ;; initialization always uses the `default' tag. We remove all
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
681 ;; specifier specs containing the `default' tag in the locale before
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 ;; adding new specs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 (tag-set '(default))
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
684 ;; The tag order matters here. The spec removal function uses the
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
685 ;; list cdrs. We want to remove (x default) and (default) specs, not
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
686 ;; (default x) and (x) specs.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 (x-tag-set '(x default))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 (tty-tag-set '(tty default))
3918
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
689 (our-tag-set '(x x-resource))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 (device-class nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 (face-sym (face-name face))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 (name (symbol-name face-sym))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 (fn (x-get-resource-and-maybe-bogosity-check
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 (concat name ".attributeFont")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 "Face.AttributeFont"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 'string locale))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 (fg (x-get-resource-and-maybe-bogosity-check
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 (concat name ".attributeForeground")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 "Face.AttributeForeground"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 'string locale))
5624
c39052c921b5 New "foreback" face property.
Didier Verna <didier@xemacs.org>
parents: 5619
diff changeset
701 (fb (x-get-resource-and-maybe-bogosity-check
c39052c921b5 New "foreback" face property.
Didier Verna <didier@xemacs.org>
parents: 5619
diff changeset
702 (concat name ".attributeForeback")
c39052c921b5 New "foreback" face property.
Didier Verna <didier@xemacs.org>
parents: 5619
diff changeset
703 "Face.AttributeForeback"
c39052c921b5 New "foreback" face property.
Didier Verna <didier@xemacs.org>
parents: 5619
diff changeset
704 'string locale))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 (bg (x-get-resource-and-maybe-bogosity-check
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 (concat name ".attributeBackground")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 "Face.AttributeBackground"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 'string locale))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 (bgp (x-get-resource-and-maybe-bogosity-check
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 (concat name ".attributeBackgroundPixmap")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 "Face.AttributeBackgroundPixmap"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 'string locale))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 (ulp (x-get-resource-and-maybe-bogosity-check
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 (concat name ".attributeUnderline")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 "Face.AttributeUnderline"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 'boolean locale))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 (stp (x-get-resource-and-maybe-bogosity-check
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 (concat name ".attributeStrikethru")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 "Face.AttributeStrikethru"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 'boolean locale))
5617
b0d712bbc2a6 The "flush" face property.
Didier Verna <didier@xemacs.org>
parents: 5402
diff changeset
721 (fp (x-get-resource-and-maybe-bogosity-check
5619
75ad4969a16d Replace the 'flush face property with the opposite 'shrink one.
Didier Verna <didier@xemacs.org>
parents: 5617
diff changeset
722 (concat name ".attributeShrink")
75ad4969a16d Replace the 'flush face property with the opposite 'shrink one.
Didier Verna <didier@xemacs.org>
parents: 5617
diff changeset
723 "Face.AttributeShrink"
5617
b0d712bbc2a6 The "flush" face property.
Didier Verna <didier@xemacs.org>
parents: 5402
diff changeset
724 'boolean locale))
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
725 ;; we still resource for these TTY-only resources so that you can
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
726 ;; specify resources for TTY frames/devices. This is useful when you
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
727 ;; start up your XEmacs on an X display and later open some TTY
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
728 ;; frames.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 (hp (x-get-resource-and-maybe-bogosity-check
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 (concat name ".attributeHighlight")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 "Face.AttributeHighlight"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 'boolean locale))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 (dp (x-get-resource-and-maybe-bogosity-check
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 (concat name ".attributeDim")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 "Face.AttributeDim"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 'boolean locale))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 (bp (x-get-resource-and-maybe-bogosity-check
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 (concat name ".attributeBlinking")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 "Face.AttributeBlinking"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 'boolean locale))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 (rp (x-get-resource-and-maybe-bogosity-check
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 (concat name ".attributeReverse")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 "Face.AttributeReverse"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 'boolean locale))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 (cond ((framep locale)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 (setq device-class (device-class (frame-device locale))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 ((devicep locale)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 (setq device-class (device-class locale))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 (if device-class
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 (setq tag-set (cons device-class tag-set)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 x-tag-set (cons device-class x-tag-set)
3918
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
755 tty-tag-set (cons device-class tty-tag-set)
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
756 our-tag-set (cons device-class our-tag-set)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
758 ;; For the default and gui-element faces, some unspecified properties
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
759 ;; should be defaulted from the global properties. Can't do this for
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 ;; frames or devices because then, common resource specs like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 ;; "*Foreground: black" will have unwanted effects.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 (if (and (or (eq (face-name face) 'default)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 (eq (face-name face) 'gui-element))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 (or (null locale) (eq locale 'global)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 (or fn (setq fn (x-get-resource
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
767 "font" "Font" 'string locale nil 'warn)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 (or fg (setq fg (x-get-resource
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
769 "foreground" "Foreground" 'string locale nil
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
770 'warn)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 (or bg (setq bg (x-get-resource
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
772 "background" "Background" 'string locale nil
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
773 'warn)))))
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
774
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 ;; "*cursorColor: foo" is equivalent to setting the background of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 ;; text-cursor face.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 (if (and (eq (face-name face) 'text-cursor)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 (or (null locale) (eq locale 'global)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 (setq bg (or (x-get-resource
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
780 "cursorColor" "CursorColor" 'string locale nil 'warn)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
781 bg)))
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
782 ;; #### NOTE: should issue warnings? I think this should be done when the
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
783 ;; instancing actually happens, but I'm not sure how it should actually be
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
784 ;; dealt with.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 (when fn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 (if device-class
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
787 ;; Always use the x-tag-set to remove specs, since we don't know
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
788 ;; whether the predumped face was initialized with an 'x tag or not.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 (remove-specifier-specs-matching-tag-set-cdrs (face-font face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 locale
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 x-tag-set)
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
792 ;; If there's no device class then we're initializing globally. This
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
793 ;; means we should override global defaults for all X device classes.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 (remove-specifier (face-font face) locale x-tag-set nil))
3918
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
795 (set-face-font face fn locale our-tag-set append)
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
796
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
797 ;; And retain some of the fallbacks in the generated default face, since
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
798 ;; we don't want to try andale-mono's ISO-10646-1 encoding for Amharic
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
799 ;; or Thai.
3918
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
800 (when (and (specifierp (face-font face))
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
801 (consp (specifier-fallback (face-font face))))
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
802 (loop
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
803 for (tag-set . instantiator)
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
804 in (specifier-fallback (face-font face))
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
805 if (memq 'x-coverage-instantiator tag-set)
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
806 do (add-spec-list-to-specifier
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
807 (face-font face)
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
808 (list (cons (or locale 'global)
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
809 (list (cons tag-set instantiator))))
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
810 append))))
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3360
diff changeset
811
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
812 ;; Kludge-o-rooni. Set the foreground and background resources for X
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
813 ;; devices only -- otherwise things tend to get all messed up if you start
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
814 ;; up an X frame and then later create a TTY frame.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 (when fg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 (if device-class
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 (remove-specifier-specs-matching-tag-set-cdrs (face-foreground face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 locale
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 x-tag-set)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 (remove-specifier (face-foreground face) locale x-tag-set nil))
3918
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
821 (set-face-foreground face fg locale our-tag-set append))
5624
c39052c921b5 New "foreback" face property.
Didier Verna <didier@xemacs.org>
parents: 5619
diff changeset
822 (when fb
c39052c921b5 New "foreback" face property.
Didier Verna <didier@xemacs.org>
parents: 5619
diff changeset
823 (if device-class
c39052c921b5 New "foreback" face property.
Didier Verna <didier@xemacs.org>
parents: 5619
diff changeset
824 (remove-specifier-specs-matching-tag-set-cdrs (face-foreback face)
c39052c921b5 New "foreback" face property.
Didier Verna <didier@xemacs.org>
parents: 5619
diff changeset
825 locale
c39052c921b5 New "foreback" face property.
Didier Verna <didier@xemacs.org>
parents: 5619
diff changeset
826 x-tag-set)
c39052c921b5 New "foreback" face property.
Didier Verna <didier@xemacs.org>
parents: 5619
diff changeset
827 (remove-specifier (face-foreback face) locale x-tag-set nil))
c39052c921b5 New "foreback" face property.
Didier Verna <didier@xemacs.org>
parents: 5619
diff changeset
828 (set-face-foreback face fb locale our-tag-set append))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 (when bg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 (if device-class
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 (remove-specifier-specs-matching-tag-set-cdrs (face-background face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 locale
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 x-tag-set)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 (remove-specifier (face-background face) locale x-tag-set nil))
3918
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
835 (set-face-background face bg locale our-tag-set append))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 (when bgp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 (if device-class
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 (remove-specifier-specs-matching-tag-set-cdrs (face-background-pixmap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 locale
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 x-tag-set)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 (remove-specifier (face-background-pixmap face) locale x-tag-set nil))
3918
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
843 (set-face-background-pixmap face bgp locale our-tag-set append))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 (when ulp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 (if device-class
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 (remove-specifier-specs-matching-tag-set-cdrs (face-property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 face 'underline)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 locale
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 tty-tag-set)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 (remove-specifier (face-property face 'underline) locale
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 tty-tag-set nil))
3918
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
852 (set-face-underline-p face ulp locale our-tag-set append))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 (when stp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 (if device-class
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 (remove-specifier-specs-matching-tag-set-cdrs (face-property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 face 'strikethru)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 locale
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 tty-tag-set)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 (remove-specifier (face-property face 'strikethru)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 locale tty-tag-set nil))
3918
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
861 (set-face-strikethru-p face stp locale our-tag-set append))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 (when hp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 (if device-class
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 (remove-specifier-specs-matching-tag-set-cdrs (face-property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 face 'highlight)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 locale
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 tty-tag-set)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 (remove-specifier (face-property face 'highlight)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 locale tty-tag-set nil))
3918
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
870 (set-face-highlight-p face hp locale our-tag-set append))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 (when dp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 (if device-class
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 (remove-specifier-specs-matching-tag-set-cdrs (face-property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 face 'dim)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 locale
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 tty-tag-set)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 (remove-specifier (face-property face 'dim) locale tty-tag-set nil))
3918
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
878 (set-face-dim-p face dp locale our-tag-set append))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 (when bp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 (if device-class
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 (remove-specifier-specs-matching-tag-set-cdrs (face-property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 face 'blinking)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 locale
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 tty-tag-set)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 (remove-specifier (face-property face 'blinking) locale
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 tty-tag-set nil))
3918
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
887 (set-face-blinking-p face bp locale our-tag-set append))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 (when rp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 (if device-class
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 (remove-specifier-specs-matching-tag-set-cdrs (face-property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 face 'reverse)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 locale
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 tty-tag-set)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 (remove-specifier (face-property face 'reverse) locale
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 tty-tag-set nil))
3918
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3747
diff changeset
896 (set-face-reverse-p face rp locale our-tag-set append))
5617
b0d712bbc2a6 The "flush" face property.
Didier Verna <didier@xemacs.org>
parents: 5402
diff changeset
897 (when fp
b0d712bbc2a6 The "flush" face property.
Didier Verna <didier@xemacs.org>
parents: 5402
diff changeset
898 (cond (device-class
b0d712bbc2a6 The "flush" face property.
Didier Verna <didier@xemacs.org>
parents: 5402
diff changeset
899 (remove-specifier-specs-matching-tag-set-cdrs (face-property
5619
75ad4969a16d Replace the 'flush face property with the opposite 'shrink one.
Didier Verna <didier@xemacs.org>
parents: 5617
diff changeset
900 face 'shrink)
5617
b0d712bbc2a6 The "flush" face property.
Didier Verna <didier@xemacs.org>
parents: 5402
diff changeset
901 locale
b0d712bbc2a6 The "flush" face property.
Didier Verna <didier@xemacs.org>
parents: 5402
diff changeset
902 tty-tag-set)
b0d712bbc2a6 The "flush" face property.
Didier Verna <didier@xemacs.org>
parents: 5402
diff changeset
903 (remove-specifier-specs-matching-tag-set-cdrs (face-property
5619
75ad4969a16d Replace the 'flush face property with the opposite 'shrink one.
Didier Verna <didier@xemacs.org>
parents: 5617
diff changeset
904 face 'shrink)
5617
b0d712bbc2a6 The "flush" face property.
Didier Verna <didier@xemacs.org>
parents: 5402
diff changeset
905 locale
b0d712bbc2a6 The "flush" face property.
Didier Verna <didier@xemacs.org>
parents: 5402
diff changeset
906 x-tag-set))
b0d712bbc2a6 The "flush" face property.
Didier Verna <didier@xemacs.org>
parents: 5402
diff changeset
907 (t
5619
75ad4969a16d Replace the 'flush face property with the opposite 'shrink one.
Didier Verna <didier@xemacs.org>
parents: 5617
diff changeset
908 (remove-specifier (face-property face 'shrink) locale
5617
b0d712bbc2a6 The "flush" face property.
Didier Verna <didier@xemacs.org>
parents: 5402
diff changeset
909 tty-tag-set nil)
5619
75ad4969a16d Replace the 'flush face property with the opposite 'shrink one.
Didier Verna <didier@xemacs.org>
parents: 5617
diff changeset
910 (remove-specifier (face-property face 'shrink) locale
5617
b0d712bbc2a6 The "flush" face property.
Didier Verna <didier@xemacs.org>
parents: 5402
diff changeset
911 x-tag-set nil)))
5619
75ad4969a16d Replace the 'flush face property with the opposite 'shrink one.
Didier Verna <didier@xemacs.org>
parents: 5617
diff changeset
912 (set-face-shrink-p face fp locale our-tag-set append))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 ;; GNU Emacs compatibility. (move to obsolete.el?)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 (defalias 'make-face-x-resource-internal 'x-init-face-from-resources)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 (defun remove-specifier-specs-matching-tag-set-cdrs (specifier locale tag-set)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 (while tag-set
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 (remove-specifier specifier locale tag-set t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 (setq tag-set (cdr tag-set))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
923 ;;; x-init-global-faces is responsible for ensuring that the default face has
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
924 ;;; some reasonable fallbacks if nothing else is specified.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 (defun x-init-global-faces ()
4819
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
926 ;; #### NOTE: this code is probably an oldy: faces.c ensures that we have
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
927 ;; working fallback values so there is no need to initialize anything here.
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
928 ;; -- dvl
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
929 ;; (or (face-foreground 'default 'global)
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
930 ;; (set-face-foreground 'default "black" 'global '(x default)))
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
931 ;; (or (face-background 'default 'global)
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
932 ;; (set-face-background 'default "gray80" 'global '(x default))
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
933 )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
935 ;;; x-init-device-faces is responsible for initializing default values for
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
936 ;;; faces on a newly created device.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 (defun x-init-device-faces (device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 ;; If the "default" face didn't have a font specified, try to pick one.
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
939
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 801
diff changeset
940 ;; (or
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 801
diff changeset
941 ;; (face-font-instance 'default device)
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
942
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 801
diff changeset
943 ;; [[ No font specified in the resource database; try to cope. ]]
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
944
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
945 ;; #### NOTE: In reality, this will never happen. The fallbacks will always
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
946 ;; be tried, and the last fallback is "*", which should get any font. No
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
947 ;; need to put the same checks here as in the fallbacks. These comments
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 801
diff changeset
948 ;; appear to be pre-19.12. --ben
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 801
diff changeset
950 ;; [[ At first I wanted to do this by just putting a font-spec in the
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
951 ;; fallback resources passed to XtAppInitialize(), but that fails if there
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
952 ;; is an Emacs app-defaults file which doesn't specify a font: apparently
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
953 ;; the fallback resources are not consulted when there is an app-defaults
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
954 ;; file, which seems pretty bogus to me.
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
955
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
956 ;; We should also probably try "*xtDefaultFont", but I think that it might
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
957 ;; be legal to specify that as "xtDefaultFont:", that is, at top level,
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
958 ;; instead of "*xtDefaultFont:", that is, applicable to every application.
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
959 ;; `x-get-resource' can't handle that right now. Anyway, xtDefaultFont is
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
960 ;; probably variable-width.
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
961
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
962 ;; Some who have LucidaTypewriter think it's a better font than Courier, but
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
963 ;; it has the bug that there are no italic and bold italic versions. We
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
964 ;; could hair this code up to try and mix-and-match fonts to get a full
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
965 ;; complement, but really, why bother. It's just a default. ]]
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
966
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
967 ;; [[ We default to looking for iso8859 fonts. Using a wildcard for the
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 801
diff changeset
968 ;; encoding would be bad, because that can cause English speakers to get
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
969 ;; Kanji fonts by default. It is safe to assume that people using a language
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
970 ;; other than English have both set $LANG, and have specified their `font'
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
971 ;; and `fontList' resources. In any event, it's better to err on the side of
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
972 ;; the English speaker in this case because they are much less likely to
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
973 ;; have encountered this problem, and are thus less likely to know what to
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
974 ;; do about it. ]]
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 801
diff changeset
975
4819
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
976 ;; #### NOTE: this code is probably an oldy as well (as per Ben's comment
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
977 ;; above): faces.c ensures that we have working fallback values so there is
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
978 ;; no need to initialize anything here. -- dvl
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979
4819
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
980 ;; (let ((fg (face-foreground-instance 'default device))
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
981 ;; (bg (face-background-instance 'default device)))
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
982 ;; (if (not (and fg bg))
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
983 ;; (if (or (and fg (equalp (color-instance-name fg) "white"))
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
984 ;; (and bg (equalp (color-instance-name bg) "black")))
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
985 ;; (progn
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
986 ;; (or fg (set-face-foreground 'default "white" device))
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
987 ;; (or bg (set-face-background 'default "black" device)))
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
988 ;; (or fg (set-face-foreground 'default "white" device))
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
989 ;; (or bg (set-face-background 'default "black" device)))))
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
990
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
991 ;; Don't look at reverseVideo now or initialize the modeline. This is done
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
992 ;; on a per-frame basis at the appropriate time.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
994 ;; Now let's try to pick some reasonable defaults for a few other faces.
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
995 ;; This kind of stuff should normally go on the create-frame-hook, but this
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
996 ;; way we won't be in danger of the user screwing things up by not adding
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
997 ;; hooks in a safe way.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 (x-init-pointer-shape device) ; from x-mouse.el
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 ;;; This is called from `init-frame-faces', which is called from
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
1002 ;;; init_frame_faces() which is called from Fmake_frame(), to perform any
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
1003 ;;; device-specific initialization.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 (defun x-init-frame-faces (frame)
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
1005 ;; The faces already got initialized (by init-frame-faces) from the resource
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
1006 ;; database or global, non-frame faces. The default, bold, bold-italic, and
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
1007 ;; italic faces (plus various other random faces) got set up then. But
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
1008 ;; modeline didn't so that reverseVideo can be frame-specific.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
1010 ;; If reverseVideo was specified, swap the foreground and background of the
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
1011 ;; default and modeline faces.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
1012 (cond ((car (x-get-resource "reverseVideo" "ReverseVideo" 'boolean frame
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
1013 nil 'warn))
4819
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
1014 ;; #### NOTE: again, this is probably yet another oldy: faces.c
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
1015 ;; ensures sane fallbacks for the modeline face. Besides, this face
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
1016 ;; does not inherit from the default face, but from the gui-element
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
1017 ;; one.-- dvl
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
1018
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
1019 ;; (or (face-foreground 'modeline frame)
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
1020 ;; (set-face-foreground 'modeline
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
1021 ;; (face-foreground-instance 'default frame)
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
1022 ;; frame))
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
1023 ;; (or (face-background 'modeline frame)
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
1024 ;; (set-face-background 'modeline
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
1025 ;; (face-background-instance 'default frame)
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
1026 ;; frame))
49480d838d32 Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents: 4215
diff changeset
1027
4822
0482cdb4e35d Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents: 4819
diff changeset
1028 ;; Now invert both of them. If they end up looking the same,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 ;; make-frame-initial-faces will invert the modeline again later.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 (invert-face 'default frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 (invert-face 'modeline frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 )))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 ;;; x-faces.el ends here