annotate lisp/x11/x-font-menu.el @ 82:6a378aca36af r20-0b91

Import from CVS: tag r20-0b91
author cvs
date Mon, 13 Aug 2007 09:07:36 +0200
parents c0c698873ce1
children 364816949b59
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;; x-font-menu.el --- Managing menus of X fonts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Author: Jamie Zawinski <jwz@lucid.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Restructured by: Jonathan Stigelman <Stig@hackvan.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
23 ;; Free Software Foundation, 59 Temple Place - Suite 330,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
24 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Creates three menus, "Font", "Size", and "Weight", and puts them on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; "Options" menu. The contents of these menus are the superset of those
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; properties available on any fonts, but only the intersection of the three
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; sets is selectable at one time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; Known Problems:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; ===============
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; Items on the Font menu are selectable if and only if that font exists in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; the same size and weight as the current font. This means that some fonts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;; are simply not reachable from some other fonts - if only one font comes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;; in only one point size (like "Nil", which comes only in 2), you will never
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; be able to select it. It would be better if the items on the Fonts menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;; were always selectable, and selecting them would set the size to be the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;; closest size to the current font's size.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;; This attempts to change all other faces in an analagous way to the change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;; that was made to the default face; if it can't, it will skip over the face.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;; However, this could leave incongruous font sizes around, which may cause
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;; some nonreversibility problems if further changes are made. Perhaps it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; should remember the initial fonts of all faces, and derive all subsequent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;; fonts from that initial state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;; xfontsel(1) is a lot more flexible (but probably harder to understand).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;; The code to construct menus from all of the x11 fonts available from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;; server is autoloaded and executed the very first time that one of the Font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;; menus is selected on each device. That is, if XEmacs has frames on two
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;; different devices, then separate font menu information will be maintained
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;; for each X display. If the font path changes after emacs has already
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;; asked the X server on a particular display for its list of fonts, this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;; won't notice. Also, the first time that a font menu is posted on each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;; display will entail a lengthy delay, but that's better than slowing down
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; XEmacs startup. At any time (i.e.: after a font-path change or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;; immediately after device creation), you can call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;; `reset-device-font-menus' to rebuild the menus from all currently
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;; available fonts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;; There is knowledge here about the regexp match numbers in `x-font-regexp',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;; `x-font-regexp-foundry-and-family', and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;; `x-font-regexp-registry-and-encoding' defined in x-faces.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; There are at least three kinds of fonts under X11r5:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;;; - bitmap fonts, which can be assumed to look as good as possible;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;; - bitmap fonts which have been (or can be) automatically scaled to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;; a new size, and which almost always look awful;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
74 ;;; - and true outline fonts, which should look ok at any size, but in
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;; practice (on at least some systems) look awful at any size, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;;; even in theory are unlikely ever to look as good as non-scaled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;;; bitmap fonts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;; It would be nice to get this code to look for non-scaled bitmap fonts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;;; first, then outline fonts, then scaled bitmap fonts as a last resort.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;;; But it's not clear to me how to tell them apart based on their truenames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;;; and/or the result of XListFonts(). I welcome any and all explanations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;; of the subtleties involved...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;;; If You Think You'Re Seeing A Bug:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;; =================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;; When reporting problems, send the following information:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;; - Exactly what behavior you're seeing;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;;; - The output of the `xlsfonts' program;
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
92 ;;; - The value of the variable `device-fonts-cache';
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;;; - The values of the following expressions, both before and after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;; making a selection from any of the fonts-related menus:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;; (face-font 'default)
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
96 ;;; (font-truename (face-font 'default))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
97 ;;; (font-properties (face-font 'default))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; - The values of the following variables after making a selection:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;; font-menu-preferred-resolution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;; font-menu-preferred-registry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;; There is a common misconception that "*-courier-medium-r-*-11-*", also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;; known as "-adobe-courier-medium-r-normal--11-80-100-100-m-60-iso8859-1",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;; is an 11-point font. It is not -- it is an 11-pixel font at 100dpi,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;;; which is an 8-point font (the number after -11- is the size in tenths
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;; of points). So if you expect to be seeing an "11" entry in the "Size"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;; menu and are not, this may be why.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;; #### - implement these...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;;; (defvar font-menu-ignore-proportional-fonts nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;;; "*If non-nil, then the font menu will only show fixed-width fonts.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (defvar font-menu-ignore-scaled-fonts t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 "*If non-nil, then the font menu will try to show only bitmap fonts.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;;;###autoload
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
121 (defvar font-menu-this-frame-only-p nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 "*If non-nil, then changing the default font from the font menu will only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 affect one frame instead of all frames.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; only call XListFonts (and parse) once per device.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;; ( (device . [parsed-list-fonts family-menu size-menu weight-menu]) ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (defvar device-fonts-cache nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (defconst font-menu-preferred-registry nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (defconst font-menu-preferred-resolution nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (defconst fonts-menu-junk-families
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 #'identity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 '("cursor" "glyph" "symbol" ; Obvious losers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 "\\`Ax...\\'" ; FrameMaker fonts - there are just way too
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ; many of these, and there is a different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ; font family for each font face! Losers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ; "Axcor" -> "Applix Courier Roman",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ; "Axcob" -> "Applix Courier Bold", etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 "\\|"))
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
144 "A regexp matching font families which are uninteresting (e.g. cursor fonts).")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (defun hack-font-truename (fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 "Filter the output of `font-instance-truename' to deal with Japanese fontsets."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (if (string-match "," (font-instance-truename fn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (let ((fpnt (nth 8 (split-string (font-instance-name fn) "-")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (flist (split-string (font-instance-truename fn) ","))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ret)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (while flist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (if (string-equal fpnt (nth 8 (split-string (car flist) "-")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (progn (setq ret (car flist)) (setq flist nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (setq flist (cdr flist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ret)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (font-instance-truename fn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (fset 'install-font-menus 'reset-device-font-menus)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (make-obsolete 'install-font-menus 'reset-device-font-menus)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (defvar x-font-regexp-ja nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 "This is used to filter out fonts that don't work in the locale.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 It must be set at run-time.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (defun vassoc (key valist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 "Search VALIST for a vector whose first element is equal to KEY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 See also `assoc'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (let (el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (catch 'done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (while (setq el (pop valist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (and (equal key (aref el 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (throw 'done el))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (defun reset-device-font-menus (&optional device debug)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 "Generates the `Font', `Size', and `Weight' submenus for the Options menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 This is run the first time that a font-menu is needed for each device.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 If you don't like the lazy invocation of this function, you can add it to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 `create-device-hook' and that will make the font menus respond more quickly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 when they are selected for the first time. If you add fonts to your system,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 or if you change your font path, you can call this to re-initialize the menus."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;; #### - this should implement a `menus-only' option, which would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;; recalculate the menus from the cache w/o having to do list-fonts again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (message "Getting list of fonts from server... ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (if (or noninteractive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (not (or device (setq device (selected-device))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (not (eq (device-type device) 'x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (if (and (getenv "LANG")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (string-match "^\\(ja\\|japanese\\)$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (getenv "LANG")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;; #### - this is questionable behavior left over from the I18N4 code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (setq x-font-regexp-ja "jisx[^-]*-[^-]*$"
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
199 font-menu-preferred-registry '("*" . "*")
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
200 font-menu-preferred-resolution '("*" . "*")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (let ((all-fonts nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 name family size weight entry monospaced-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 dev-cache
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (cache nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (families nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (sizes nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (weights nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (cond ((stringp debug) ; kludge
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (setq all-fonts (split-string debug "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (setq all-fonts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (or debug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (list-fonts "*-*-*-*-*-*-*-*-*-*-*-*-*-*" device)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (while (setq name (pop all-fonts))
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
216 (when (and (or (not x-font-regexp-ja)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
217 (string-match x-font-regexp-ja name))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
218 (string-match x-font-regexp name))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
219 (setq weight (capitalize (match-string 1 name))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
220 size (string-to-int (match-string 6 name)))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
221 (or (string-match x-font-regexp-foundry-and-family name)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
222 (error "internal error"))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
223 (setq family (capitalize (match-string 1 name)))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
224 (or (string-match x-font-regexp-spacing name)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
225 (error "internal error"))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
226 (setq monospaced-p (string= "m" (match-string 1 name)))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
227 (unless (string-match fonts-menu-junk-families family)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
228 (setq entry (or (vassoc family cache)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
229 (car (setq cache
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
230 (cons (vector family nil nil t)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
231 cache)))))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
232 (or (member family families)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
233 (setq families (cons family families)))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
234 (or (member weight weights)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
235 (setq weights (cons weight weights)))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
236 (or (member weight (aref entry 1))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
237 (aset entry 1 (cons weight (aref entry 1))))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
238 (or (member size sizes)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
239 (setq sizes (cons size sizes)))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
240 (or (member size (aref entry 2))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
241 (aset entry 2 (cons size (aref entry 2))))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
242 (aset entry 3 (and (aref entry 3) monospaced-p))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
243 )))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;; Hack scalable fonts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;; Some fonts come only in scalable versions (the only size is 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ;; and some fonts come in both scalable and non-scalable versions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ;; (one size is 0). If there are any scalable fonts at all, make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 ;; sure that the union of all point sizes contains at least some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ;; common sizes - it's possible that some sensible sizes might end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ;; up not getting mentioned explicitly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (if (member 0 sizes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (let ((common '(60 80 100 120 140 160 180 240)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (while common
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (or;;(member (car common) sizes) ; not enough slack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (let ((rest sizes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (done nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (while (and (not done) rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (if (and (> (car common) (- (car rest) 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (< (car common) (+ (car rest) 5)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (setq done t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (setq rest (cdr rest)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 done)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (setq sizes (cons (car common) sizes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (setq common (cdr common)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (setq sizes (delq 0 sizes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (setq families (sort families 'string-lessp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 weights (sort weights 'string-lessp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 sizes (sort sizes '<))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (let ((rest cache))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (while rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (aset (car rest) 1 (sort (aref (car rest) 1) 'string-lessp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (aset (car rest) 2 (sort (aref (car rest) 2) '<))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (setq rest (cdr rest))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (message "Getting list of fonts from server... done.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (setq dev-cache (assq device device-fonts-cache))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (or dev-cache
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (setq dev-cache (car (push (list device) device-fonts-cache))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (setcdr dev-cache
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 cache
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (mapcar #'(lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (vector x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (list 'font-menu-set-font x nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ':style 'radio ':active nil ':selected nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 families)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (mapcar #'(lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (vector (if (/= 0 (% x 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ;; works with no LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (concat (int-to-string (/ x 10)) "."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (int-to-string (% x 10)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (int-to-string (/ x 10)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (list 'font-menu-set-font nil nil x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ':style 'radio ':active nil ':selected nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 sizes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (mapcar #'(lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (vector x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (list 'font-menu-set-font nil x nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ':style 'radio ':active nil ':selected nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 weights)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (cdr dev-cache))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
308 (defsubst font-menu-truename (face)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
309 (hack-font-truename
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
310 (if (featurep 'mule)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
311 (face-font-instance face nil 'ascii)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
312 (face-font-instance face))))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
313
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
314 ;;; Extract a font family from a face.
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
315 ;;; Use the user-specified one if possible.
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
316 ;;; If the user didn't specify one (with "*", for example)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
317 ;;; get the truename and use the guaranteed family from that.
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
318 (defun font-menu-family (face)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
319 (let ((dcache (cdr (assq (selected-device) device-fonts-cache)))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
320 (name (font-instance-name (face-font-instance face)))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
321 (family nil))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
322 (when (string-match x-font-regexp-foundry-and-family name)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
323 (setq family (capitalize (match-string 1 name))))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
324 (when (not (and family (vassoc family (aref dcache 0))))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
325 (setq name (font-menu-truename face))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
326 (string-match x-font-regexp-foundry-and-family name)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
327 (setq family (capitalize (match-string 1 name))))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
328 family))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
329
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (defun font-menu-family-constructor (ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (if (not (eq 'x (device-type (selected-device))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 '(["Cannot parse current font" ding nil])
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
335 (let* ((dcache (cdr (assq (selected-device) device-fonts-cache)))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
336 (name (font-menu-truename 'default))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
337 (case-fold-search t)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
338 family weight size ; parsed from current font
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
339 entry ; font cache entry
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
340 f)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (or dcache
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (setq dcache (reset-device-font-menus (selected-device))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (if (not (string-match x-font-regexp name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ;; couldn't parse current font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 '(["Cannot parse current font" ding nil])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (setq weight (capitalize (match-string 1 name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (setq size (string-to-number (match-string 6 name)))
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
348 (setq family (font-menu-family 'default))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (setq entry (vassoc family (aref dcache 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (mapcar #'(lambda (item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 ;; Items on the Font menu are enabled iff that font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 ;; exists in the same size and weight as the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 ;; font (scalable fonts exist in every size). Only the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 ;; current font is marked as selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (setq f (aref item 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 entry (vassoc f (aref dcache 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (if (and (member weight (aref entry 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (or (member size (aref entry 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (and (not font-menu-ignore-scaled-fonts)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (member 0 (aref entry 2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (enable-menu-item item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (disable-menu-item item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (if (equal family f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (select-toggle-menu-item item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (deselect-toggle-menu-item item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (aref dcache 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (defun font-menu-size-constructor (ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (if (not (eq 'x (device-type (selected-device))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 '(["Cannot parse current font" ding nil])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (let ((dcache (cdr (assq (selected-device) device-fonts-cache)))
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
378 (name (font-menu-truename 'default))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 family size ; parsed from current font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 entry ; font cache entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (or dcache
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (setq dcache (reset-device-font-menus (selected-device))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (if (not (string-match x-font-regexp name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 ;; couldn't parse current font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 '(["Cannot parse current font" ding nil])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (setq size (string-to-number (match-string 6 name)))
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
389 (setq family (font-menu-family 'default))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (setq entry (vassoc family (aref dcache 0)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
391 (mapcar
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
392 (lambda (item)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
393 ;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
394 ;; Items on the Size menu are enabled iff current font has
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
395 ;; that size. Only the size of the current font is
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
396 ;; selected. (If the current font comes in size 0, it is
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
397 ;; scalable, and thus has every size.)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
398 ;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
399 (setq s (nth 3 (aref item 1)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
400 (if (or (member s (aref entry 2))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
401 (and (not font-menu-ignore-scaled-fonts)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
402 (member 0 (aref entry 2))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
403 (enable-menu-item item)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
404 (disable-menu-item item))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
405 (if (eq size s)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
406 (select-toggle-menu-item item)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
407 (deselect-toggle-menu-item item))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
408 item)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
409 (aref dcache 2)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (defun font-menu-weight-constructor (ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (if (not (eq 'x (device-type (selected-device))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 '(["Cannot parse current font" ding nil])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (let ((dcache (cdr (assq (selected-device) device-fonts-cache)))
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
418 (name (font-menu-truename 'default))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 family weight ; parsed from current font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 entry ; font cache entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (or dcache
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (setq dcache (reset-device-font-menus (selected-device))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (if (not (string-match x-font-regexp name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 ;; couldn't parse current font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 '(["Cannot parse current font" ding nil])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (setq weight (capitalize (match-string 1 name)))
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
429 (setq family (font-menu-family 'default))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (setq entry (vassoc family (aref dcache 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (mapcar #'(lambda (item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 ;; Items on the Weight menu are enabled iff current font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 ;; has that weight. Only the weight of the current font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ;; is selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (setq w (aref item 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (if (member w (aref entry 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (enable-menu-item item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (disable-menu-item item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (if (equal weight w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (select-toggle-menu-item item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (deselect-toggle-menu-item item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (aref dcache 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ;;; Changing font sizes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (defun font-menu-set-font (family weight size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 ;; This is what gets run when an item is selected from any of the three
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ;; fonts menus. It needs to be rather clever.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 ;; (size is measured in 10ths of points.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (let ((faces (delq 'default (face-list)))
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
454 (default-name (font-menu-truename 'default))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 new-default-face-font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 from-family from-weight from-size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 ;; First, parse out the default face's font.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 ;;
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
461 (setq from-family (font-menu-family 'default))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (or (string-match x-font-regexp default-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (signal 'error (list "couldn't parse font name" default-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (setq from-weight (capitalize (match-string 1 default-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (setq from-size (match-string 6 default-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (setq new-default-face-font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (font-menu-load-font (or family from-family)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (or weight from-weight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (or size from-size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 default-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (while faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (cond ((face-font-instance (car faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (message "Changing font of `%s'..." (car faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (condition-case c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (font-menu-change-face (car faces)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 from-family from-weight from-size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 family weight size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (display-error c nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (sit-for 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (setq faces (cdr faces)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;; Set the default face's font after hacking the other faces, so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 ;; the frame size doesn't change until we are all done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 ;;; WMP - we need to honor font-menu-this-frame-only-p here!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (set-face-font 'default new-default-face-font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (and font-menu-this-frame-only-p (selected-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (message "Font %s" (face-font-name 'default))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (defun font-menu-change-face (face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 from-family from-weight from-size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 to-family to-weight to-size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (or (symbolp face) (signal 'wrong-type-argument (list 'symbolp face)))
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
495 (let* ((name (font-menu-truename face))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 face-family
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 face-weight
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 face-size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ;; First, parse out the face's font.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (or (string-match x-font-regexp-foundry-and-family name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (signal 'error (list "couldn't parse font name" name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (setq face-family (capitalize (match-string 1 name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (or (string-match x-font-regexp name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (signal 'error (list "couldn't parse font name" name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (setq face-weight (match-string 1 name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (setq face-size (match-string 6 name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 ;; If this face matches the old default face in the attribute we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 ;; are changing, then change it to the new attribute along that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 ;; dimension. Also, the face must have its own global attribute.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 ;; If its value is inherited, we don't touch it. If any of this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 ;; is not true, we leave it alone.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (if (and (face-font face 'global)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (to-family (equal face-family from-family))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (to-weight (equal face-weight from-weight))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (to-size (equal face-size from-size))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (set-face-font face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (font-menu-load-font (or to-family face-family)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (or to-weight face-weight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (or to-size face-size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (and font-menu-this-frame-only-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (selected-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (defun font-menu-load-font (family weight size from-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (and (numberp size) (setq size (int-to-string size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 slant other-slant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 registry encoding resx resy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (or (string-match x-font-regexp-registry-and-encoding from-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (signal 'error (list "couldn't parse font name" from-font)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (setq registry (match-string 1 from-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 encoding (match-string 2 from-font))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (or (string-match x-font-regexp from-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (signal 'error (list "couldn't parse font name" from-font)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (setq slant (capitalize (match-string 2 from-font))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 resx (match-string 7 from-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 resy (match-string 8 from-font))
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
544 (setq other-slant (cond ((equal slant "O") "I") ; oh, bite me.
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
545 ((equal slant "I") "O")
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 76
diff changeset
546 (t nil)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 ;; Remember these values for the first font we switch away from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 ;; (the original default font).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (or font-menu-preferred-resolution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (setq font-menu-preferred-resolution (cons resx resy)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (or font-menu-preferred-registry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (setq font-menu-preferred-registry (cons registry encoding)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 ;; Now we know all the interesting properties of the font we want.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 ;; Let's see what we can actually *get*.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (or ;; First try the default resolution, registry, and encoding.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (make-font-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (concat "-*-" family "-" weight "-" slant "-*-*-*-" size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 "-" (car font-menu-preferred-resolution)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 "-" (cdr font-menu-preferred-resolution)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 "-*-*-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (car font-menu-preferred-registry) "-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (cdr font-menu-preferred-registry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ;; Then try that in the other slant.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (and other-slant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (make-font-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (concat "-*-" family "-" weight "-" other-slant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 "-*-*-*-" size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 "-" (car font-menu-preferred-resolution)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 "-" (cdr font-menu-preferred-resolution)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 "-*-*-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (car font-menu-preferred-registry) "-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (cdr font-menu-preferred-registry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 ;; Then try the default resolution and registry, any encoding.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (make-font-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (concat "-*-" family "-" weight "-" slant "-*-*-*-" size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 "-" (car font-menu-preferred-resolution)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 "-" (cdr font-menu-preferred-resolution)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 "-*-*-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (car font-menu-preferred-registry) "-*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 ;; Then try that in the other slant.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (and other-slant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (make-font-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (concat "-*-" family "-" weight "-" other-slant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 "-*-*-*-" size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 "-" (car font-menu-preferred-resolution)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 "-" (cdr font-menu-preferred-resolution)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 "-*-*-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (car font-menu-preferred-registry) "-*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 ;; Then try the default registry and encoding, any resolution.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (make-font-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (concat "-*-" family "-" weight "-" slant "-*-*-*-" size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 "-*-*-*-*-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (car font-menu-preferred-registry) "-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (cdr font-menu-preferred-registry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 ;; Then try that in the other slant.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (and other-slant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (make-font-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (concat "-*-" family "-" weight "-" other-slant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 "-*-*-*-" size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 "-*-*-*-*-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (car font-menu-preferred-registry) "-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (cdr font-menu-preferred-registry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 ;; Then try the default registry, any encoding or resolution.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (make-font-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (concat "-*-" family "-" weight "-" slant "-*-*-*-" size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 "-*-*-*-*-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (car font-menu-preferred-registry) "-*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 ;; Then try that in the other slant.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (and other-slant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (make-font-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (concat "-*-" family "-" weight "-" slant "-*-*-*-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 size "-*-*-*-*-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (car font-menu-preferred-registry) "-*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 ;; Then try anything in the same slant, and error if it fails...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (and other-slant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (make-font-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (concat "-*-" family "-" weight "-" slant "-*-*-*-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 size "-*-*-*-*-*-*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (make-font-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (concat "-*-" family "-" weight "-" (or other-slant slant)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 "-*-*-*-" size "-*-*-*-*-*-*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (defun flush-device-fonts-cache (device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (let ((elt (assq device device-fonts-cache)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (and elt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (setq device-fonts-cache (delq elt device-fonts-cache)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (add-hook 'delete-device-hook 'flush-device-fonts-cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (provide 'x-font-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 ;;; x-font-menu.el ends here