Mercurial > hg > xemacs-beta
annotate lisp/x-faces.el @ 4981:4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
-------------------- ChangeLog entries follow: --------------------
modules/ChangeLog addition:
2010-02-05 Ben Wing <ben@xemacs.org>
* postgresql/postgresql.c:
* postgresql/postgresql.c (CHECK_LIVE_CONNECTION):
* postgresql/postgresql.c (Fpq_connectdb):
* postgresql/postgresql.c (Fpq_connect_start):
* postgresql/postgresql.c (Fpq_lo_import):
* postgresql/postgresql.c (Fpq_lo_export):
* ldap/eldap.c (Fldap_open):
* ldap/eldap.c (Fldap_search_basic):
* ldap/eldap.c (Fldap_add):
* ldap/eldap.c (Fldap_modify):
* ldap/eldap.c (Fldap_delete):
* canna/canna_api.c (Fcanna_initialize):
* canna/canna_api.c (Fcanna_store_yomi):
* canna/canna_api.c (Fcanna_parse):
* canna/canna_api.c (Fcanna_henkan_begin):
EXTERNAL_TO_C_STRING returns its argument instead of storing it
in a parameter, and is renamed to EXTERNAL_TO_ITEXT. Similar
things happen to related macros. See entry in src/ChangeLog.
More Mule-izing of postgresql.c. Extract out common code
between `pq-connectdb' and `pq-connect-start'. Fix places
that signal an error string using a formatted string to instead
follow the standard and have a fixed reason followed by the
particular error message stored as one of the frobs.
src/ChangeLog addition:
2010-02-05 Ben Wing <ben@xemacs.org>
* console-msw.c (write_string_to_mswindows_debugging_output):
* console-msw.c (Fmswindows_message_box):
* console-x.c (x_perhaps_init_unseen_key_defaults):
* console.c:
* database.c (dbm_get):
* database.c (dbm_put):
* database.c (dbm_remove):
* database.c (berkdb_get):
* database.c (berkdb_put):
* database.c (berkdb_remove):
* database.c (Fopen_database):
* device-gtk.c (gtk_init_device):
* device-msw.c (msprinter_init_device_internal):
* device-msw.c (msprinter_default_printer):
* device-msw.c (msprinter_init_device):
* device-msw.c (sync_printer_with_devmode):
* device-msw.c (Fmsprinter_select_settings):
* device-x.c (sanity_check_geometry_resource):
* device-x.c (Dynarr_add_validified_lisp_string):
* device-x.c (x_init_device):
* device-x.c (Fx_put_resource):
* device-x.c (Fx_valid_keysym_name_p):
* device-x.c (Fx_set_font_path):
* dialog-msw.c (push_lisp_string_as_unicode):
* dialog-msw.c (handle_directory_dialog_box):
* dialog-msw.c (handle_file_dialog_box):
* dialog-x.c (dbox_descriptor_to_widget_value):
* editfns.c (Fformat_time_string):
* editfns.c (Fencode_time):
* editfns.c (Fset_time_zone_rule):
* emacs.c (make_argc_argv):
* emacs.c (Fdump_emacs):
* emodules.c (emodules_load):
* eval.c:
* eval.c (maybe_signal_error_1):
* event-msw.c (Fdde_alloc_advise_item):
* event-msw.c (mswindows_dde_callback):
* event-msw.c (mswindows_wnd_proc):
* fileio.c (report_error_with_errno):
* fileio.c (Fsysnetunam):
* fileio.c (Fdo_auto_save):
* font-mgr.c (extract_fcapi_string):
* font-mgr.c (Ffc_config_app_font_add_file):
* font-mgr.c (Ffc_config_app_font_add_dir):
* font-mgr.c (Ffc_config_filename):
* frame-gtk.c (gtk_set_frame_text_value):
* frame-gtk.c (gtk_create_widgets):
* frame-msw.c (mswindows_init_frame_1):
* frame-msw.c (mswindows_set_title_from_ibyte):
* frame-msw.c (msprinter_init_frame_3):
* frame-x.c (x_set_frame_text_value):
* frame-x.c (x_set_frame_properties):
* frame-x.c (start_drag_internal_1):
* frame-x.c (x_cde_transfer_callback):
* frame-x.c (x_create_widgets):
* glyphs-eimage.c (my_jpeg_output_message):
* glyphs-eimage.c (jpeg_instantiate):
* glyphs-eimage.c (gif_instantiate):
* glyphs-eimage.c (png_instantiate):
* glyphs-eimage.c (tiff_instantiate):
* glyphs-gtk.c (xbm_instantiate_1):
* glyphs-gtk.c (gtk_xbm_instantiate):
* glyphs-gtk.c (gtk_xpm_instantiate):
* glyphs-gtk.c (gtk_xface_instantiate):
* glyphs-gtk.c (cursor_font_instantiate):
* glyphs-gtk.c (gtk_redisplay_widget):
* glyphs-gtk.c (gtk_widget_instantiate_1):
* glyphs-gtk.c (gtk_add_tab_item):
* glyphs-msw.c (mswindows_xpm_instantiate):
* glyphs-msw.c (bmp_instantiate):
* glyphs-msw.c (mswindows_resource_instantiate):
* glyphs-msw.c (xbm_instantiate_1):
* glyphs-msw.c (mswindows_xbm_instantiate):
* glyphs-msw.c (mswindows_xface_instantiate):
* glyphs-msw.c (mswindows_redisplay_widget):
* glyphs-msw.c (mswindows_widget_instantiate):
* glyphs-msw.c (add_tree_item):
* glyphs-msw.c (add_tab_item):
* glyphs-msw.c (mswindows_combo_box_instantiate):
* glyphs-msw.c (mswindows_widget_query_string_geometry):
* glyphs-x.c (x_locate_pixmap_file):
* glyphs-x.c (xbm_instantiate_1):
* glyphs-x.c (x_xbm_instantiate):
* glyphs-x.c (extract_xpm_color_names):
* glyphs-x.c (x_xpm_instantiate):
* glyphs-x.c (x_xface_instantiate):
* glyphs-x.c (autodetect_instantiate):
* glyphs-x.c (safe_XLoadFont):
* glyphs-x.c (cursor_font_instantiate):
* glyphs-x.c (x_redisplay_widget):
* glyphs-x.c (Fchange_subwindow_property):
* glyphs-x.c (x_widget_instantiate):
* glyphs-x.c (x_tab_control_redisplay):
* glyphs.c (pixmap_to_lisp_data):
* gui-x.c (menu_separator_style_and_to_external):
* gui-x.c (add_accel_and_to_external):
* gui-x.c (button_item_to_widget_value):
* hpplay.c (player_error_internal):
* hpplay.c (play_sound_file):
* hpplay.c (play_sound_data):
* intl.c (Fset_current_locale):
* lisp.h:
* menubar-gtk.c (gtk_xemacs_set_accel_keys):
* menubar-msw.c (populate_menu_add_item):
* menubar-msw.c (populate_or_checksum_helper):
* menubar-x.c (menu_item_descriptor_to_widget_value_1):
* nt.c (init_user_info):
* nt.c (get_long_basename):
* nt.c (nt_get_resource):
* nt.c (init_mswindows_environment):
* nt.c (get_cached_volume_information):
* nt.c (mswindows_readdir):
* nt.c (read_unc_volume):
* nt.c (mswindows_stat):
* nt.c (mswindows_getdcwd):
* nt.c (mswindows_executable_type):
* nt.c (Fmswindows_short_file_name):
* ntplay.c (nt_play_sound_file):
* objects-gtk.c:
* objects-gtk.c (gtk_valid_color_name_p):
* objects-gtk.c (gtk_initialize_font_instance):
* objects-gtk.c (gtk_font_list):
* objects-msw.c (font_enum_callback_2):
* objects-msw.c (parse_font_spec):
* objects-x.c (x_parse_nearest_color):
* objects-x.c (x_valid_color_name_p):
* objects-x.c (x_initialize_font_instance):
* objects-x.c (x_font_instance_truename):
* objects-x.c (x_font_list):
* objects-xlike-inc.c (XFUN):
* objects-xlike-inc.c (xft_find_charset_font):
* process-nt.c (mswindows_report_winsock_error):
* process-nt.c (nt_create_process):
* process-nt.c (get_internet_address):
* process-nt.c (nt_open_network_stream):
* process-unix.c:
* process-unix.c (allocate_pty):
* process-unix.c (get_internet_address):
* process-unix.c (unix_canonicalize_host_name):
* process-unix.c (unix_open_network_stream):
* realpath.c:
* select-common.h (lisp_data_to_selection_data):
* select-gtk.c (symbol_to_gtk_atom):
* select-gtk.c (atom_to_symbol):
* select-msw.c (symbol_to_ms_cf):
* select-msw.c (mswindows_register_selection_data_type):
* select-x.c (symbol_to_x_atom):
* select-x.c (x_atom_to_symbol):
* select-x.c (hack_motif_clipboard_selection):
* select-x.c (Fx_store_cutbuffer_internal):
* sound.c (Fplay_sound_file):
* sound.c (Fplay_sound):
* sound.h (sound_perror):
* sysdep.c:
* sysdep.c (qxe_allocating_getcwd):
* sysdep.c (qxe_execve):
* sysdep.c (copy_in_passwd):
* sysdep.c (qxe_getpwnam):
* sysdep.c (qxe_ctime):
* sysdll.c (dll_open):
* sysdll.c (dll_function):
* sysdll.c (dll_variable):
* sysdll.c (search_linked_libs):
* sysdll.c (dll_error):
* sysfile.h:
* sysfile.h (PATHNAME_CONVERT_OUT_TSTR):
* sysfile.h (PATHNAME_CONVERT_OUT_UTF_8):
* sysfile.h (PATHNAME_CONVERT_OUT):
* sysfile.h (LISP_PATHNAME_CONVERT_OUT):
* syswindows.h (ITEXT_TO_TSTR):
* syswindows.h (LOCAL_FILE_FORMAT_TO_TSTR):
* syswindows.h (TSTR_TO_LOCAL_FILE_FORMAT):
* syswindows.h (LOCAL_FILE_FORMAT_TO_INTERNAL_MSWIN):
* syswindows.h (LISP_LOCAL_FILE_FORMAT_MAYBE_URL_TO_TSTR):
* text.h:
* text.h (eicpy_ext_len):
* text.h (enum new_dfc_src_type):
* text.h (EXTERNAL_TO_ITEXT):
* text.h (GET_STRERROR):
* tooltalk.c (check_status):
* tooltalk.c (Fadd_tooltalk_message_arg):
* tooltalk.c (Fadd_tooltalk_pattern_attribute):
* tooltalk.c (Fadd_tooltalk_pattern_arg):
* win32.c (tstr_to_local_file_format):
* win32.c (mswindows_lisp_error_1):
* win32.c (mswindows_report_process_error):
* win32.c (Fmswindows_shell_execute):
* win32.c (mswindows_read_link_1):
Changes involving external/internal format conversion,
mostly code cleanup and renaming.
1. Eliminate the previous macros like LISP_STRING_TO_EXTERNAL
that stored its result in a parameter. The new version of
LISP_STRING_TO_EXTERNAL returns its result through the
return value, same as the previous NEW_LISP_STRING_TO_EXTERNAL.
Use the new-style macros throughout the code.
2. Rename C_STRING_TO_EXTERNAL and friends to ITEXT_TO_EXTERNAL,
in keeping with overall naming rationalization involving
Itext and related types.
Macros involved in previous two:
EXTERNAL_TO_C_STRING -> EXTERNAL_TO_ITEXT
EXTERNAL_TO_C_STRING_MALLOC -> EXTERNAL_TO_ITEXT_MALLOC
SIZED_EXTERNAL_TO_C_STRING -> SIZED_EXTERNAL_TO_ITEXT
SIZED_EXTERNAL_TO_C_STRING_MALLOC -> SIZED_EXTERNAL_TO_ITEXT_MALLOC
C_STRING_TO_EXTERNAL -> ITEXT_TO_EXTERNAL
C_STRING_TO_EXTERNAL_MALLOC -> ITEXT_TO_EXTERNAL_MALLOC
LISP_STRING_TO_EXTERNAL
LISP_STRING_TO_EXTERNAL_MALLOC
LISP_STRING_TO_TSTR
C_STRING_TO_TSTR -> ITEXT_TO_TSTR
TSTR_TO_C_STRING -> TSTR_TO_ITEXT
The following four still return their values through parameters,
since they have more than one value to return:
C_STRING_TO_SIZED_EXTERNAL -> ITEXT_TO_SIZED_EXTERNAL
LISP_STRING_TO_SIZED_EXTERNAL
C_STRING_TO_SIZED_EXTERNAL_MALLOC -> ITEXT_TO_SIZED_EXTERNAL_MALLOC
LISP_STRING_TO_SIZED_EXTERNAL_MALLOC
Sometimes additional casts had to be inserted, since the old
macros played strange games and completely defeated the type system
of the store params.
3. Rewrite many places where direct calls to TO_EXTERNAL_FORMAT
occurred with calls to one of the convenience macros listed above,
or to make_extstring().
4. Eliminate SIZED_C_STRING macros (they were hardly used, anyway)
and use a direct call to TO_EXTERNAL_FORMAT or TO_INTERNAL_FORMAT.
4. Use LISP_PATHNAME_CONVERT_OUT in many places instead of something
like LISP_STRING_TO_EXTERNAL(..., Qfile_name).
5. Eliminate some temporary variables that are no longer necessary
now that we return a value rather than storing it into a variable.
6. Some Mule-izing in database.c.
7. Error functions:
-- A bit of code cleanup in maybe_signal_error_1.
-- Eliminate report_file_type_error; it's just an alias for
signal_error_2 with params in a different order.
-- Fix some places in the hostname-handling code that directly
inserted externally-retrieved error strings into the
supposed ASCII "reason" param instead of doing the right thing
and sticking text descriptive of what was going on in "reason"
and putting the external message in a frob.
8. Use Ascbyte instead of CIbyte in process-unix.c and maybe one
or two other places.
9. Some code cleanup in copy_in_passwd() in sysdep.c.
10. Fix a real bug due to accidental variable shadowing in
tstr_to_local_file_format() in win32.c.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Fri, 05 Feb 2010 11:02:24 -0600 |
parents | 0482cdb4e35d |
children | 8b2f75cecb89 |
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 | |
12 ;; XEmacs is free software; you can redistribute it and/or modify it | |
13 ;; under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; XEmacs is distributed in the hope that it will be useful, but | |
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 ;; General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with XEmacs; see the file COPYING. If not, write to the | |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
26 | |
27 ;;; Synched up with: Not synched. | |
28 | |
29 ;;; Commentary: | |
30 | |
31 ;; This file is dumped with XEmacs (when X support is compiled in). | |
32 | |
33 ;; Modified by: Chuck Thompson | |
34 ;; Modified by: Ben Wing | |
35 ;; Modified by: Martin Buchholz | |
36 | |
37 ;; This file does the magic to parse X font names, and make sure that the | |
38 ;; default and modeline attributes of new frames are specified enough. | |
39 | |
40 ;; The resource-manager syntax for faces is | |
41 | |
2703 | 42 ;; XEmacs.bold.attributeFont: font-name |
43 ;; XEmacs.bold.attributeForeground: fg | |
44 ;; XEmacs.bold.attributeBackground: bg | |
45 ;; XEmacs.bold.attributeBackgroundPixmap: file | |
46 ;; XEmacs.bold.attributeUnderline: true/false | |
47 ;; XEmacs.bold.attributeStrikethru: true/false | |
428 | 48 |
49 ;; You can specify the properties of a face on a per-frame basis. For | |
50 ;; example, to have the "isearch" face use a red foreground on frames | |
2703 | 51 ;; named "XEmacs" (the default) but use a blue foreground on frames that |
428 | 52 ;; you create named "debugger", you could do |
53 | |
2703 | 54 ;; XEmacs*XEmacs.isearch.attributeForeground: red |
55 ;; XEmacs*debugger.isearch.attributeForeground: blue | |
428 | 56 |
57 ;; Generally things that make faces won't set any of the face attributes if | |
58 ;; you have already given them values via the resource database. You can | |
59 ;; also change this stuff from your .emacs file, by using the functions | |
60 ;; set-face-foreground, set-face-font, etc. See the code in this file, and | |
61 ;; in faces.el. | |
62 | |
63 ;;; Code: | |
64 | |
502 | 65 (globally-declare-fboundp |
66 '(x-get-resource-and-maybe-bogosity-check | |
67 x-get-resource x-init-pointer-shape)) | |
68 | |
3354 | 69 (if (featurep 'xft-fonts) |
70 (require 'fontconfig) | |
71 (globally-declare-boundp | |
72 '(fc-font-name-weight-bold fc-font-name-weight-black | |
73 fc-font-name-weight-demibold fc-font-name-weight-medium | |
74 fc-font-name-slant-oblique fc-font-name-slant-italic | |
75 fc-font-name-slant-roman)) | |
76 (globally-declare-fboundp | |
3918 | 77 '(fc-font-match fc-pattern-del-size fc-pattern-get-size |
78 fc-pattern-add-size fc-pattern-del-style fc-pattern-duplicate | |
79 fc-copy-pattern-partial fc-pattern-add-weight fc-pattern-del-weight | |
80 fc-try-font fc-pattern-del-slant fc-pattern-add-slant fc-name-parse | |
81 fc-name-unparse fc-pattern-get-pixelsize))) | |
3094 | 82 |
428 | 83 (defconst x-font-regexp nil) |
84 (defconst x-font-regexp-head nil) | |
85 (defconst x-font-regexp-head-2 nil) | |
86 (defconst x-font-regexp-weight nil) | |
87 (defconst x-font-regexp-slant nil) | |
88 (defconst x-font-regexp-pixel nil) | |
89 (defconst x-font-regexp-point nil) | |
90 (defconst x-font-regexp-foundry-and-family nil) | |
91 (defconst x-font-regexp-registry-and-encoding nil) | |
92 (defconst x-font-regexp-spacing nil) | |
93 | |
94 ;;; Regexps matching font names in "Host Portable Character Representation." | |
3094 | 95 ;;; #### But more recently Latin-1 is permitted, and Xft needs it in C (?). |
428 | 96 ;;; |
97 (let ((- "[-?]") | |
98 (foundry "[^-]*") | |
99 (family "[^-]*") | |
100 (weight "\\(bold\\|demibold\\|medium\\|black\\)") ; 1 | |
101 ; (weight\? "\\(\\*\\|bold\\|demibold\\|medium\\|\\)") ; 1 | |
102 (weight\? "\\([^-]*\\)") ; 1 | |
103 (slant "\\([ior]\\)") ; 2 | |
104 ; (slant\? "\\([ior?*]?\\)") ; 2 | |
105 (slant\? "\\([^-]?\\)") ; 2 | |
106 ; (swidth "\\(\\*\\|normal\\|semicondensed\\|\\)") ; 3 | |
107 (swidth "\\([^-]*\\)") ; 3 | |
108 ; (adstyle "\\(\\*\\|sans\\|\\)") ; 4 | |
109 (adstyle "\\([^-]*\\)") ; 4 | |
110 (pixelsize "\\(\\*\\|[0-9]+\\)") ; 5 | |
111 (pointsize "\\(\\*\\|0\\|[0-9][0-9]+\\)") ; 6 | |
112 ; (resx "\\(\\*\\|[0-9][0-9]+\\)") ; 7 | |
113 ; (resy "\\(\\*\\|[0-9][0-9]+\\)") ; 8 | |
114 (resx "\\([*0]\\|[0-9][0-9]+\\)") ; 7 | |
115 (resy "\\([*0]\\|[0-9][0-9]+\\)") ; 8 | |
116 (spacing "[cmp?*]") | |
117 (avgwidth "\\(\\*\\|[0-9]+\\)") ; 9 | |
118 (registry "[^-]*") ; some fonts have omitted registries | |
119 ; (encoding ".+") ; note that encoding may contain "-"... | |
120 (encoding "[^-]+") ; false! | |
121 ) | |
122 (setq x-font-regexp | |
444 | 123 (concat "\\`\\*?[-?*]" |
124 foundry - family - weight\? - slant\? - swidth - adstyle - | |
125 pixelsize - pointsize - resx - resy - spacing - avgwidth - | |
126 registry - encoding "\\'" | |
127 )) | |
428 | 128 (setq x-font-regexp-head |
444 | 129 (concat "\\`[-?*]" foundry - family - weight\? - slant\? |
130 "\\([-*?]\\|\\'\\)")) | |
428 | 131 (setq x-font-regexp-head-2 |
444 | 132 (concat "\\`[-?*]" foundry - family - weight\? - slant\? |
133 - swidth - adstyle - pixelsize - pointsize | |
134 "\\([-*?]\\|\\'\\)")) | |
135 (setq x-font-regexp-slant (concat - slant -)) | |
136 (setq x-font-regexp-weight (concat - weight -)) | |
428 | 137 ;; if we can't match any of the more specific regexps (unfortunate) then |
138 ;; look for digits; assume 2+ digits is 10ths of points, and 1-2 digits | |
139 ;; is pixels. Bogus as hell. | |
444 | 140 (setq x-font-regexp-pixel "[-?*]\\([0-9][0-9]?\\)[-?*]") |
141 (setq x-font-regexp-point "[-?*]\\([0-9][0-9]+\\)[-?*]") | |
428 | 142 ;; the following two are used by x-font-menu.el. |
143 (setq x-font-regexp-foundry-and-family | |
444 | 144 (concat "\\`[-?*]" foundry - "\\(" family "\\)" -)) |
428 | 145 (setq x-font-regexp-registry-and-encoding |
444 | 146 (concat - "\\(" registry "\\)" - "\\(" encoding "\\)\\'")) |
428 | 147 (setq x-font-regexp-spacing |
444 | 148 (concat - "\\(" spacing "\\)" - avgwidth |
149 - registry - encoding "\\'")) | |
428 | 150 ) |
151 | |
3094 | 152 (defun x-font-xlfd-font-name-p (font) |
153 "Check if FONT is an XLFD font name" | |
154 (and (stringp font) | |
155 (string-match x-font-regexp font))) | |
156 | |
428 | 157 ;; A "loser font" is something like "8x13" -> "8x13bold". |
158 ;; These are supported only through extreme generosity. | |
444 | 159 (defconst x-loser-font-regexp "\\`[0-9]+x[0-9]+\\'") |
428 | 160 |
161 (defun x-frob-font-weight (font which) | |
162 (if (font-instance-p font) (setq font (font-instance-name font))) | |
163 (cond ((null font) nil) | |
164 ((or (string-match x-font-regexp font) | |
165 (string-match x-font-regexp-head font) | |
166 (string-match x-font-regexp-weight font)) | |
167 (concat (substring font 0 (match-beginning 1)) which | |
168 (substring font (match-end 1)))) | |
169 ((string-match x-loser-font-regexp font) | |
170 (concat font which)) | |
171 (t nil))) | |
172 | |
173 (defun x-frob-font-slant (font which) | |
174 (if (font-instance-p font) (setq font (font-instance-name font))) | |
175 (cond ((null font) nil) | |
176 ((or (string-match x-font-regexp font) | |
177 (string-match x-font-regexp-head font)) | |
178 (concat (substring font 0 (match-beginning 2)) which | |
179 (substring font (match-end 2)))) | |
180 ((string-match x-font-regexp-slant font) | |
181 (concat (substring font 0 (match-beginning 1)) which | |
182 (substring font (match-end 1)))) | |
183 ((string-match x-loser-font-regexp font) | |
184 (concat font which)) | |
185 (t nil))) | |
186 | |
187 (defun x-make-font-bold (font &optional device) | |
188 "Given an X font specification, this attempts to make a `bold' font. | |
189 If it fails, it returns nil." | |
3094 | 190 (if (featurep 'xft-fonts) |
191 (if (x-font-xlfd-font-name-p font) | |
192 (x-make-font-bold-core font device) | |
193 (x-make-font-bold-xft font device)) | |
194 (x-make-font-bold-core font device))) | |
195 | |
196 (defun x-make-font-bold-xft (font &optional device) | |
3360 | 197 (let ((pattern (fc-font-match (or device (default-x-device)) |
198 (fc-name-parse font)))) | |
3094 | 199 (if pattern |
200 (let ((size (fc-pattern-get-size pattern 0)) | |
3354 | 201 (copy (fc-copy-pattern-partial pattern (list "family")))) |
202 (fc-pattern-del-weight copy) | |
203 (fc-pattern-del-style copy) | |
3094 | 204 (when copy |
205 (or | |
206 ;; try bold font | |
207 (let ((copy-2 (fc-pattern-duplicate copy))) | |
3354 | 208 (fc-pattern-add-weight copy-2 fc-font-name-weight-bold) |
3094 | 209 (when (fc-try-font copy-2 device) |
3354 | 210 (fc-pattern-add-size copy-2 size) |
3094 | 211 (fc-name-unparse copy-2))) |
212 ;; try black font | |
213 (let ((copy-2 (fc-pattern-duplicate copy))) | |
3354 | 214 (fc-pattern-add-weight copy-2 fc-font-name-weight-black) |
3094 | 215 (when (fc-try-font copy-2 device) |
3354 | 216 (fc-pattern-add-size copy-2 size) |
3094 | 217 (fc-name-unparse copy-2))) |
218 ;; try demibold font | |
219 (let ((copy-2 (fc-pattern-duplicate copy))) | |
3354 | 220 (fc-pattern-add-weight copy-2 fc-font-name-weight-demibold) |
3094 | 221 (when (fc-try-font copy-2 device) |
3354 | 222 (fc-pattern-add-size copy-2 size) |
3094 | 223 (fc-name-unparse copy-2))))))))) |
224 | |
225 (defun x-make-font-bold-core (font &optional device) | |
428 | 226 ;; Certain Type1 fonts know "bold" as "black"... |
227 (or (try-font-name (x-frob-font-weight font "bold") device) | |
228 (try-font-name (x-frob-font-weight font "black") device) | |
229 (try-font-name (x-frob-font-weight font "demibold") device))) | |
230 | |
231 (defun x-make-font-unbold (font &optional device) | |
232 "Given an X font specification, this attempts to make a non-bold font. | |
233 If it fails, it returns nil." | |
3094 | 234 (if (featurep 'xft-fonts) |
235 (if (x-font-xlfd-font-name-p font) | |
236 (x-make-font-unbold-core font device) | |
237 (x-make-font-unbold-xft font device)) | |
238 (x-make-font-unbold-core font device))) | |
239 | |
240 (defun x-make-font-unbold-xft (font &optional device) | |
3360 | 241 (let ((pattern (fc-font-match (or device (default-x-device)) |
242 (fc-name-parse font)))) | |
3094 | 243 (when pattern |
3354 | 244 (fc-pattern-del-weight pattern) |
245 (fc-pattern-add-weight pattern fc-font-name-weight-medium) | |
3094 | 246 (if (fc-try-font pattern device) |
247 (fc-name-unparse pattern))))) | |
248 | |
249 (defun x-make-font-unbold-core (font &optional device) | |
428 | 250 (try-font-name (x-frob-font-weight font "medium") device)) |
251 | |
252 (defcustom try-oblique-before-italic-fonts nil | |
253 "*If nil, italic fonts are searched before oblique fonts. | |
254 If non-nil, oblique fonts are tried before italic fonts. This is mostly | |
255 applicable to adobe-courier fonts" | |
256 :type 'boolean | |
257 :group 'x) | |
258 (define-obsolete-variable-alias '*try-oblique-before-italic-fonts* | |
259 'try-oblique-before-italic-fonts) | |
260 | |
261 (defun x-make-font-italic (font &optional device) | |
262 "Given an X font specification, this attempts to make an `italic' font. | |
263 If it fails, it returns nil." | |
3094 | 264 (if (featurep 'xft-fonts) |
265 (if (x-font-xlfd-font-name-p font) | |
266 (x-make-font-italic-core font device) | |
267 (x-make-font-italic-xft font device)) | |
268 (x-make-font-italic-core font device))) | |
269 | |
270 (defun x-make-font-italic-xft (font &optional device) | |
3360 | 271 (let ((pattern (fc-font-match (or device (default-x-device)) |
272 (fc-name-parse font)))) | |
3094 | 273 (if pattern |
274 (let ((size (fc-pattern-get-size pattern 0)) | |
3354 | 275 (copy (fc-copy-pattern-partial pattern (list "family")))) |
3094 | 276 (when copy |
3354 | 277 (fc-pattern-del-slant copy) |
278 (fc-pattern-del-style copy) | |
279 ;; #### can't we do this with one ambiguous pattern? | |
3094 | 280 (let ((pattern-oblique (fc-pattern-duplicate copy)) |
281 (pattern-italic (fc-pattern-duplicate copy))) | |
3354 | 282 (fc-pattern-add-slant pattern-oblique fc-font-name-slant-oblique) |
283 (fc-pattern-add-slant pattern-italic fc-font-name-slant-italic) | |
3094 | 284 (let ((have-oblique (fc-try-font pattern-oblique device)) |
285 (have-italic (fc-try-font pattern-italic device))) | |
286 (if try-oblique-before-italic-fonts | |
287 (if have-oblique | |
288 (progn | |
289 (if size | |
3354 | 290 (fc-pattern-add-size pattern-oblique size)) |
3094 | 291 (fc-name-unparse pattern-oblique)) |
292 (if have-italic | |
293 (progn | |
294 (if size | |
3354 | 295 (fc-pattern-add-size pattern-italic size)) |
3094 | 296 (fc-name-unparse pattern-italic)))) |
297 (if have-italic | |
298 (progn | |
299 (if size | |
3354 | 300 (fc-pattern-add-size pattern-italic size)) |
3094 | 301 (fc-name-unparse pattern-italic)) |
302 (if have-oblique | |
303 (progn | |
304 (if size | |
3354 | 305 (fc-pattern-add-size pattern-oblique size)) |
3094 | 306 (fc-name-unparse pattern-oblique)))))))))))) |
307 | |
308 (defun x-make-font-italic-core (font &optional device) | |
428 | 309 (if try-oblique-before-italic-fonts |
310 (or (try-font-name (x-frob-font-slant font "o") device) | |
311 (try-font-name (x-frob-font-slant font "i") device)) | |
312 (or (try-font-name (x-frob-font-slant font "i") device) | |
313 (try-font-name (x-frob-font-slant font "o") device)))) | |
314 | |
315 (defun x-make-font-unitalic (font &optional device) | |
316 "Given an X font specification, this attempts to make a non-italic font. | |
317 If it fails, it returns nil." | |
3094 | 318 (if (featurep 'xft-fonts) |
319 (if (x-font-xlfd-font-name-p font) | |
320 (x-make-font-unitalic-core font device) | |
321 (x-make-font-unitalic-xft font device)) | |
322 (x-make-font-unitalic-core font device))) | |
323 | |
324 (defun x-make-font-unitalic-xft (font &optional device) | |
3360 | 325 (let ((pattern (fc-font-match (or device (default-x-device)) |
326 (fc-name-parse font)))) | |
3094 | 327 (when pattern |
3354 | 328 (fc-pattern-del-slant pattern) |
329 (fc-pattern-add-slant pattern fc-font-name-slant-roman) | |
3094 | 330 (if (fc-try-font pattern device) |
331 (fc-name-unparse pattern))))) | |
332 | |
333 (defun x-make-font-unitalic-core (font &optional device) | |
428 | 334 (try-font-name (x-frob-font-slant font "r") device)) |
335 | |
336 (defun x-make-font-bold-italic (font &optional device) | |
337 "Given an X font specification, this attempts to make a `bold-italic' font. | |
338 If it fails, it returns nil." | |
3094 | 339 (if (featurep 'xft-fonts) |
340 (if (x-font-xlfd-font-name-p font) | |
341 (x-make-font-bold-italic-core font device) | |
342 (x-make-font-bold-italic-xft font device)) | |
343 (x-make-font-bold-italic-core font device))) | |
344 | |
345 (defun x-make-font-bold-italic-xft (font &optional device) | |
346 (let ((italic (x-make-font-italic-xft font device))) | |
347 (if italic | |
348 (x-make-font-bold-xft italic device)))) | |
349 | |
350 (defun x-make-font-bold-italic-core (font &optional device) | |
428 | 351 ;; This is haired up to avoid loading the "intermediate" fonts. |
442 | 352 (if try-oblique-before-italic-fonts |
428 | 353 (or (try-font-name |
354 (x-frob-font-slant (x-frob-font-weight font "bold") "o") device) | |
355 (try-font-name | |
356 (x-frob-font-slant (x-frob-font-weight font "bold") "i") device) | |
357 (try-font-name | |
358 (x-frob-font-slant (x-frob-font-weight font "black") "o") device) | |
359 (try-font-name | |
360 (x-frob-font-slant (x-frob-font-weight font "black") "i") device) | |
361 (try-font-name | |
362 (x-frob-font-slant (x-frob-font-weight font "demibold") "o") device) | |
363 (try-font-name | |
364 (x-frob-font-slant (x-frob-font-weight font "demibold") "i") device)) | |
365 (or (try-font-name | |
366 (x-frob-font-slant (x-frob-font-weight font "bold") "i") device) | |
367 (try-font-name | |
368 (x-frob-font-slant (x-frob-font-weight font "bold") "o") device) | |
369 (try-font-name | |
370 (x-frob-font-slant (x-frob-font-weight font "black") "i") device) | |
371 (try-font-name | |
372 (x-frob-font-slant (x-frob-font-weight font "black") "o") device) | |
373 (try-font-name | |
374 (x-frob-font-slant (x-frob-font-weight font "demibold") "i") device) | |
375 (try-font-name | |
376 (x-frob-font-slant (x-frob-font-weight font "demibold") "o") device)))) | |
377 | |
378 (defun x-font-size (font) | |
379 "Return the nominal size of the given font. | |
380 This is done by parsing its name, so it's likely to lose. | |
381 X fonts can be specified (by the user) in either pixels or 10ths of points, | |
382 and this returns the first one it finds, so you have to decide which units | |
383 the returned value is measured in yourself..." | |
3094 | 384 (if (featurep 'xft-fonts) |
385 (if (x-font-xlfd-font-name-p font) | |
386 (x-font-size-core font) | |
387 (x-font-size-xft font)) | |
388 (x-font-size-core font))) | |
389 | |
390 ;; this is unbelievable &*@# | |
391 (defun x-font-size-xft (font) | |
3360 | 392 (let ((pattern (fc-font-match (default-x-device) |
393 (fc-name-parse font)))) | |
3094 | 394 (when pattern |
395 (let ((pixelsize (fc-pattern-get-pixelsize pattern 0))) | |
3360 | 396 (if (floatp pixelsize) (round pixelsize) pixelsize))))) |
3094 | 397 |
398 (defun x-font-size-core (font) | |
428 | 399 (if (font-instance-p font) (setq font (font-instance-name font))) |
400 (cond ((or (string-match x-font-regexp font) | |
401 (string-match x-font-regexp-head-2 font)) | |
402 (string-to-int (substring font (match-beginning 6) (match-end 6)))) | |
403 ((or (string-match x-font-regexp-pixel font) | |
404 (string-match x-font-regexp-point font)) | |
405 (string-to-int (substring font (match-beginning 1) (match-end 1)))) | |
406 (t nil))) | |
407 | |
408 ;; Given a font name, this function returns a list describing all fonts | |
409 ;; of all sizes that otherwise match the given font spec. Each element | |
410 ;; in the list is a list of three items: the pixel size of the font, | |
411 ;; the point size (in 1/10ths of a point) of the font, and the fully- | |
412 ;; qualified font name. The first two values may be zero; this | |
413 ;; refers to a scalable font. | |
414 | |
415 (defun x-available-font-sizes (font device) | |
416 (if (font-instance-p font) (setq font (font-instance-name font))) | |
417 (cond ((string-match x-font-regexp font) | |
418 ;; turn pixelsize, pointsize, and avgwidth into wildcards | |
419 (setq font | |
420 (concat (substring font 0 (match-beginning 5)) "*" | |
421 (substring font (match-end 5) (match-beginning 6)) "*" | |
422 (substring font (match-end 6) (match-beginning 9)) "*" | |
423 (substring font (match-end 9) (match-end 0))))) | |
424 ((string-match x-font-regexp-head-2 font) | |
425 ;; turn pixelsize and pointsize into wildcards | |
426 (setq font | |
427 (concat (substring font 0 (match-beginning 5)) "*" | |
428 (substring font (match-end 5) (match-beginning 6)) "*" | |
429 (substring font (match-end 6) (match-end 0))))) | |
430 ((string-match "[-?*]\\([0-9]+\\)[-?*]" font) | |
431 ;; Turn the first integer we match into a wildcard. | |
432 ;; This is pretty dubious... | |
433 (setq font | |
434 (concat (substring font 0 (match-beginning 1)) "*" | |
435 (substring font (match-end 1) (match-end 0)))))) | |
436 (sort | |
437 (delq nil | |
438 (mapcar (function | |
439 (lambda (name) | |
440 (and (string-match x-font-regexp name) | |
441 (list | |
442 (string-to-int (substring name (match-beginning 5) | |
443 (match-end 5))) | |
444 (string-to-int (substring name (match-beginning 6) | |
445 (match-end 6))) | |
446 name)))) | |
2527 | 447 (font-list font device))) |
428 | 448 (function (lambda (x y) (if (= (nth 1 x) (nth 1 y)) |
449 (< (nth 0 x) (nth 0 y)) | |
450 (< (nth 1 x) (nth 1 y))))))) | |
451 | |
452 ;; Given a font name, this attempts to construct a valid font name for | |
453 ;; DEVICE whose size is the next smaller (if UP-P is nil) or larger | |
454 ;; (if UP-P is t) size and whose other characteristics are the same | |
455 ;; as the given font. | |
456 | |
457 (defun x-frob-font-size (font up-p device) | |
458 (if (stringp font) (setq font (make-font-instance font device))) | |
459 (if (font-instance-p font) (setq font (font-instance-truename font))) | |
460 (let ((available (and font | |
461 (x-available-font-sizes font device)))) | |
462 (cond | |
463 ((null available) nil) | |
464 ((or (= 0 (nth 0 (car available))) | |
465 (= 0 (nth 1 (car available)))) | |
466 ;; R5 scalable fonts: change size by 1 point. | |
467 ;; If they're scalable the first font will have pixel or point = 0. | |
468 ;; Sometimes one is 0 and the other isn't (if it's a bitmap font that | |
469 ;; can be scaled), sometimes both are (if it's a true outline font). | |
470 (let ((name (nth 2 (car available))) | |
471 old-size) | |
472 (or (string-match x-font-regexp font) (error "can't parse %S" font)) | |
473 (setq old-size (string-to-int | |
474 (substring font (match-beginning 6) (match-end 6)))) | |
475 (or (> old-size 0) (error "font truename has 0 pointsize?")) | |
476 (or (string-match x-font-regexp name) (error "can't parse %S" name)) | |
477 ;; turn pixelsize into a wildcard, and make pointsize be +/- 10, | |
478 ;; which is +/- 1 point. All other fields stay the same as they | |
479 ;; were in the "template" font returned by x-available-font-sizes. | |
480 ;; | |
481 ;; #### But this might return the same font: for example, if the | |
482 ;; truename of "-*-courier-medium-r-normal--*-230-75-75-m-0-*" | |
483 ;; is "...-240-..." (instead of 230) then this loses, because | |
484 ;; the 230 that was passed in as an arg got turned into 240 | |
485 ;; by the call to font-instance-truename; then we decrement that | |
486 ;; by 10 and return the result which is the same. I think the | |
487 ;; way to fix this is to make this be a loop that keeps trying | |
488 ;; progressively larger pointsize deltas until it finds one | |
489 ;; whose truename differs. Have to be careful to avoid infinite | |
490 ;; loops at the upper end... | |
491 ;; | |
492 (concat (substring name 0 (match-beginning 5)) "*" | |
493 (substring name (match-end 5) (match-beginning 6)) | |
494 (int-to-string (+ old-size (if up-p 10 -10))) | |
495 (substring name (match-end 6) (match-end 0))))) | |
496 (t | |
497 ;; non-scalable fonts: take the next available size. | |
498 (let ((rest available) | |
499 (last nil) | |
500 result) | |
501 (while rest | |
801 | 502 (cond ((and (not up-p) (equalp font (nth 2 (car rest)))) |
428 | 503 (setq result last |
504 rest nil)) | |
801 | 505 ((and up-p (equalp font (and last (nth 2 last)))) |
428 | 506 (setq result (car rest) |
507 rest nil))) | |
508 (setq last (car rest)) | |
509 (setq rest (cdr rest))) | |
510 (nth 2 result)))))) | |
511 | |
512 (defun x-find-smaller-font (font &optional device) | |
513 "Load a new, slightly smaller version of the given font (or font name). | |
514 Returns the font if it succeeds, nil otherwise. | |
515 If scalable fonts are available, this returns a font which is 1 point smaller. | |
516 Otherwise, it returns the next smaller version of this font that is defined." | |
3094 | 517 (if (featurep 'xft-fonts) |
518 (if (x-font-xlfd-font-name-p font) | |
519 (x-find-smaller-font-core font device) | |
520 (x-find-smaller-font-xft font device)) | |
521 (x-find-smaller-font-core font device))) | |
522 | |
523 (defun x-find-xft-font-of-size (font new-size-proc &optional device) | |
3360 | 524 (let* ((pattern (fc-font-match (or device (default-x-device)) |
525 (fc-name-parse font)))) | |
3094 | 526 (when pattern |
527 (let ((size (fc-pattern-get-size pattern 0))) | |
528 (if (floatp size) | |
529 (let ((copy (fc-pattern-duplicate pattern))) | |
3354 | 530 (fc-pattern-del-size copy) |
531 (fc-pattern-add-size copy (funcall new-size-proc size)) | |
3094 | 532 (if (fc-try-font font device) |
533 (fc-name-unparse copy)))))))) | |
534 | |
535 (defun x-find-smaller-font-xft (font &optional device) | |
4021 | 536 (x-find-xft-font-of-size font #'(lambda (old-size) (- old-size 1.0)) device)) |
3094 | 537 |
538 (defun x-find-smaller-font-core (font &optional device) | |
428 | 539 (x-frob-font-size font nil device)) |
540 | |
541 (defun x-find-larger-font (font &optional device) | |
542 "Load a new, slightly larger version of the given font (or font name). | |
543 Returns the font if it succeeds, nil otherwise. | |
544 If scalable fonts are available, this returns a font which is 1 point larger. | |
545 Otherwise, it returns the next larger version of this font that is defined." | |
3094 | 546 (if (featurep 'xft-fonts) |
547 (if (x-font-xlfd-font-name-p font) | |
548 (x-find-larger-font-core font device) | |
549 (x-find-larger-font-xft font device)) | |
550 (x-find-larger-font-core font device))) | |
551 | |
552 (defun x-find-larger-font-xft (font &optional device) | |
4021 | 553 (x-find-xft-font-of-size font #'(lambda (old-size) (+ old-size 1.0)) device)) |
3094 | 554 |
555 (defun x-find-larger-font-core (font &optional device) | |
428 | 556 (x-frob-font-size font t device)) |
557 | |
558 (defalias 'x-make-face-bold 'make-face-bold) | |
559 (defalias 'x-make-face-italic 'make-face-italic) | |
560 (defalias 'x-make-face-bold-italic 'make-face-bold-italic) | |
561 (defalias 'x-make-face-unbold 'make-face-unbold) | |
562 (defalias 'x-make-face-unitalic 'make-face-unitalic) | |
563 | |
564 (make-obsolete 'x-make-face-bold 'make-face-bold) | |
565 (make-obsolete 'x-make-face-italic 'make-face-italic) | |
566 (make-obsolete 'x-make-face-bold-italic 'make-face-bold-italic) | |
567 (make-obsolete 'x-make-face-unbold 'make-face-unbold) | |
568 (make-obsolete 'x-make-face-unitalic 'make-face-unitalic) | |
569 | |
570 | |
2527 | 571 |
572 ;; #### - wrong place for this variable? Exactly. We probably want | |
573 ;; `color-list' to be a console method, so `tty-color-list' becomes | |
574 ;; obsolete, and `read-color-completion-table' conses (mapcar #'list | |
575 ;; (color-list)), optionally caching the results. | |
576 | |
577 ;; Ben wanted all of the possibilities from the `configure' script used | |
578 ;; here, but I think this is way too many. I already trimmed the R4 variants | |
579 ;; and a few obvious losers from the list. --Stig | |
580 (defvar x-library-search-path '("/usr/X11R6/lib/X11/" | |
581 "/usr/X11R5/lib/X11/" | |
582 "/usr/lib/X11R6/X11/" | |
583 "/usr/lib/X11R5/X11/" | |
584 "/usr/local/X11R6/lib/X11/" | |
585 "/usr/local/X11R5/lib/X11/" | |
586 "/usr/local/lib/X11R6/X11/" | |
587 "/usr/local/lib/X11R5/X11/" | |
588 "/usr/X11/lib/X11/" | |
589 "/usr/lib/X11/" | |
3125 | 590 "/usr/share/X11/" |
2527 | 591 "/usr/local/lib/X11/" |
3125 | 592 "/usr/local/share/X11/" |
2527 | 593 "/usr/X386/lib/X11/" |
594 "/usr/x386/lib/X11/" | |
595 "/usr/XFree86/lib/X11/" | |
596 "/usr/unsupported/lib/X11/" | |
597 "/usr/athena/lib/X11/" | |
598 "/usr/local/x11r5/lib/X11/" | |
599 "/usr/lpp/Xamples/lib/X11/" | |
600 "/usr/openwin/lib/X11/" | |
601 "/usr/openwin/share/lib/X11/") | |
602 "Search path used by `x-color-list-internal' to find rgb.txt.") | |
603 | |
604 (defvar x-color-list-internal-cache) | |
605 | |
4215 | 606 ;; Ben originally coded this in 2005/01 to return a list of lists each |
607 ;; containing a single string. This is apparently derived from use of | |
608 ;; this list in completion, but in fact `read-color-completion-table' | |
609 ;; already does this wrapping. So I'm changing this to return a list of | |
610 ;; strings as the TTY code does, and as expected by r-c-c-t. | |
611 ;; -- sjt 2007-10-06 | |
612 | |
613 ;; This function is probably also used by the GTK platform. Cf. | |
614 ;; gtk_color_list in src/objects-gtk.c. | |
2527 | 615 (defun x-color-list-internal () |
616 (if (boundp 'x-color-list-internal-cache) | |
617 x-color-list-internal-cache | |
618 (let ((rgb-file (locate-file "rgb.txt" x-library-search-path)) | |
619 clist color p) | |
620 (if (not rgb-file) | |
621 ;; prevents multiple searches for rgb.txt if we can't find it | |
622 (setq x-color-list-internal-cache nil) | |
623 (with-current-buffer (get-buffer-create " *colors*") | |
624 (reset-buffer (current-buffer)) | |
625 (insert-file-contents rgb-file) | |
626 (while (not (eobp)) | |
627 ;; skip over comments | |
628 (while (looking-at "^!") | |
629 (end-of-line) | |
630 (forward-char 1)) | |
631 (skip-chars-forward "0-9 \t") | |
632 (setq p (point)) | |
633 (end-of-line) | |
634 (setq color (buffer-substring p (point)) | |
4215 | 635 clist (cons color clist)) |
2527 | 636 ;; Ugh. If we want to be able to complete the lowercase form |
637 ;; of the color name, we need to add it twice! Yuck. | |
638 (let ((dcase (downcase color))) | |
639 (or (string= dcase color) | |
4215 | 640 (push dcase clist))) |
2527 | 641 (forward-char 1)) |
642 (kill-buffer (current-buffer)))) | |
643 (setq x-color-list-internal-cache clist) | |
644 x-color-list-internal-cache))) | |
645 | |
646 | |
428 | 647 ;;; internal routines |
648 | |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
649 ;;; 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
|
650 ;;; face from the resource database. |
428 | 651 ;;; |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
652 ;;; 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
|
653 ;;; 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
|
654 ;;; 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
|
655 ;;; 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
|
656 ;;; faces on that frame. |
428 | 657 ;;; |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
658 ;;; It's also called from `init-device-faces' and `init-global-faces'. |
428 | 659 ;;; |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
660 ;;; 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
|
661 ;;; 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
|
662 ;;; a crash. |
428 | 663 |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
664 ;; 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
|
665 ;; 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
|
666 ;; (define-specifier-tag 'x-resource) |
3918 | 667 |
428 | 668 (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
|
669 ;; 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
|
670 ;; "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
|
671 ;; 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
|
672 ;; 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
|
673 ;; 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
|
674 ;; environments. |
428 | 675 |
676 ;; 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
|
677 ;; "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
|
678 ;; reasons. (jwz) |
428 | 679 (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
|
680 ;; 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
|
681 ;; 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
|
682 ;; 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
|
683 ;; specifier specs containing the `default' tag in the locale before |
428 | 684 ;; adding new specs. |
685 (tag-set '(default)) | |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
686 ;; 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
|
687 ;; 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
|
688 ;; (default x) and (x) specs. |
428 | 689 (x-tag-set '(x default)) |
690 (tty-tag-set '(tty default)) | |
3918 | 691 (our-tag-set '(x x-resource)) |
428 | 692 (device-class nil) |
693 (face-sym (face-name face)) | |
694 (name (symbol-name face-sym)) | |
695 (fn (x-get-resource-and-maybe-bogosity-check | |
696 (concat name ".attributeFont") | |
697 "Face.AttributeFont" | |
698 'string locale)) | |
699 (fg (x-get-resource-and-maybe-bogosity-check | |
700 (concat name ".attributeForeground") | |
701 "Face.AttributeForeground" | |
702 'string locale)) | |
703 (bg (x-get-resource-and-maybe-bogosity-check | |
704 (concat name ".attributeBackground") | |
705 "Face.AttributeBackground" | |
706 'string locale)) | |
707 (bgp (x-get-resource-and-maybe-bogosity-check | |
708 (concat name ".attributeBackgroundPixmap") | |
709 "Face.AttributeBackgroundPixmap" | |
710 'string locale)) | |
711 (ulp (x-get-resource-and-maybe-bogosity-check | |
712 (concat name ".attributeUnderline") | |
713 "Face.AttributeUnderline" | |
714 'boolean locale)) | |
715 (stp (x-get-resource-and-maybe-bogosity-check | |
716 (concat name ".attributeStrikethru") | |
717 "Face.AttributeStrikethru" | |
718 'boolean locale)) | |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
719 ;; 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
|
720 ;; 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
|
721 ;; 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
|
722 ;; frames. |
428 | 723 (hp (x-get-resource-and-maybe-bogosity-check |
724 (concat name ".attributeHighlight") | |
725 "Face.AttributeHighlight" | |
726 'boolean locale)) | |
727 (dp (x-get-resource-and-maybe-bogosity-check | |
728 (concat name ".attributeDim") | |
729 "Face.AttributeDim" | |
730 'boolean locale)) | |
731 (bp (x-get-resource-and-maybe-bogosity-check | |
732 (concat name ".attributeBlinking") | |
733 "Face.AttributeBlinking" | |
734 'boolean locale)) | |
735 (rp (x-get-resource-and-maybe-bogosity-check | |
736 (concat name ".attributeReverse") | |
737 "Face.AttributeReverse" | |
738 'boolean locale)) | |
739 ) | |
740 | |
741 (cond ((framep locale) | |
742 (setq device-class (device-class (frame-device locale)))) | |
743 ((devicep locale) | |
744 (setq device-class (device-class locale)))) | |
745 | |
746 (if device-class | |
747 (setq tag-set (cons device-class tag-set) | |
748 x-tag-set (cons device-class x-tag-set) | |
3918 | 749 tty-tag-set (cons device-class tty-tag-set) |
750 our-tag-set (cons device-class our-tag-set))) | |
428 | 751 |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
752 ;; 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
|
753 ;; should be defaulted from the global properties. Can't do this for |
428 | 754 ;; frames or devices because then, common resource specs like |
755 ;; "*Foreground: black" will have unwanted effects. | |
756 (if (and (or (eq (face-name face) 'default) | |
757 (eq (face-name face) 'gui-element)) | |
758 (or (null locale) (eq locale 'global))) | |
759 (progn | |
760 (or fn (setq fn (x-get-resource | |
442 | 761 "font" "Font" 'string locale nil 'warn))) |
428 | 762 (or fg (setq fg (x-get-resource |
442 | 763 "foreground" "Foreground" 'string locale nil |
764 'warn))) | |
428 | 765 (or bg (setq bg (x-get-resource |
442 | 766 "background" "Background" 'string locale nil |
767 'warn))))) | |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
768 |
428 | 769 ;; "*cursorColor: foo" is equivalent to setting the background of the |
770 ;; text-cursor face. | |
771 (if (and (eq (face-name face) 'text-cursor) | |
772 (or (null locale) (eq locale 'global))) | |
773 (setq bg (or (x-get-resource | |
442 | 774 "cursorColor" "CursorColor" 'string locale nil 'warn) |
775 bg))) | |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
776 ;; #### 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
|
777 ;; 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
|
778 ;; dealt with. |
428 | 779 (when fn |
780 (if device-class | |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
781 ;; 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
|
782 ;; whether the predumped face was initialized with an 'x tag or not. |
428 | 783 (remove-specifier-specs-matching-tag-set-cdrs (face-font face) |
784 locale | |
785 x-tag-set) | |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
786 ;; 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
|
787 ;; means we should override global defaults for all X device classes. |
428 | 788 (remove-specifier (face-font face) locale x-tag-set nil)) |
3918 | 789 (set-face-font face fn locale our-tag-set append) |
790 | |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
791 ;; 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
|
792 ;; 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
|
793 ;; or Thai. |
3918 | 794 (when (and (specifierp (face-font face)) |
795 (consp (specifier-fallback (face-font face)))) | |
796 (loop | |
797 for (tag-set . instantiator) | |
798 in (specifier-fallback (face-font face)) | |
799 if (memq 'x-coverage-instantiator tag-set) | |
800 do (add-spec-list-to-specifier | |
801 (face-font face) | |
802 (list (cons (or locale 'global) | |
803 (list (cons tag-set instantiator)))) | |
804 append)))) | |
3659 | 805 |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
806 ;; 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
|
807 ;; 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
|
808 ;; up an X frame and then later create a TTY frame. |
428 | 809 (when fg |
810 (if device-class | |
811 (remove-specifier-specs-matching-tag-set-cdrs (face-foreground face) | |
812 locale | |
813 x-tag-set) | |
814 (remove-specifier (face-foreground face) locale x-tag-set nil)) | |
3918 | 815 (set-face-foreground face fg locale our-tag-set append)) |
428 | 816 (when bg |
817 (if device-class | |
818 (remove-specifier-specs-matching-tag-set-cdrs (face-background face) | |
819 locale | |
820 x-tag-set) | |
821 (remove-specifier (face-background face) locale x-tag-set nil)) | |
3918 | 822 (set-face-background face bg locale our-tag-set append)) |
428 | 823 (when bgp |
824 (if device-class | |
825 (remove-specifier-specs-matching-tag-set-cdrs (face-background-pixmap | |
826 face) | |
827 locale | |
828 x-tag-set) | |
829 (remove-specifier (face-background-pixmap face) locale x-tag-set nil)) | |
3918 | 830 (set-face-background-pixmap face bgp locale our-tag-set append)) |
428 | 831 (when ulp |
832 (if device-class | |
833 (remove-specifier-specs-matching-tag-set-cdrs (face-property | |
834 face 'underline) | |
835 locale | |
836 tty-tag-set) | |
837 (remove-specifier (face-property face 'underline) locale | |
838 tty-tag-set nil)) | |
3918 | 839 (set-face-underline-p face ulp locale our-tag-set append)) |
428 | 840 (when stp |
841 (if device-class | |
842 (remove-specifier-specs-matching-tag-set-cdrs (face-property | |
843 face 'strikethru) | |
844 locale | |
845 tty-tag-set) | |
846 (remove-specifier (face-property face 'strikethru) | |
847 locale tty-tag-set nil)) | |
3918 | 848 (set-face-strikethru-p face stp locale our-tag-set append)) |
428 | 849 (when hp |
850 (if device-class | |
851 (remove-specifier-specs-matching-tag-set-cdrs (face-property | |
852 face 'highlight) | |
853 locale | |
854 tty-tag-set) | |
855 (remove-specifier (face-property face 'highlight) | |
856 locale tty-tag-set nil)) | |
3918 | 857 (set-face-highlight-p face hp locale our-tag-set append)) |
428 | 858 (when dp |
859 (if device-class | |
860 (remove-specifier-specs-matching-tag-set-cdrs (face-property | |
861 face 'dim) | |
862 locale | |
863 tty-tag-set) | |
864 (remove-specifier (face-property face 'dim) locale tty-tag-set nil)) | |
3918 | 865 (set-face-dim-p face dp locale our-tag-set append)) |
428 | 866 (when bp |
867 (if device-class | |
868 (remove-specifier-specs-matching-tag-set-cdrs (face-property | |
869 face 'blinking) | |
870 locale | |
871 tty-tag-set) | |
872 (remove-specifier (face-property face 'blinking) locale | |
873 tty-tag-set nil)) | |
3918 | 874 (set-face-blinking-p face bp locale our-tag-set append)) |
428 | 875 (when rp |
876 (if device-class | |
877 (remove-specifier-specs-matching-tag-set-cdrs (face-property | |
878 face 'reverse) | |
879 locale | |
880 tty-tag-set) | |
881 (remove-specifier (face-property face 'reverse) locale | |
882 tty-tag-set nil)) | |
3918 | 883 (set-face-reverse-p face rp locale our-tag-set append)) |
428 | 884 )) |
885 | |
886 ;; GNU Emacs compatibility. (move to obsolete.el?) | |
887 (defalias 'make-face-x-resource-internal 'x-init-face-from-resources) | |
888 | |
889 (defun remove-specifier-specs-matching-tag-set-cdrs (specifier locale tag-set) | |
890 (while tag-set | |
891 (remove-specifier specifier locale tag-set t) | |
892 (setq tag-set (cdr tag-set)))) | |
893 | |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
894 ;;; 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
|
895 ;;; some reasonable fallbacks if nothing else is specified. |
428 | 896 (defun x-init-global-faces () |
4819
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
897 ;; #### 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
|
898 ;; 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
|
899 ;; -- dvl |
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
900 ;; (or (face-foreground 'default 'global) |
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
901 ;; (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
|
902 ;; (or (face-background 'default 'global) |
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
903 ;; (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
|
904 ) |
428 | 905 |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
906 ;;; 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
|
907 ;;; faces on a newly created device. |
428 | 908 (defun x-init-device-faces (device) |
909 ;; 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
|
910 |
872 | 911 ;; (or |
912 ;; (face-font-instance 'default device) | |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
913 |
872 | 914 ;; [[ 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
|
915 |
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
916 ;; #### 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
|
917 ;; 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
|
918 ;; need to put the same checks here as in the fallbacks. These comments |
872 | 919 ;; appear to be pre-19.12. --ben |
428 | 920 |
872 | 921 ;; [[ 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
|
922 ;; 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
|
923 ;; 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
|
924 ;; 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
|
925 ;; file, which seems pretty bogus to me. |
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
926 |
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
927 ;; 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
|
928 ;; 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
|
929 ;; 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
|
930 ;; `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
|
931 ;; probably variable-width. |
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
932 |
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
933 ;; 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
|
934 ;; 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
|
935 ;; 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
|
936 ;; 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
|
937 |
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
938 ;; [[ We default to looking for iso8859 fonts. Using a wildcard for the |
872 | 939 ;; 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
|
940 ;; 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
|
941 ;; 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
|
942 ;; 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
|
943 ;; 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
|
944 ;; 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
|
945 ;; do about it. ]] |
872 | 946 |
4819
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
947 ;; #### 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
|
948 ;; 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
|
949 ;; no need to initialize anything here. -- dvl |
428 | 950 |
4819
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
951 ;; (let ((fg (face-foreground-instance 'default device)) |
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
952 ;; (bg (face-background-instance 'default device))) |
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
953 ;; (if (not (and fg bg)) |
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
954 ;; (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
|
955 ;; (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
|
956 ;; (progn |
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
957 ;; (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
|
958 ;; (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
|
959 ;; (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
|
960 ;; (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
|
961 |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
962 ;; 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
|
963 ;; on a per-frame basis at the appropriate time. |
428 | 964 |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
965 ;; 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
|
966 ;; 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
|
967 ;; 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
|
968 ;; hooks in a safe way. |
428 | 969 (x-init-pointer-shape device) ; from x-mouse.el |
970 ) | |
971 | |
972 ;;; 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
|
973 ;;; 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
|
974 ;;; device-specific initialization. |
428 | 975 (defun x-init-frame-faces (frame) |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
976 ;; 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
|
977 ;; 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
|
978 ;; 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
|
979 ;; modeline didn't so that reverseVideo can be frame-specific. |
428 | 980 |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
981 ;; 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
|
982 ;; default and modeline faces. |
442 | 983 (cond ((car (x-get-resource "reverseVideo" "ReverseVideo" 'boolean frame |
984 nil 'warn)) | |
4819
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
985 ;; #### 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
|
986 ;; 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
|
987 ;; 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
|
988 ;; one.-- dvl |
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
989 |
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
990 ;; (or (face-foreground 'modeline frame) |
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
991 ;; (set-face-foreground 'modeline |
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
992 ;; (face-foreground-instance 'default frame) |
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
993 ;; frame)) |
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
994 ;; (or (face-background 'modeline frame) |
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
995 ;; (set-face-background 'modeline |
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
996 ;; (face-background-instance 'default frame) |
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
997 ;; frame)) |
49480d838d32
Deactivate obsolete x-face initialization cod
Didier Verna <didier@lrde.epita.fr>
parents:
4215
diff
changeset
|
998 |
4822
0482cdb4e35d
Cosmetic changes in x-faces.e
Didier Verna <didier@lrde.epita.fr>
parents:
4819
diff
changeset
|
999 ;; Now invert both of them. If they end up looking the same, |
428 | 1000 ;; make-frame-initial-faces will invert the modeline again later. |
1001 (invert-face 'default frame) | |
1002 (invert-face 'modeline frame) | |
1003 ))) | |
1004 | |
1005 ;;; x-faces.el ends here |