annotate lisp/x11/x-font-menu.el @ 30:ec9a17fef872 r19-15b98

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