annotate lisp/packages/lispm-fonts.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
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 ;;; lispm-fonts.el --- quick hack to parse LISPM-style font-shift codes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Keywords: faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Copyright (C) 1992-1993 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; 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
20 ;; along with XEmacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
22 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; This only copes with MIT/LMI/TI style font shifts, not Symbolics.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; It doesn't do diagram lines (ha ha). It doesn't do output. That
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; has to wait until it is possible to attach faces to characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; instead of just intervals, since this code is really talking about
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; attributes of the text instead of attributes of regions of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; buffer. We could do it by mapping over the extents and hacking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; the overlaps by hand, but that would be hard.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (make-face 'variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (or (face-differs-from-default-p 'variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (set-face-font 'variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 "-*-helvetica-medium-r-*-*-*-120-*-*-*-*-*-*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (make-face 'variable-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (or (face-differs-from-default-p 'variable-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; This is no good because helvetica-12-bold is a LOT larger than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; helvetica-12-medium. Someone really blew it there.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; (copy-face 'variable 'variable-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; (make-face-bold 'variable-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (set-face-font 'variable-bold
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 "-*-helvetica-bold-r-*-*-*-100-*-*-*-*-*-*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (make-face 'variable-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (or (face-differs-from-default-p 'variable-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (copy-face 'variable-bold 'variable-italic) ; see above
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (make-face-unbold 'variable-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (make-face-italic 'variable-italic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (make-face 'variable-bold-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (or (face-differs-from-default-p 'variable-bold-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (copy-face 'variable-bold 'variable-bold-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (make-face-italic 'variable-bold-italic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defconst lispm-font-to-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 '(("tvfont" . default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ("cptfont" . default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ("cptfontb" . bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ("cptfonti" . italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ("cptfontbi" . bold-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ("base-font" . default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ("bigfnt" . bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ("cmb8" . variable-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ("higher-medfnb" . bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ("higher-tr8" . default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ("medfnb" . bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ("medfnt" . normal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ("medfntb" . bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ("wider-font" . bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ("wider-medfnt" . bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ("mets" . variable-large)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ("metsb" . variable-large-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ("metsbi" . variable-large-bold-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ("metsi" . variable-large-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ("cmr5" . variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ("cmr10" . variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ("cmr18" . variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ("cmold" . variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ("cmdunh" . variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ("hl10" . variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ("hl10b" . variable-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ("hl12" . variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ("hl12b" . variable-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ("hl12bi" . variable-bold-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ("hl12i" . variable-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ("hl6" . variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ("hl7" . variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ("tr10" . variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ("tr10b" . variable-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ("tr10bi" . variable-bold-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ("tr10i" . variable-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ("tr12" . variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ("tr12b" . variable-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ("tr12bi" . variable-bold-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ("tr12i" . variable-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ("tr18" . variable-large)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ("tr18b" . variable-large-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ("tr8" . variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ("tr8b" . variable-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ("tr8i" . variable-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ("5x5" . small)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ("tiny" . small)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ("43vxms" . variable-large)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ("courier" . bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ("adobe-courier10" . default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ("adobe-courier14" . bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ("adobe-courier10b" . bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ("adobe-courier14b" . bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ("adobe-hl12" . variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ("adobe-hl14" . variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ("adobe-hl14b" . variable-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 "Alist of LISPM font names to Emacs face names.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (defun lispm-font-to-face (lispm-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (if (symbolp lispm-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (setq lispm-font (symbol-name lispm-font)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (setq lispm-font (downcase lispm-font))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (if (string-match "^fonts:+" lispm-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (setq lispm-font (substring lispm-font (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (if (setq face (cdr (assoc lispm-font lispm-font-to-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (if (find-face face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (message "warning: unknown face %s" face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 'default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (message "warning: unknown Lispm font %s" (upcase lispm-font))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 'default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (defvar fonts) ; the -*- line of the file will set this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (defun lispm-fontify-hack-local-variables ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;; Sometimes code has font-shifts in the -*- line, which means that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;; local variables will have been read incorrectly by the emacs-lisp reader.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;; In particular, the `fonts' variable might be corrupted. So if there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;; are font-shifts in the prop line, re-parse it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (if (or (not (boundp 'fonts))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (null 'fonts)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (and (looking-at "[ \t]*;.*-\\*-.*fonts[ \t]*:.*-\\*-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (looking-at ".*\^F"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (narrow-to-region (point-min) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (while (re-search-forward "\^F[0-9a-zA-Z*]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (delete-region (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (let ((enable-local-variables 'query))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (hack-local-variables))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (defun lispm-fontify-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (if (fboundp 'font-lock-mode) (font-lock-mode 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (lispm-fontify-hack-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (let ((font-stack nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (while (search-forward "\^F" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (delete-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (setq c (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (cond ((= c ?\^F)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (insert "\^F"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ((= c ?*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (if (and font-stack (/= p (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (set-extent-face (make-extent p (point)) (car font-stack)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (setq p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (setq font-stack (cdr font-stack)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ((or (< c ?0) (> c ?Z)) ; error...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ((>= (setq c (- c ?0)) (length fonts)) ; error...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (if (and font-stack (/= p (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (set-extent-face (make-extent p (point)) (car font-stack)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (setq font-stack (cons (lispm-font-to-face (nth c fonts))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 font-stack))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (setq p (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (if (and font-stack (/= p (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (set-extent-face (make-extent p (point)) (car font-stack))))))