Mercurial > emacs
annotate lisp/international/fontset.el @ 19431:9c5fdc90d3c6
(tit-process-body): Handle `\' used
for quoting the following digits correctly.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Tue, 19 Aug 1997 10:58:40 +0000 |
parents | cad4c032fa26 |
children | f5627d8c422a |
rev | line source |
---|---|
17052 | 1 ;;; fontset.el --- Commands for handling fontset. |
2 | |
18377
8b4a66c66dd6
Change copyright notice.
Richard M. Stallman <rms@gnu.org>
parents:
18350
diff
changeset
|
3 ;; Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN. |
8b4a66c66dd6
Change copyright notice.
Richard M. Stallman <rms@gnu.org>
parents:
18350
diff
changeset
|
4 ;; Licensed to the Free Software Foundation. |
17052 | 5 |
6 ;; Keywords: mule, multilingual, fontset | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
17071 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
17052 | 24 |
25 ;;; Code: | |
26 | |
17842
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
27 ;; Set standard REGISTRY property of charset to find an appropriate |
17052 | 28 ;; font for each charset. This is used to generate a font name in a |
29 ;; fontset. If the value contains a character `-', the string before | |
30 ;; that is embeded in `CHARSET_REGISTRY' field, and the string after | |
31 ;; that is embeded in `CHARSET_ENCODING' field. If the value does not | |
32 ;; contain `-', the whole string is embeded in `CHARSET_REGISTRY' | |
33 ;; field, and a wild card character `*' is embeded in | |
34 ;; `CHARSET_ENCODING' field. | |
35 | |
36 (defvar x-charset-registries | |
37 '((ascii . "ISO8859-1") | |
38 (latin-iso8859-1 . "ISO8859-1") | |
39 (latin-iso8859-2 . "ISO8859-2") | |
40 (latin-iso8859-3 . "ISO8859-3") | |
41 (latin-iso8859-4 . "ISO8859-4") | |
42 (thai-tis620 . "TIS620") | |
43 (greek-iso8859-7 . "ISO8859-7") | |
44 (arabic-iso8859-6 . "ISO8859-6") | |
45 (hebrew-iso8859-8 . "ISO8859-8") | |
46 (katakana-jisx0201 . "JISX0201") | |
47 (latin-jisx0201 . "JISX0201") | |
48 (cyrillic-iso8859-5 . "ISO8859-5") | |
49 (latin-iso8859-9 . "ISO8859-9") | |
50 (japanese-jisx0208-1978 . "JISX0208.1978") | |
51 (chinese-gb2312 . "GB2312") | |
52 (japanese-jisx0208 . "JISX0208.1983") | |
53 (korean-ksc5601 . "KSC5601") | |
54 (japanese-jisx0212 . "JISX0212") | |
55 (chinese-cns11643-1 . "CNS11643.1992-1") | |
56 (chinese-cns11643-2 . "CNS11643.1992-2") | |
57 (chinese-cns11643-3 . "CNS11643.1992-3") | |
58 (chinese-cns11643-4 . "CNS11643.1992-4") | |
59 (chinese-cns11643-5 . "CNS11643.1992-5") | |
60 (chinese-cns11643-6 . "CNS11643.1992-6") | |
61 (chinese-cns11643-7 . "CNS11643.1992-7") | |
62 (chinese-big5-1 . "Big5") | |
63 (chinese-big5-2 . "Big5") | |
64 (chinese-sisheng . "sisheng_cwnn") | |
65 (vietnamese-viscii-lower . "VISCII1.1") | |
66 (vietnamese-viscii-upper . "VISCII1.1") | |
67 (arabic-digit . "MuleArabic-0") | |
68 (arabic-1-column . "MuleArabic-1") | |
69 (arabic-2-column . "MuleArabic-2") | |
70 (ipa . "MuleIPA") | |
17177
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
71 (ethiopic . "Ethiopic-Unicode") |
17052 | 72 (ascii-right-to-left . "ISO8859-1") |
73 (indian-is13194 . "IS13194-Devanagari") | |
74 (indian-2-column . "MuleIndian-2") | |
75 (indian-1-column . "MuleIndian-1") | |
18350
3f4364889538
(x-charset-registries): Name changed for consistency:
Kenichi Handa <handa@m17n.org>
parents:
17989
diff
changeset
|
76 (lao . "MuleLao-1") |
3f4364889538
(x-charset-registries): Name changed for consistency:
Kenichi Handa <handa@m17n.org>
parents:
17989
diff
changeset
|
77 (tibetan . "MuleTibetan-0") |
3f4364889538
(x-charset-registries): Name changed for consistency:
Kenichi Handa <handa@m17n.org>
parents:
17989
diff
changeset
|
78 (tibetan-1-column . "MuleTibetan-1") |
17295
34efd2073019
(x-charset-registries): Add Tibetan entries.
Kenichi Handa <handa@m17n.org>
parents:
17195
diff
changeset
|
79 )) |
17052 | 80 |
81 (let ((l x-charset-registries)) | |
82 (while l | |
17339
8ce3d2e461bc
When calling put-charset-property, ignore errors.
Richard M. Stallman <rms@gnu.org>
parents:
17336
diff
changeset
|
83 (condition-case nil |
8ce3d2e461bc
When calling put-charset-property, ignore errors.
Richard M. Stallman <rms@gnu.org>
parents:
17336
diff
changeset
|
84 (put-charset-property (car (car l)) 'x-charset-registry (cdr (car l))) |
8ce3d2e461bc
When calling put-charset-property, ignore errors.
Richard M. Stallman <rms@gnu.org>
parents:
17336
diff
changeset
|
85 (error nil)) |
17052 | 86 (setq l (cdr l)))) |
87 | |
88 ;; Set arguments in `font-encoding-alist' (which see). | |
89 (defun set-font-encoding (pattern charset encoding) | |
90 (let ((slot (assoc pattern font-encoding-alist))) | |
91 (if slot | |
92 (let ((place (assq charset (cdr slot)))) | |
93 (if place | |
94 (setcdr place encoding) | |
95 (setcdr slot (cons (cons charset encoding) (cdr slot))))) | |
96 (setq font-encoding-alist | |
97 (cons (list pattern (cons charset encoding)) font-encoding-alist))) | |
98 )) | |
99 | |
100 (set-font-encoding "ISO8859-1" 'ascii 0) | |
101 (set-font-encoding "JISX0201" 'latin-jisx0201 0) | |
102 | |
103 ;; Setting for suppressing XLoadQueryFont on big fonts. | |
104 (setq x-pixel-size-width-font-regexp | |
105 "gb2312\\|jisx0208\\|ksc5601\\|cns11643\\|big5") | |
106 | |
107 ;;; XLFD (X Logical Font Description) format handler. | |
108 | |
109 ;; Define XLFD's field index numbers. ; field name | |
110 (defconst xlfd-regexp-foundry-subnum 0) ; FOUNDRY | |
111 (defconst xlfd-regexp-family-subnum 1) ; FAMILY_NAME | |
112 (defconst xlfd-regexp-weight-subnum 2) ; WEIGHT_NAME | |
113 (defconst xlfd-regexp-slant-subnum 3) ; SLANT | |
114 (defconst xlfd-regexp-swidth-subnum 4) ; SETWIDTH_NAME | |
115 (defconst xlfd-regexp-adstyle-subnum 5) ; ADD_STYLE_NAME | |
116 (defconst xlfd-regexp-pixelsize-subnum 6) ; PIXEL_SIZE | |
117 (defconst xlfd-regexp-pointsize-subnum 7) ; POINT_SIZE | |
118 (defconst xlfd-regexp-resx-subnum 8) ; RESOLUTION_X | |
119 (defconst xlfd-regexp-resy-subnum 9) ; RESOLUTION_Y | |
120 (defconst xlfd-regexp-spacing-subnum 10) ; SPACING | |
121 (defconst xlfd-regexp-avgwidth-subnum 11) ; AVERAGE_WIDTH | |
122 (defconst xlfd-regexp-registry-subnum 12) ; CHARSET_REGISTRY | |
123 (defconst xlfd-regexp-encoding-subnum 13) ; CHARSET_ENCODING | |
124 | |
125 ;; Regular expression matching against a fontname which conforms to | |
126 ;; XLFD (X Logical Font Description). All fields in XLFD should be | |
127 ;; not be omitted (but can be a wild card) to be matched. | |
128 (defconst xlfd-tight-regexp | |
129 "^\ | |
130 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\ | |
131 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\ | |
132 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)$") | |
133 | |
134 ;; List of field numbers of XLFD whose values are numeric. | |
135 (defconst xlfd-regexp-numeric-subnums | |
136 (list xlfd-regexp-pixelsize-subnum ;6 | |
137 xlfd-regexp-pointsize-subnum ;7 | |
138 xlfd-regexp-resx-subnum ;8 | |
139 xlfd-regexp-resy-subnum ;9 | |
140 xlfd-regexp-avgwidth-subnum ;11 | |
141 )) | |
142 | |
143 (defun x-decompose-font-name (pattern) | |
144 "Decompose PATTERN into XLFD's fields and return vector of the fields. | |
145 The length of the vector is 14. | |
146 | |
147 If PATTERN doesn't conform to XLFD, try to get a full XLFD name from | |
148 X server and use the information of the full name to decompose | |
149 PATTERN. If no full XLFD name is gotten, return nil." | |
150 (let (xlfd-fields fontname) | |
151 (if (string-match xlfd-tight-regexp pattern) | |
152 (let ((i 0)) | |
153 (setq xlfd-fields (make-vector 14 nil)) | |
154 (while (< i 14) | |
155 (aset xlfd-fields i (match-string (1+ i) pattern)) | |
156 (setq i (1+ i))) | |
157 xlfd-fields) | |
158 (setq fontname (condition-case nil | |
159 (x-resolve-font-name pattern) | |
160 (error))) | |
161 (if (and fontname | |
162 (string-match xlfd-tight-regexp fontname)) | |
163 (let ((len (length pattern)) | |
164 (i 0) | |
165 l) | |
166 (setq xlfd-fields (make-vector 14 nil)) | |
167 (while (< i 14) | |
168 (aset xlfd-fields i | |
169 (cons (match-beginning (1+ i)) | |
170 (match-string (1+ i) fontname))) | |
171 (setq i (1+ i))) | |
172 (setq i 0) | |
173 (while (< i len) | |
174 (let ((ch (aref pattern i))) | |
175 (if (= ch ??) | |
176 (setq pattern (concat (substring pattern 0 i) | |
177 "\\(.\\)" | |
178 (substring pattern (1+ i))) | |
179 len (+ len 4) | |
180 i (+ i 4)) | |
181 (if (= ch ?*) | |
182 (setq pattern (concat (substring pattern 0 i) | |
183 "\\(.*\\)" | |
184 (substring pattern (1+ i))) | |
185 len (+ len 5) | |
186 i (+ i 5)) | |
187 (setq i (1+ i)))))) | |
188 (string-match pattern fontname) | |
189 (setq l (cdr (cdr (match-data)))) | |
190 (setq i 0) | |
191 (while (< i 14) | |
192 (if (or (null l) (< (car (aref xlfd-fields i)) (car l))) | |
193 (progn | |
194 (aset xlfd-fields i (cdr (aref xlfd-fields i))) | |
195 (setq i (1+ i))) | |
196 (if (< (car (aref xlfd-fields i)) (car (cdr l))) | |
197 (progn | |
17755
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
198 (aset xlfd-fields i "*") |
17052 | 199 (setq i (1+ i))) |
200 (setq l (cdr (cdr l)))))) | |
201 xlfd-fields))))) | |
202 | |
17177
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
203 ;; Replace consecutive wild-cards (`*') in NAME to one. |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
204 ;; Ex. (x-reduce-font-name "-*-*-*-iso8859-1") => "-*-iso8859-1" |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
205 (defsubst x-reduce-font-name (name) |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
206 (while (string-match "-\\*-\\(\\*-\\)+" name) |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
207 (setq name (replace-match "-*-" t t name))) |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
208 name) |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
209 |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
210 (defun x-compose-font-name (xlfd-fields &optional reduce) |
17052 | 211 "Compose X's fontname from FIELDS. |
212 FIELDS is a vector of XLFD fields. | |
17177
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
213 If a field is nil, wild-card letter `*' is embedded. |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
214 Optional argument REDUCE non-nil means consecutive wild-cards are |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
215 reduced to be one." |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
216 (let ((name |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
217 (concat "-" (mapconcat (lambda (x) (or x "*")) xlfd-fields "-")))) |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
218 (if reduce |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
219 (x-reduce-font-name name) |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
220 name))) |
17052 | 221 |
222 (defun x-complement-fontset-spec (xlfd-fields fontlist) | |
223 "Complement FONTLIST for all charsets based on XLFD-FIELDS and return it. | |
224 XLFD-FIELDS is a vector of XLFD (X Logical Font Description) fields. | |
225 FONTLIST is an alist of cons of charset and fontname. | |
226 | |
227 Fontnames for charsets not listed in FONTLIST are generated from | |
18350
3f4364889538
(x-charset-registries): Name changed for consistency:
Kenichi Handa <handa@m17n.org>
parents:
17989
diff
changeset
|
228 XLFD-FIELDS and a property of x-charset-registry of each charset |
17052 | 229 automatically." |
17195
9c0c6ae6dcad
(x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents:
17177
diff
changeset
|
230 (let ((charsets charset-list) |
17989
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
231 (style-ignored (copy-sequence xlfd-fields)) |
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
232 (size-ignored (copy-sequence xlfd-fields))) |
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
233 (aset style-ignored xlfd-regexp-weight-subnum nil) |
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
234 (aset style-ignored xlfd-regexp-slant-subnum nil) |
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
235 (aset style-ignored xlfd-regexp-swidth-subnum nil) |
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
236 (aset style-ignored xlfd-regexp-adstyle-subnum nil) |
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
237 (aset size-ignored xlfd-regexp-pixelsize-subnum nil) |
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
238 (aset size-ignored xlfd-regexp-pointsize-subnum nil) |
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
239 (aset size-ignored xlfd-regexp-resx-subnum nil) |
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
240 (aset size-ignored xlfd-regexp-resy-subnum nil) |
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
241 (aset size-ignored xlfd-regexp-spacing-subnum nil) |
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
242 (aset size-ignored xlfd-regexp-avgwidth-subnum nil) |
17052 | 243 (while charsets |
244 (let ((charset (car charsets))) | |
245 (if (null (assq charset fontlist)) | |
246 (let ((registry (get-charset-property charset | |
17195
9c0c6ae6dcad
(x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents:
17177
diff
changeset
|
247 'x-charset-registry)) |
9c0c6ae6dcad
(x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents:
17177
diff
changeset
|
248 registry-val encoding-val fontname loose-fontname) |
17052 | 249 (if (string-match "-" registry) |
250 ;; REGISTRY contains `CHARSET_ENCODING' field. | |
17195
9c0c6ae6dcad
(x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents:
17177
diff
changeset
|
251 (setq registry-val (substring registry 0 (match-beginning 0)) |
9c0c6ae6dcad
(x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents:
17177
diff
changeset
|
252 encoding-val (substring registry (match-end 0))) |
9c0c6ae6dcad
(x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents:
17177
diff
changeset
|
253 (setq registry-val (concat registry "*") |
9c0c6ae6dcad
(x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents:
17177
diff
changeset
|
254 encoding-val "*")) |
9c0c6ae6dcad
(x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents:
17177
diff
changeset
|
255 (aset xlfd-fields xlfd-regexp-registry-subnum registry-val) |
9c0c6ae6dcad
(x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents:
17177
diff
changeset
|
256 (aset xlfd-fields xlfd-regexp-encoding-subnum encoding-val) |
17989
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
257 (aset style-ignored xlfd-regexp-registry-subnum registry-val) |
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
258 (aset style-ignored xlfd-regexp-encoding-subnum encoding-val) |
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
259 (aset size-ignored xlfd-regexp-registry-subnum registry-val) |
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
260 (aset size-ignored xlfd-regexp-encoding-subnum encoding-val) |
17195
9c0c6ae6dcad
(x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents:
17177
diff
changeset
|
261 (setq fontname (x-compose-font-name xlfd-fields t)) |
9c0c6ae6dcad
(x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents:
17177
diff
changeset
|
262 (setq fontlist (cons (cons charset fontname) fontlist)) |
9c0c6ae6dcad
(x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents:
17177
diff
changeset
|
263 (or (assoc fontname alternative-fontname-alist) |
9c0c6ae6dcad
(x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents:
17177
diff
changeset
|
264 (setq alternative-fontname-alist |
9c0c6ae6dcad
(x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents:
17177
diff
changeset
|
265 (cons (list |
9c0c6ae6dcad
(x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents:
17177
diff
changeset
|
266 fontname |
17989
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
267 (x-compose-font-name style-ignored t) |
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
268 (x-compose-font-name size-ignored t) |
17195
9c0c6ae6dcad
(x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents:
17177
diff
changeset
|
269 (concat "*-" registry-val "-" encoding-val)) |
9c0c6ae6dcad
(x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents:
17177
diff
changeset
|
270 alternative-fontname-alist))) |
9c0c6ae6dcad
(x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents:
17177
diff
changeset
|
271 ))) |
17052 | 272 (setq charsets (cdr charsets)))) |
18350
3f4364889538
(x-charset-registries): Name changed for consistency:
Kenichi Handa <handa@m17n.org>
parents:
17989
diff
changeset
|
273 |
3f4364889538
(x-charset-registries): Name changed for consistency:
Kenichi Handa <handa@m17n.org>
parents:
17989
diff
changeset
|
274 ;; Here's a trick for the charset latin-iso8859-1. If font for |
3f4364889538
(x-charset-registries): Name changed for consistency:
Kenichi Handa <handa@m17n.org>
parents:
17989
diff
changeset
|
275 ;; ascii also contains Latin-1 characters, use it also for |
3f4364889538
(x-charset-registries): Name changed for consistency:
Kenichi Handa <handa@m17n.org>
parents:
17989
diff
changeset
|
276 ;; latin-iso8859-1. This prevent loading a font for latin-iso8859-1 |
3f4364889538
(x-charset-registries): Name changed for consistency:
Kenichi Handa <handa@m17n.org>
parents:
17989
diff
changeset
|
277 ;; by a different name. |
3f4364889538
(x-charset-registries): Name changed for consistency:
Kenichi Handa <handa@m17n.org>
parents:
17989
diff
changeset
|
278 (if (string-match (cdr (assq 'latin-iso8859-1 x-charset-registries)) |
3f4364889538
(x-charset-registries): Name changed for consistency:
Kenichi Handa <handa@m17n.org>
parents:
17989
diff
changeset
|
279 (cdr (assq 'ascii fontlist))) |
3f4364889538
(x-charset-registries): Name changed for consistency:
Kenichi Handa <handa@m17n.org>
parents:
17989
diff
changeset
|
280 (setcdr (assq 'latin-iso8859-1 fontlist) (cdr (assq 'ascii fontlist)))) |
17052 | 281 fontlist) |
282 | |
19049
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
283 (defun fontset-name-p (fontset) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
284 "Return non-nil if FONTSET is valid as fontset name. |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
285 A valid fontset name should conform to XLFD (X Logical Font Description) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
286 with \"fontset\" in `<CHARSET_REGISTRY> field." |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
287 (and (string-match xlfd-tight-regexp fontset) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
288 (string= (match-string (1+ xlfd-regexp-registry-subnum) fontset) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
289 "fontset"))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
290 |
17052 | 291 ;; Return a list to be appended to `x-fixed-font-alist' when |
292 ;; `mouse-set-font' is called. | |
293 (defun generate-fontset-menu () | |
294 (let ((fontsets global-fontset-alist) | |
295 fontset-name | |
296 l) | |
297 (while fontsets | |
298 (setq fontset-name (car (car fontsets)) fontsets (cdr fontsets)) | |
17755
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
299 (setq l (cons (list (fontset-plain-name fontset-name) fontset-name) l))) |
17052 | 300 (cons "Fontset" l))) |
301 | |
302 (defun fontset-plain-name (fontset) | |
303 "Return a plain and descriptive name of FONTSET." | |
17755
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
304 (if (not (setq fontset (query-fontset fontset))) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
305 (error "Invalid fontset: %s" fontset)) |
17052 | 306 (let ((xlfd-fields (x-decompose-font-name fontset))) |
307 (if xlfd-fields | |
308 (let ((weight (aref xlfd-fields xlfd-regexp-weight-subnum)) | |
309 (slant (aref xlfd-fields xlfd-regexp-slant-subnum)) | |
310 (swidth (aref xlfd-fields xlfd-regexp-swidth-subnum)) | |
311 (size (aref xlfd-fields xlfd-regexp-pixelsize-subnum)) | |
17755
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
312 (charset (aref xlfd-fields xlfd-regexp-registry-subnum)) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
313 (nickname (aref xlfd-fields xlfd-regexp-encoding-subnum)) |
17052 | 314 name) |
17755
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
315 (if (not (string= "fontset" charset)) |
17052 | 316 fontset |
17755
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
317 (if (> (string-to-int size) 0) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
318 (setq name (format "%s: %s-dot" nickname size)) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
319 (setq name nickname)) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
320 (cond ((string-match "^medium$" weight) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
321 (setq name (concat name " " "medium"))) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
322 ((string-match "^bold$\\|^demibold$" weight) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
323 (setq name (concat name " " weight)))) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
324 (cond ((string-match "^i$" slant) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
325 (setq name (concat name " " "italic"))) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
326 ((string-match "^o$" slant) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
327 (setq name (concat name " " "slant"))) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
328 ((string-match "^ri$" slant) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
329 (setq name (concat name " " "reverse italic"))) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
330 ((string-match "^ro$" slant) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
331 (setq name (concat name " " "reverse slant")))) |
17052 | 332 name)) |
333 fontset))) | |
334 | |
19049
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
335 (defvar uninstanciated-fontset-alist nil |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
336 "Alist of fontset names vs. information for instanciating them. |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
337 Each element has the form (FONTSET STYLE BASE-FONTSET), where |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
338 FONTSET is a name of fontset not yet instanciated. |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
339 STYLE is a style of FONTSET, one of the followings: |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
340 bold, demobold, italic, oblique, |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
341 bold-italic, demibold-italic, bold-oblique, demibold-oblique. |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
342 BASE-FONTSET is a name of fontset base from which FONSET is instanciated.") |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
343 |
18714
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
344 (defun create-fontset-from-fontset-spec (fontset-spec &optional style noerror) |
17052 | 345 "Create a fontset from fontset specification string FONTSET-SPEC. |
346 FONTSET-SPEC is a string of the format: | |
347 FONTSET-NAME,CHARSET-NAME0:FONT-NAME0,CHARSET-NAME1:FONT-NAME1, ... | |
17755
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
348 Any number of SPACE, TAB, and NEWLINE can be put before and after commas. |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
349 If optional argument STYLE is specified, create a fontset of STYLE |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
350 by modifying FONTSET-SPEC appropriately. STYLE can be one of `bold', |
18714
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
351 `italic', and `bold-italic'. |
18719
de8249499f33
(create-fontset-from-fontset-spec): Typo in doc-string fixed.
Kenichi Handa <handa@m17n.org>
parents:
18714
diff
changeset
|
352 If this function attempts to create already existing fontset, error is |
de8249499f33
(create-fontset-from-fontset-spec): Typo in doc-string fixed.
Kenichi Handa <handa@m17n.org>
parents:
18714
diff
changeset
|
353 signaled unless the optional 3rd argument NOERROR is non-nil." |
17755
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
354 (if (not (string-match "^[^,]+" fontset-spec)) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
355 (error "Invalid fontset spec: %s" fontset-spec)) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
356 (let ((idx (match-end 0)) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
357 (name (match-string 0 fontset-spec)) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
358 fontlist charset) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
359 ;; At first, extract pairs of charset and fontname from FONTSET-SPEC. |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
360 (while (string-match "[, \t\n]*\\([^:]+\\):\\([^,]+\\)" fontset-spec idx) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
361 (setq idx (match-end 0)) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
362 (setq charset (intern (match-string 1 fontset-spec))) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
363 (if (charsetp charset) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
364 (setq fontlist (cons (cons charset (match-string 2 fontset-spec)) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
365 fontlist)))) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
366 |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
367 ;; If NAME conforms to XLFD, complement FONTLIST for charsets not |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
368 ;; specified in FONTSET-SPEC. |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
369 (let ((xlfd-fields (x-decompose-font-name name))) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
370 (if xlfd-fields |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
371 (setq fontlist |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
372 (x-complement-fontset-spec xlfd-fields fontlist)))) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
373 |
19049
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
374 ;; If STYLE is specified, modify fontset name (NAME) and FONTLIST. |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
375 (if nil |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
376 (let ((func (cdr (assq style '((bold . x-make-font-bold) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
377 (italic . x-make-font-italic) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
378 (bold-italic . x-make-font-bold-italic))))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
379 (l fontlist) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
380 new-name) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
381 (if (and func |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
382 (setq new-name (funcall func name))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
383 (progn |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
384 (setq name new-name) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
385 (while l |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
386 (if (setq new-name (funcall func (cdr (car l)))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
387 (setcdr (car l) new-name)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
388 (setq l (cdr l)))))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
389 (let ((funcs-alist |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
390 '((bold x-make-font-bold) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
391 (demibold x-make-font-demibold) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
392 (italic x-make-font-italic) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
393 (oblique x-make-font-oblique) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
394 (bold-italic x-make-font-bold x-make-font-italic) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
395 (demibold-italic x-make-font-demibold x-make-font-italic) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
396 (bold-oblique x-make-font-bold x-make-font-oblique) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
397 (demibold-oblique x-make-font-demibold x-make-font-oblique))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
398 new-name style funcs) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
399 (while funcs-alist |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
400 (setq funcs (car funcs-alist)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
401 (setq style (car funcs)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
402 (setq funcs (cdr funcs)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
403 (setq new-name name) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
404 (while funcs |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
405 (setq new-name (funcall (car funcs) new-name)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
406 (setq funcs (cdr funcs))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
407 (setq uninstanciated-fontset-alist |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
408 (cons (list new-name style name) uninstanciated-fontset-alist)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
409 (setq funcs-alist (cdr funcs-alist))))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
410 |
18714
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
411 (if (and noerror (query-fontset name)) |
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
412 ;; Don't try to create an already existing fontset. |
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
413 nil |
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
414 ;; Create the fontset, and define the alias if appropriate. |
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
415 (new-fontset name fontlist) |
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
416 (if (and (not style) |
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
417 (not (assoc name fontset-alias-alist)) |
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
418 (string-match "fontset-.*$" name)) |
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
419 (let ((alias (match-string 0 name))) |
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
420 (or (rassoc alias fontset-alias-alist) |
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
421 (setq fontset-alias-alist |
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
422 (cons (cons name alias) fontset-alias-alist)))))))) |
17052 | 423 |
19049
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
424 (defun instanciate-fontset (fontset) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
425 "Create a new fontset FONTSET if it is not yet instanciated. |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
426 Return FONTSET if it is created successfully, else return nil." |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
427 (let ((fontset-data (assoc fontset uninstanciated-fontset-alist))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
428 (if (null fontset-data) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
429 nil |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
430 (let ((style (nth 1 fontset-data)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
431 (base-fontset (nth 2 fontset-data)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
432 (funcs-alist |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
433 '((bold x-make-font-bold) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
434 (demibold x-make-font-demibold) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
435 (italic x-make-font-italic) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
436 (oblique x-make-font-oblique) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
437 (bold-italic x-make-font-bold x-make-font-italic) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
438 (demibold-italic x-make-font-demibold x-make-font-italic) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
439 (bold-oblique x-make-font-bold x-make-font-oblique) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
440 (demibold-oblique x-make-font-demibold x-make-font-oblique))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
441 ascii-font font font2 funcs) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
442 (setq uninstanciated-fontset-alist |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
443 (delete fontset-data uninstanciated-fontset-alist)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
444 (setq fontset-data (assoc base-fontset global-fontset-alist)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
445 (setq ascii-font (cdr (assq 'ascii (cdr fontset-data)))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
446 (setq funcs (cdr (assq style funcs-alist))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
447 (if (= (length funcs) 1) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
448 (and (setq font (funcall (car funcs) ascii-font)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
449 (setq font (x-resolve-font-name font 'default))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
450 (and (setq font (funcall (car funcs) ascii-font)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
451 (not (equal font ascii-font)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
452 (setq font2 (funcall (nth 1 funcs) font)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
453 (not (equal font2 font)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
454 (setq font (x-resolve-font-name font2 'default)))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
455 (when font |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
456 (let ((new-fontset-data (copy-alist fontset-data))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
457 (setq funcs (cdr (assq style funcs-alist))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
458 (while funcs |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
459 (setcar new-fontset-data |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
460 (funcall (car funcs) (car new-fontset-data))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
461 (let ((l (cdr new-fontset-data))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
462 (while l |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
463 (if (setq font (funcall (car funcs) (cdr (car l)))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
464 (setcdr (car l) font)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
465 (setq l (cdr l)))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
466 (setq funcs (cdr funcs))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
467 (new-fontset (car new-fontset-data) (cdr new-fontset-data)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
468 (car new-fontset-data))))))) |
17052 | 469 |
17842
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
470 ;; Create standard fontset from 16 dots fonts which are the most widely |
17989
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
471 ;; installed fonts. Fonts for Chinese-GB, Korean, and Chinese-CNS are |
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
472 ;; specified here because FAMILY of those fonts are not "fixed" in |
8a264cfe3768
(x-complement-fontset-spec): Add font names which are
Kenichi Handa <handa@m17n.org>
parents:
17842
diff
changeset
|
473 ;; many cases. |
17842
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
474 (defvar standard-fontset-spec |
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
475 "-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard, |
17052 | 476 chinese-gb2312:-*-medium-r-normal-*-16-*-gb2312*-*, |
477 korean-ksc5601:-*-medium-r-normal-*-16-*-ksc5601*-*, | |
478 chinese-cns11643-1:-*-medium-r-normal-*-16-*-cns11643*-1, | |
479 chinese-cns11643-2:-*-medium-r-normal-*-16-*-cns11643*-2, | |
480 chinese-cns11643-3:-*-medium-r-normal-*-16-*-cns11643*-3, | |
481 chinese-cns11643-4:-*-medium-r-normal-*-16-*-cns11643*-4, | |
482 chinese-cns11643-5:-*-medium-r-normal-*-16-*-cns11643*-5, | |
483 chinese-cns11643-6:-*-medium-r-normal-*-16-*-cns11643*-6, | |
484 chinese-cns11643-7:-*-medium-r-normal-*-16-*-cns11643*-7" | |
17842
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
485 "String of fontset spec of the standard fontset. |
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
486 You have the biggest chance to display international characters |
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
487 with correct glyphs by using the standard fontset. |
17052 | 488 See the documentation of `create-fontset-from-fontset-spec' for the format.") |
489 | |
490 ;; Create fontsets from X resources of the name `fontset-N (class | |
491 ;; Fontset-N)' where N is integer 0, 1, ... | |
492 ;; The values of the resources the string of the same format as | |
17842
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
493 ;; `standard-fontset-spec'. |
17052 | 494 |
495 (defun create-fontset-from-x-resource () | |
496 (let ((idx 0) | |
497 fontset-spec) | |
498 (while (setq fontset-spec (x-get-resource (concat "fontset-" idx) | |
499 (concat "Fontset-" idx))) | |
18714
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
500 (create-fontset-from-fontset-spec fontset-spec nil 'noerror) |
17052 | 501 (setq idx (1+ idx))))) |
502 | |
503 (defsubst fontset-list () | |
504 "Returns a list of all defined fontset names." | |
505 (mapcar 'car global-fontset-alist)) | |
506 | |
507 ;; | |
508 (provide 'fontset) | |
509 | |
510 ;;; fontset.el ends here |