annotate lisp/energize/energize-font-size.el @ 16:0293115a14e9 r19-15b91

Import from CVS: tag r19-15b91
author cvs
date Mon, 13 Aug 2007 08:49:20 +0200
parents 376386a54a3c
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;; interactive adjust font size and face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Copyright (C) 1992-1993 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
17 ;; along with XEmacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
18 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
19 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 (defconst energize-x-modify-font-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 "-\\([^-]+-[^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 "Regexpr to extract or modify font entries")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 (defconst energize-font-families-parameters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 '(("courier" . ("adobe-courier" "o"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ("lucida" . ("b&h-lucida" "i"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ("openwindows" . energize-make-openwindow-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ("helvetica" . ("adobe-helvetica" "o"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ("times" . ("adobe-times" "i"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ("clean" . ("shumacher-clean" "i"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (defun energize-x-set-font-name-entry (font-name entry value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (if (and font-name (string-match energize-x-modify-font-regexp font-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (let ((match (substring font-name (match-beginning entry) (match-end entry))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (concat (substring font-name 0 (match-beginning entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (substring font-name (match-end entry))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 font-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (defun energize-x-set-font-entry (font entry value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (if font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (let* ((font-name (if (stringp font) font (font-name font)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (new-name (energize-x-set-font-name-entry font-name entry value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (if (stringp font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 new-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (make-x-font new-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (defun energize-x-set-face-font-entry (face entry value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 "Sets the face font to be of the specified point size"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (let* ((font (face-font face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (new-font (energize-x-set-font-entry font entry value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (and new-font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (condition-case a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (set-face-font face new-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (error (message (format "%S" a)) (sit-for 0))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (defun energize-set-font-size (size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (interactive "sSet new font size to: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (mapcar '(lambda (face) (energize-x-set-face-font-entry face 7 size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (list-faces)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (defun energize-make-openwindow-font (font-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (string-match energize-x-modify-font-regexp f-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (let ((slant (substring f-name (match-beginning 3) (match-end 3))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (if (member slant '("i" "o"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (substring f-name 0 (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 "b&h-lucida"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (substring f-name (match-end 1) (match-beginning 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 "i"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (substring f-name (match-end 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (let ((new-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (substring f-name 0 (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 "b&h-lucidatypewriter"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (substring f-name (match-end 1) (match-beginning 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 slant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (substring f-name (match-end 3)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; tries the R5 name first and the openwindows name second
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (if (x-list-fonts new-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 new-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (substring f-name 0 (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 "b&h-lucida sans typewriter"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (substring f-name (match-end 1) (match-beginning 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 slant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (substring f-name (match-end 3))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (defun energize-set-font-family (family)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (interactive "sSet new font family to: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (let ((font-desc (cdr (assoc family energize-font-families-parameters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (faces (list-faces)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (if (null font-desc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (error (format "Unknown font family %s, use one of %s" family
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (mapcar 'car energize-font-families-parameters))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (while faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (let* ((face (car faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (font (face-font face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (f-name (and font (font-name font))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (if f-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (if (symbolp font-desc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (setq f-name (funcall font-desc f-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (string-match energize-x-modify-font-regexp f-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (let ((slant (substring f-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (match-beginning 3) (match-end 3))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (if (member slant '("i" "o"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (setq slant (nth 1 font-desc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (setq f-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (substring f-name 0 (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (car font-desc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (substring f-name (match-end 1) (match-beginning 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 slant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (substring f-name (match-end 3))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (set-face-font face f-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (setq faces (cdr faces)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (defun energize-set-font-boldness (bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (interactive "sEnter boldness:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (let* ((default-name (font-name (face-font 'default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (default-boldness
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (and (string-match energize-x-modify-font-regexp default-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (substring default-name (match-beginning 2) (match-end 2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (if (not (equal bold default-boldness))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (let ((faces (list-faces)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (while faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (let* ((face (car faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (font (face-font face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (f-name (and font (font-name font))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (if f-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (string-match energize-x-modify-font-regexp f-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (let ((font-boldness
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (substring f-name (match-beginning 2) (match-end 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (setq new-boldness
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (if (equal font-boldness "bold")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 "medium"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 "bold"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (setq f-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (substring f-name 0 (match-beginning 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 new-boldness
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (substring f-name (match-end 2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (set-face-font face f-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (setq faces (cdr faces)))))))