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