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