annotate lisp/energize/energize-font-size.el @ 119:d101af7320b8

Added tag r20-1b11 for changeset 7d55a9ba150c
author cvs
date Mon, 13 Aug 2007 09:24:19 +0200
parents 131b0175ea99
children
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
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
17 ;; along with XEmacs; see the file COPYING. If not, write to the Free
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
18 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 (defconst energize-x-modify-font-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 "-\\([^-]+-[^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)-\\([^-]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 "Regexpr to extract or modify font entries")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 (defconst energize-font-families-parameters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 '(("courier" . ("adobe-courier" "o"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ("lucida" . ("b&h-lucida" "i"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ("openwindows" . energize-make-openwindow-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ("helvetica" . ("adobe-helvetica" "o"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ("times" . ("adobe-times" "i"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ("clean" . ("shumacher-clean" "i"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (defun energize-x-set-font-name-entry (font-name entry value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (if (and font-name (string-match energize-x-modify-font-regexp font-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (let ((match (substring font-name (match-beginning entry) (match-end entry))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (concat (substring font-name 0 (match-beginning entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (substring font-name (match-end entry))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 font-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (defun energize-x-set-font-entry (font entry value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (if font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (let* ((font-name (if (stringp font) font (font-name font)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (new-name (energize-x-set-font-name-entry font-name entry value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (if (stringp font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 new-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (make-x-font new-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (defun energize-x-set-face-font-entry (face entry value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 "Sets the face font to be of the specified point size"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (let* ((font (face-font face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (new-font (energize-x-set-font-entry font entry value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (and new-font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (condition-case a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (set-face-font face new-font)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
55 (error (message "%S" a) (sit-for 0))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (defun energize-set-font-size (size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (interactive "sSet new font size to: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (mapcar '(lambda (face) (energize-x-set-face-font-entry face 7 size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (list-faces)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defun energize-make-openwindow-font (font-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (string-match energize-x-modify-font-regexp f-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (let ((slant (substring f-name (match-beginning 3) (match-end 3))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (if (member slant '("i" "o"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (substring f-name 0 (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 "b&h-lucida"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (substring f-name (match-end 1) (match-beginning 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 "i"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (substring f-name (match-end 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (let ((new-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (substring f-name 0 (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 "b&h-lucidatypewriter"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (substring f-name (match-end 1) (match-beginning 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 slant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (substring f-name (match-end 3)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; tries the R5 name first and the openwindows name second
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (if (x-list-fonts new-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 new-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (substring f-name 0 (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 "b&h-lucida sans typewriter"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (substring f-name (match-end 1) (match-beginning 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 slant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (substring f-name (match-end 3))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (defun energize-set-font-family (family)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (interactive "sSet new font family to: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (let ((font-desc (cdr (assoc family energize-font-families-parameters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (faces (list-faces)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (if (null font-desc)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
94 (error "Unknown font family %s, use one of %s" family
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
95 (mapcar 'car energize-font-families-parameters)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (while faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (let* ((face (car faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (font (face-font face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (f-name (and font (font-name font))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (if f-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (if (symbolp font-desc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (setq f-name (funcall font-desc f-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (string-match energize-x-modify-font-regexp f-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (let ((slant (substring f-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (match-beginning 3) (match-end 3))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (if (member slant '("i" "o"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (setq slant (nth 1 font-desc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (setq f-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (substring f-name 0 (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (car font-desc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (substring f-name (match-end 1) (match-beginning 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 slant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (substring f-name (match-end 3))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (set-face-font face f-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (setq faces (cdr faces)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (defun energize-set-font-boldness (bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (interactive "sEnter boldness:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (let* ((default-name (font-name (face-font 'default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (default-boldness
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (and (string-match energize-x-modify-font-regexp default-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (substring default-name (match-beginning 2) (match-end 2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (if (not (equal bold default-boldness))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (let ((faces (list-faces)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (while faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (let* ((face (car faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (font (face-font face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (f-name (and font (font-name font))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (if f-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (string-match energize-x-modify-font-regexp f-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (let ((font-boldness
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (substring f-name (match-beginning 2) (match-end 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (setq new-boldness
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (if (equal font-boldness "bold")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 "medium"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 "bold"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (setq f-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (substring f-name 0 (match-beginning 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 new-boldness
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (substring f-name (match-end 2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (set-face-font face f-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (setq faces (cdr faces)))))))