annotate lisp/font-menu.el @ 5896:2865c4f6fab2

Fix shell syntax error.
author Stephen J. Turnbull <stephen@xemacs.org>
date Tue, 05 May 2015 03:48:07 +0900
parents 4dee0387b9de
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;; font-menu.el --- Managing menus of fonts.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 ;; Copyright (C) 1994 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 ;; Copyright (C) 1997 Sun Microsystems
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; Adapted from x-font-menu.el by Andy Piper <andy@xemacs.org>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 3918
diff changeset
11 ;; XEmacs is free software: you can redistribute it and/or modify it
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 3918
diff changeset
12 ;; under the terms of the GNU General Public License as published by the
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 3918
diff changeset
13 ;; Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 3918
diff changeset
14 ;; option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 3918
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 3918
diff changeset
17 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 3918
diff changeset
18 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 3918
diff changeset
19 ;; for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 3918
diff changeset
22 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;; This file contains the device-nospecific font menu stuff
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 ;;; Creates three menus, "Font", "Size", and "Weight", and puts them on the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 ;;; "Options" menu. The contents of these menus are the superset of those
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 ;;; properties available on any fonts, but only the intersection of the three
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 ;;; sets is selectable at one time.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 ;;; Known Problems:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 ;;; ===============
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 ;;; Items on the Font menu are selectable if and only if that font exists in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 ;;; the same size and weight as the current font. This means that some fonts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 ;;; are simply not reachable from some other fonts - if only one font comes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 ;;; in only one point size (like "Nil", which comes only in 2), you will never
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 ;;; be able to select it. It would be better if the items on the Fonts menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 ;;; were always selectable, and selecting them would set the size to be the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 ;;; closest size to the current font's size.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 ;;;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
43 ;;; This attempts to change all other faces in an analogous way to the change
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 ;;; that was made to the default face; if it can't, it will skip over the face.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 ;;; However, this could leave incongruous font sizes around, which may cause
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 ;;; some nonreversibility problems if further changes are made. Perhaps it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 ;;; should remember the initial fonts of all faces, and derive all subsequent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 ;;; fonts from that initial state.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 ;;; xfontsel(1) is a lot more flexible (but probably harder to understand).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 ;;; The code to construct menus from all of the x11 fonts available from the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 ;;; server is autoloaded and executed the very first time that one of the Font
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 ;;; menus is selected on each device. That is, if XEmacs has frames on two
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 ;;; different devices, then separate font menu information will be maintained
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 ;;; for each X display. If the font path changes after emacs has already
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 ;;; asked the X server on a particular display for its list of fonts, this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 ;;; won't notice. Also, the first time that a font menu is posted on each
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 ;;; display will entail a lengthy delay, but that's better than slowing down
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 ;;; XEmacs startup. At any time (i.e.: after a font-path change or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 ;;; immediately after device creation), you can call
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 ;;; `reset-device-font-menus' to rebuild the menus from all currently
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 ;;; available fonts.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 ;;; There are at least three kinds of fonts under X11r5:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 ;;; - bitmap fonts, which can be assumed to look as good as possible;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 ;;; - bitmap fonts which have been (or can be) automatically scaled to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 ;;; a new size, and which almost always look awful;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 ;;; - and true outline fonts, which should look ok at any size, but in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 ;;; practice (on at least some systems) look awful at any size, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 ;;; even in theory are unlikely ever to look as good as non-scaled
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 ;;; bitmap fonts.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 ;;; It would be nice to get this code to look for non-scaled bitmap fonts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 ;;; first, then outline fonts, then scaled bitmap fonts as a last resort.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 ;;; But it's not clear to me how to tell them apart based on their truenames
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 ;;; and/or the result of XListFonts(). I welcome any and all explanations
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 ;;; of the subtleties involved...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 ;;; If You Think You'Re Seeing A Bug:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 ;;; =================================
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 ;;; When reporting problems, send the following information:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 ;;; - Exactly what behavior you're seeing;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 ;;; - The output of the `xlsfonts' program;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 ;;; - The value of the variable `device-fonts-cache';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 ;;; - The values of the following expressions, both before and after
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 ;;; making a selection from any of the fonts-related menus:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 ;;; (face-font 'default)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 ;;; (font-truename (face-font 'default))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 ;;; (font-properties (face-font 'default))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 ;;; - The values of the following variables after making a selection:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 ;;; font-menu-preferred-resolution
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 ;;; font-menu-registry-encoding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 ;;; There is a common misconception that "*-courier-medium-r-*-11-*", also
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 ;;; known as "-adobe-courier-medium-r-normal--11-80-100-100-m-60-iso8859-1",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 ;;; is an 11-point font. It is not -- it is an 11-pixel font at 100dpi,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 ;;; which is an 8-point font (the number after -11- is the size in tenths
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 ;;; of points). So if you expect to be seeing an "11" entry in the "Size"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 ;;; menu and are not, this may be why.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 ;;; In the real world (aka Solaris), one has to deal with fonts that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 ;;; appear to be medium-i but are really light-r, and fonts that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 ;;; resolve to different resolutions depending on the charset:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 ;;; (font-instance-truename
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 ;;; (make-font-instance "-*-mincho-medium-i-normal-*-*-*-*-*-*-*-jisx0201*-*"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 ;;; ==>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 ;;; "-morisawa-ryumin light kl-light-r-normal--10-100-72-72-m-50-jisx0201.1976-0"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 ;;;
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2297
diff changeset
114 ;;; (font-list "-dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 ;;; ==>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 ;;; ("-dt-interface user-medium-r-normal-s sans-12-120-72-72-m-70-iso8859-1"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 ;;; "-dt-interface user-medium-r-normal-s-14-120-75-75-m-120-jisx0208.1983-0"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 ;;; "-dt-interface user-medium-r-normal-s-14-120-75-75-m-60-jisx0201.1976-0")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 (defcustom font-menu-ignore-scaled-fonts nil
2297
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
122 "*If non-nil, the font menu shows only bitmap fonts.
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
123
5384
3889ef128488 Fix misspelled words, and some grammar, across the entire source tree.
Jerry James <james@xemacs.org>
parents: 3918
diff changeset
124 Bitmap fonts at their design size are generally noticeably higher quality than
2297
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
125 scaled fonts, unless the device is capable of interpreting antialiasing hints.
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
126 In general, setting this option non-`nil' is useful mostly on older X servers.
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
127
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
128 Not all devices make the distinction between bitmap and scaled fonts."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 :group 'font-menu)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 (defcustom font-menu-this-frame-only-p nil
2297
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
134 "*If non-nil, the menu affects the default font only on the selected frame."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 :group 'font-menu)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137
1701
a1e328407366 [xemacs-hg @ 2003-09-20 01:14:24 by youngs]
youngs
parents: 1102
diff changeset
138 (defcustom font-menu-max-number nil
2297
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
139 "The maximum number of fonts retrieved from the display."
1701
a1e328407366 [xemacs-hg @ 2003-09-20 01:14:24 by youngs]
youngs
parents: 1102
diff changeset
140 :type 'integer
a1e328407366 [xemacs-hg @ 2003-09-20 01:14:24 by youngs]
youngs
parents: 1102
diff changeset
141 :group 'font-menu)
a1e328407366 [xemacs-hg @ 2003-09-20 01:14:24 by youngs]
youngs
parents: 1102
diff changeset
142
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 446
diff changeset
143 (defvaralias 'font-menu-max-items 'menu-max-items)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 446
diff changeset
144 (defvaralias 'font-menu-submenu-name-format 'menu-submenu-name-format)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145
2297
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
146 ;; #### Need to update for fontconfig/Xft? Document form for MS Windows.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
147 (defvar font-menu-preferred-resolution
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 (make-specifier-and-init 'generic '((global ((mswindows) . ":")
1102
30118fdc4f1f [xemacs-hg @ 2002-11-12 03:52:23 by stephent]
stephent
parents: 872
diff changeset
149 ((gtk) . "*-*")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 ((x) . "*-*"))) t)
2297
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
151 "Generic specifier containing preferred resolution as a string.
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
152 Do not `setq' this variable; use `set-specifier'.
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
153
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
154 For X11 and GTK devices, the instance value will be interpolated into an
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
155 XLFD, and looks like \"75-75\").")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 (defvar font-menu-size-scaling
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 (make-specifier-and-init 'integer '((global ((mswindows) . 1)
1102
30118fdc4f1f [xemacs-hg @ 2002-11-12 03:52:23 by stephent]
stephent
parents: 872
diff changeset
159 ((gtk) . 10)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 ((x) . 10))) t)
2297
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
161 "Generic specifier containing scale factor for font sizes. Don't touch.
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
162
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
163 This is really a device type constant. Some devices specify size in points
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
164 \(MS Windows), others in decipoints (X11).")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165
2297
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
166 (defvar device-fonts-cache nil
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
167 "Alist mapping devices to font lists and font menus. Don't use this.
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
168
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
169 Instead, use the function `device-fonts-cache' which lazily updates this
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
170 variable, and returns the value for the selected device.
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
171
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
172 Each element has the form (DEVICE . [FONT-LIST FAMILY SIZE WEIGHT]) where
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
173 FAMILY, SIZE, and WEIGHT denote menus.")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 (defsubst device-fonts-cache ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 (or (cdr (assq (selected-device) device-fonts-cache))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 (and (reset-device-font-menus (selected-device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 (cdr (assq (selected-device) device-fonts-cache)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 (fset 'install-font-menus 'reset-device-font-menus)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 (make-obsolete 'install-font-menus 'reset-device-font-menus)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 (defun reset-device-font-menus (&optional device debug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 "Generates the `Font', `Size', and `Weight' submenus for the Options menu.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 This is run the first time that a font-menu is needed for each device.
2297
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
188
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 If you don't like the lazy invocation of this function, you can add it to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 `create-device-hook' and that will make the font menus respond more quickly
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
191 when they are selected for the first time. If you add fonts to your system,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 or if you change your font path, you can call this to re-initialize the menus."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 (if (or noninteractive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 (not (or device (setq device (selected-device)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 nil
2297
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
196 (message "Getting list of fonts from server... ")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 (call-device-method 'reset-device-font-menus device device debug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 (message "Getting list of fonts from server... done.")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 (defun font-menu-family-constructor (ignored)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 (catch 'menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 (unless (console-on-window-system-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 (throw 'menu '(["Cannot parse current font" ding nil])))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 (let* ((dcache (device-fonts-cache))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 (font-data (font-menu-font-data 'default dcache))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 (entry (aref font-data 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 (family (aref font-data 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 (size (aref font-data 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 (weight (aref font-data 3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 (unless family
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 (throw 'menu '(["Cannot parse current font" ding nil])))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 ;; Items on the Font menu are enabled iff that font exists in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 ;; the same size and weight as the current font (scalable fonts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 ;; exist in every size). Only the current font is marked as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 ;; selected.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 446
diff changeset
218 (menu-split-long-menu
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 (mapcar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 (lambda (item)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
221 (setq f (menu-item-strip-accelerator-spec (aref item 0))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 entry (vassoc f (aref dcache 0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 (if (and (or (member weight (aref entry 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 ;; mswindows often allows any weight
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 (member "" (aref entry 1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 (or (member size (aref entry 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 (and (not font-menu-ignore-scaled-fonts)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 (member 0 (aref entry 2)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 (enable-menu-item item)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 (disable-menu-item item))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 (if (string-equal family f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 (select-toggle-menu-item item)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 (deselect-toggle-menu-item item))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 item)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 (aref dcache 1))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 (define-device-method* font-menu-font-data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 (defun font-menu-size-constructor (ignored)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 (catch 'menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 (unless (console-on-window-system-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 (throw 'menu '(["Cannot parse current font" ding nil])))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 (let* ((dcache (device-fonts-cache))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 (font-data (font-menu-font-data 'default dcache))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 (entry (aref font-data 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 (family (aref font-data 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 (size (aref font-data 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 ;;(weight (aref font-data 3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 (unless family
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 (throw 'menu '(["Cannot parse current font" ding nil])))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 ;; Items on the Size menu are enabled iff current font has
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 ;; that size. Only the size of the current font is selected.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 ;; (If the current font comes in size 0, it is scalable, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 ;; thus has every size.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 (mapcar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 (lambda (item)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 (setq s (nth 3 (aref item 1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 (if (or (member s (aref entry 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 (and (not font-menu-ignore-scaled-fonts)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 (member 0 (aref entry 2))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 (enable-menu-item item)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 (disable-menu-item item))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
265 ;; #### God save the Queen!
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
266 ;; well, if this fails because s or size is non-numeric, fuck 'em
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
267 (if (= size (if (featurep 'xft-fonts) (float s) s))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 (select-toggle-menu-item item)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 (deselect-toggle-menu-item item))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 item)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
271 (submenu-generate-accelerator-spec (aref dcache 2))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 (defun font-menu-weight-constructor (ignored)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 (catch 'menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 (unless (console-on-window-system-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 (throw 'menu '(["Cannot parse current font" ding nil])))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 (let* ((dcache (device-fonts-cache))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 (font-data (font-menu-font-data 'default dcache))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 (entry (aref font-data 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 (family (aref font-data 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 ;;(size (aref font-data 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 (weight (aref font-data 3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 (unless family
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 (throw 'menu '(["Cannot parse current font" ding nil])))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 ;; Items on the Weight menu are enabled iff current font
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 ;; has that weight. Only the weight of the current font
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 ;; is selected.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 (mapcar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 (lambda (item)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 (setq w (aref item 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 (if (member w (aref entry 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 (enable-menu-item item)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 (disable-menu-item item))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 (if (string-equal weight w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 (select-toggle-menu-item item)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 (deselect-toggle-menu-item item))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 item)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
300 (submenu-generate-accelerator-spec (aref dcache 3))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 ;;; Changing font sizes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 (defun font-menu-set-font (family weight size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 ;; This is what gets run when an item is selected from any of the three
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 ;; fonts menus. It needs to be rather clever.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 ;; (size is measured in 10ths of points.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 (let* ((dcache (device-fonts-cache))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 (font-data (font-menu-font-data 'default dcache))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 (from-family (aref font-data 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 (from-size (aref font-data 2))
1102
30118fdc4f1f [xemacs-hg @ 2002-11-12 03:52:23 by stephent]
stephent
parents: 872
diff changeset
313 (from-weight (aref font-data 3))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 (from-slant (aref font-data 4))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
315 (face-list-to-change (delq 'default (face-list)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
316 new-default-face-font)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 (unless from-family
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 (signal 'error '("couldn't parse font name for default face")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 (when weight
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 (signal 'error '("Setting weight currently not supported")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 (setq new-default-face-font
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
322 (font-instance-name
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
323 (font-menu-load-font
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
324 (or family from-family)
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
325 (or weight from-weight)
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
326 (or size from-size)
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
327 from-slant
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
328 (specifier-instance
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
329 font-menu-preferred-resolution (selected-device)))))
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
330 ;; #### This is such a gross hack. The border-glyph face under
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 ;; mswindows is in a symbol font. Thus it will not appear in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 ;; cache - being a junk family. What we should do is change the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 ;; size but not the family, but this is more work than I care to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 ;; invest at the moment.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 (when (eq (device-type) 'mswindows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 (setq face-list-to-change
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 (delq 'border-glyph face-list-to-change)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 (dolist (face face-list-to-change)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 (when (face-font-instance face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 (message "Changing font of `%s'..." face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 (condition-case c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 (font-menu-change-face face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 from-family from-weight from-size
1102
30118fdc4f1f [xemacs-hg @ 2002-11-12 03:52:23 by stephent]
stephent
parents: 872
diff changeset
344 (or family from-family)
30118fdc4f1f [xemacs-hg @ 2002-11-12 03:52:23 by stephent]
stephent
parents: 872
diff changeset
345 (or weight from-weight)
30118fdc4f1f [xemacs-hg @ 2002-11-12 03:52:23 by stephent]
stephent
parents: 872
diff changeset
346 (or size from-size))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 (error
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
348 (message "Error updating font of `%s'" face)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 (display-error c nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 (sit-for 1)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 ;; Set the default face's font after hacking the other faces, so that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 ;; the frame size doesn't change until we are all done.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 ;; If we need to be frame local we do the changes ourselves.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 (if font-menu-this-frame-only-p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 ;;; WMP - we need to honor font-menu-this-frame-only-p here!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 (set-face-font 'default new-default-face-font
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 (and font-menu-this-frame-only-p (selected-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 ;; OK Let Customize do it.
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
360 (let ((fsize (if (featurep 'xft-fonts)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
361 (int-to-string (or size from-size))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
362 (concat (int-to-string
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
363 (/ (or size from-size)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
364 (specifier-instance font-menu-size-scaling
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
365 (selected-device))))
3918
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
366 "pt")))
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
367 new-spec-list)
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
368 ;; If the font was initialised from X resources (the tag-set
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
369 ;; contains 'x-resource) pretend to Custom that it has
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
370 ;; responsibility for those settings.
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
371 (map-specifier (face-font 'default)
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
372 (lambda (spec locale inst-list arg)
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
373 (loop
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
374 for (tag-set . inst)
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
375 in inst-list
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
376 do (setq tag-set (delq 'x-resource tag-set)
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
377 tag-set (delq 'custom tag-set)
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
378 tag-set (cons 'custom tag-set))
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
379 (push (cons tag-set inst) new-spec-list)
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
380 ;; Need to return nil, else map-specifier stops
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
381 finally return nil))
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
382 nil nil '(x-resource))
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
383 (remove-specifier (face-font 'default) nil '(x-resource))
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
384 (when new-spec-list
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
385 (add-spec-list-to-specifier (face-font 'default)
049dc907c17a [xemacs-hg @ 2007-04-22 19:58:27 by aidan]
aidan
parents: 3094
diff changeset
386 (list (cons 'global new-spec-list))))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
387 (custom-set-face-update-spec 'default
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
388 (list (list 'type (device-type)))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
389 (list :family (or family from-family)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
390 :size fsize))))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
391 (message "Font %s" (face-font-name 'default))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392
2297
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
393 ;; #### This should be called `font-menu-maybe-change-face'
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
394 ;; I wonder if a better API wouldn't (face attribute from to)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 (defun font-menu-change-face (face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 from-family from-weight from-size
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 to-family to-weight to-size)
2297
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
398 "Maybe update the font of FACE per TO-FAMILY, TO-WEIGHT, and TO-SIZE."
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
399 (check-type face symbol)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 (let* ((dcache (device-fonts-cache))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 (font-data (font-menu-font-data face dcache))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 (face-family (aref font-data 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 (face-size (aref font-data 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 (face-weight (aref font-data 3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 (face-slant (aref font-data 4)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406
2297
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
407 (or face-family
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1701
diff changeset
408 (signal 'error (list "couldn't parse font name for face" face)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 ;; If this face matches the old default face in the attribute we
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 ;; are changing, then change it to the new attribute along that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 ;; dimension. Also, the face must have its own global attribute.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 ;; If its value is inherited, we don't touch it. If any of this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 ;; is not true, we leave it alone.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 (when (and (face-font face 'global)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
416 (cond
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 (to-family (string-equal face-family from-family))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 (to-weight (string-equal face-weight from-weight))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 (to-size (= face-size from-size))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 (set-face-font face
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
421 (font-instance-name
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
422 (font-menu-load-font (or to-family face-family)
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
423 (or to-weight face-weight)
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
424 (or to-size face-size)
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
425 face-slant
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
426 (specifier-instance
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
427 font-menu-preferred-resolution
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
428 (selected-device))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 (and font-menu-this-frame-only-p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 (selected-frame))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 (define-device-method font-menu-load-font)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 (defun flush-device-fonts-cache (device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 ;; by Stig@hackvan.com
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 (let ((elt (assq device device-fonts-cache)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 (and elt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 (setq device-fonts-cache (delq elt device-fonts-cache)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 (add-hook 'delete-device-hook 'flush-device-fonts-cache)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 (provide 'font-menu)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 ;; font-menu ends here