annotate lisp/x-font-menu.el @ 249:83b3d10dcba9 r20-5b23

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