Mercurial > emacs
annotate lisp/international/fontset.el @ 22161:7a4c3fd89dda
(x-font-name-charset-alist): New
variable.
(register-alternate-fontnames): Doc-string modified.
(x-complement-fontset-spec): Likewise.
(x-complement-fontset-spec): Delete unused local variable. Delete
ad hoc code for Latin-1, instead refer to
x-font-name-charset-alist.
(uninstantiated-fontset-alist): Format changed (BASE-FONTSET ->
FONTLIST).
(x-style-funcs-alist): New variable.
(create-fontset-from-fontset-spec): 2nd optional arg is changed
from STYLE to STYLE-VARIANT-P. The meaning also changed. Delete
unused code. Adjusted for the change of
uninstantiated-fontset-alist.
(instantiate-fontset): Adjusted for the change of
uninstantiated-fontset-alist.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Thu, 21 May 1998 01:46:39 +0000 |
parents | 8f7a59fc78db |
children | c87830c691a5 |
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 | |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
107 (defvar x-font-name-charset-alist |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
108 '(("iso8859-1" ascii latin-iso8859-1) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
109 ("iso8859-2" ascii latin-iso8859-2) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
110 ("iso8859-3" ascii latin-iso8859-3) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
111 ("iso8859-4" ascii latin-iso8859-4) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
112 ("iso8859-5" ascii cyrillic-iso8859-5) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
113 ("iso8859-6" ascii arabic-iso8859-6) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
114 ("iso8859-7" ascii greek-iso8859-7) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
115 ("iso8859-8" ascii hebrew-iso8859-8) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
116 ("tis620" ascii thai-tis620) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
117 ("koi8" ascii cyrillic-iso8859-5) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
118 ("viscii" ascii vietnamese-viscii-upper vietnamese-viscii-lower) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
119 ("vscii" ascii vietnamese-viscii-upper vietnamese-viscii-lower) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
120 ("mulelao-1" ascii lao)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
121 "Alist of font names vs list of charsets the font can display. |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
122 |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
123 When a font name which matches some element of this alist is given as |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
124 `-fn' command line argument or is specified by X resource, a fontset |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
125 which uses the specified font for the corresponding charsets are |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
126 created and used for the initial frame.") |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
127 |
17052 | 128 ;;; XLFD (X Logical Font Description) format handler. |
129 | |
130 ;; Define XLFD's field index numbers. ; field name | |
131 (defconst xlfd-regexp-foundry-subnum 0) ; FOUNDRY | |
132 (defconst xlfd-regexp-family-subnum 1) ; FAMILY_NAME | |
133 (defconst xlfd-regexp-weight-subnum 2) ; WEIGHT_NAME | |
134 (defconst xlfd-regexp-slant-subnum 3) ; SLANT | |
135 (defconst xlfd-regexp-swidth-subnum 4) ; SETWIDTH_NAME | |
136 (defconst xlfd-regexp-adstyle-subnum 5) ; ADD_STYLE_NAME | |
137 (defconst xlfd-regexp-pixelsize-subnum 6) ; PIXEL_SIZE | |
138 (defconst xlfd-regexp-pointsize-subnum 7) ; POINT_SIZE | |
139 (defconst xlfd-regexp-resx-subnum 8) ; RESOLUTION_X | |
140 (defconst xlfd-regexp-resy-subnum 9) ; RESOLUTION_Y | |
141 (defconst xlfd-regexp-spacing-subnum 10) ; SPACING | |
142 (defconst xlfd-regexp-avgwidth-subnum 11) ; AVERAGE_WIDTH | |
143 (defconst xlfd-regexp-registry-subnum 12) ; CHARSET_REGISTRY | |
144 (defconst xlfd-regexp-encoding-subnum 13) ; CHARSET_ENCODING | |
145 | |
146 ;; Regular expression matching against a fontname which conforms to | |
147 ;; XLFD (X Logical Font Description). All fields in XLFD should be | |
148 ;; not be omitted (but can be a wild card) to be matched. | |
149 (defconst xlfd-tight-regexp | |
150 "^\ | |
151 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\ | |
152 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\ | |
153 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)$") | |
154 | |
155 ;; List of field numbers of XLFD whose values are numeric. | |
156 (defconst xlfd-regexp-numeric-subnums | |
157 (list xlfd-regexp-pixelsize-subnum ;6 | |
158 xlfd-regexp-pointsize-subnum ;7 | |
159 xlfd-regexp-resx-subnum ;8 | |
160 xlfd-regexp-resy-subnum ;9 | |
161 xlfd-regexp-avgwidth-subnum ;11 | |
162 )) | |
163 | |
164 (defun x-decompose-font-name (pattern) | |
165 "Decompose PATTERN into XLFD's fields and return vector of the fields. | |
166 The length of the vector is 14. | |
167 | |
168 If PATTERN doesn't conform to XLFD, try to get a full XLFD name from | |
169 X server and use the information of the full name to decompose | |
170 PATTERN. If no full XLFD name is gotten, return nil." | |
171 (let (xlfd-fields fontname) | |
172 (if (string-match xlfd-tight-regexp pattern) | |
173 (let ((i 0)) | |
174 (setq xlfd-fields (make-vector 14 nil)) | |
175 (while (< i 14) | |
176 (aset xlfd-fields i (match-string (1+ i) pattern)) | |
177 (setq i (1+ i))) | |
178 xlfd-fields) | |
179 (setq fontname (condition-case nil | |
180 (x-resolve-font-name pattern) | |
181 (error))) | |
182 (if (and fontname | |
183 (string-match xlfd-tight-regexp fontname)) | |
184 (let ((len (length pattern)) | |
185 (i 0) | |
186 l) | |
187 (setq xlfd-fields (make-vector 14 nil)) | |
188 (while (< i 14) | |
189 (aset xlfd-fields i | |
190 (cons (match-beginning (1+ i)) | |
191 (match-string (1+ i) fontname))) | |
192 (setq i (1+ i))) | |
193 (setq i 0) | |
194 (while (< i len) | |
195 (let ((ch (aref pattern i))) | |
196 (if (= ch ??) | |
197 (setq pattern (concat (substring pattern 0 i) | |
198 "\\(.\\)" | |
199 (substring pattern (1+ i))) | |
200 len (+ len 4) | |
201 i (+ i 4)) | |
202 (if (= ch ?*) | |
203 (setq pattern (concat (substring pattern 0 i) | |
204 "\\(.*\\)" | |
205 (substring pattern (1+ i))) | |
206 len (+ len 5) | |
207 i (+ i 5)) | |
208 (setq i (1+ i)))))) | |
209 (string-match pattern fontname) | |
210 (setq l (cdr (cdr (match-data)))) | |
211 (setq i 0) | |
212 (while (< i 14) | |
213 (if (or (null l) (< (car (aref xlfd-fields i)) (car l))) | |
214 (progn | |
215 (aset xlfd-fields i (cdr (aref xlfd-fields i))) | |
216 (setq i (1+ i))) | |
217 (if (< (car (aref xlfd-fields i)) (car (cdr l))) | |
218 (progn | |
17755
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
219 (aset xlfd-fields i "*") |
17052 | 220 (setq i (1+ i))) |
221 (setq l (cdr (cdr l)))))) | |
222 xlfd-fields))))) | |
223 | |
17177
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
224 ;; 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
|
225 ;; 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
|
226 (defsubst x-reduce-font-name (name) |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
227 (while (string-match "-\\*-\\(\\*-\\)+" name) |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
228 (setq name (replace-match "-*-" t t name))) |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
229 name) |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
230 |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
231 (defun x-compose-font-name (xlfd-fields &optional reduce) |
17052 | 232 "Compose X's fontname from FIELDS. |
233 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
|
234 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
|
235 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
|
236 reduced to be one." |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
237 (let ((name |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
238 (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
|
239 (if reduce |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
240 (x-reduce-font-name name) |
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
241 name))) |
17052 | 242 |
19456
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
243 (defun register-alternate-fontnames (fontname) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
244 "Register alternate fontnames for FONTNAME in `alternate-fontname-alist'. |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
245 When Emacs fails to open FONTNAME, it tries to open an alternate font |
19456
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
246 registered in the variable `alternate-fontname-alist' (which see). |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
247 |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
248 For FONTNAME, the following three alternate fontnames are registered: |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
249 fontname which ignores style specification of FONTNAME, |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
250 fontname which ignores size specification of FONTNAME, |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
251 fontname which ignores both style and size specification of FONTNAME. |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
252 Emacs tries to open fonts in this order." |
19456
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
253 (unless (assoc fontname alternate-fontname-alist) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
254 (let ((xlfd-fields (x-decompose-font-name fontname)) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
255 style-ignored size-ignored both-ignored) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
256 (when xlfd-fields |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
257 (aset xlfd-fields xlfd-regexp-foundry-subnum nil) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
258 (aset xlfd-fields xlfd-regexp-family-subnum nil) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
259 |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
260 (let ((temp (copy-sequence xlfd-fields))) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
261 (aset temp xlfd-regexp-weight-subnum nil) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
262 (aset temp xlfd-regexp-slant-subnum nil) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
263 (aset temp xlfd-regexp-swidth-subnum nil) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
264 (aset temp xlfd-regexp-adstyle-subnum nil) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
265 (setq style-ignored (x-compose-font-name temp t))) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
266 |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
267 (aset xlfd-fields xlfd-regexp-pixelsize-subnum nil) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
268 (aset xlfd-fields xlfd-regexp-pointsize-subnum nil) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
269 (aset xlfd-fields xlfd-regexp-resx-subnum nil) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
270 (aset xlfd-fields xlfd-regexp-resy-subnum nil) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
271 (aset xlfd-fields xlfd-regexp-spacing-subnum nil) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
272 (aset xlfd-fields xlfd-regexp-avgwidth-subnum nil) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
273 (setq size-ignored (x-compose-font-name xlfd-fields t)) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
274 |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
275 (aset xlfd-fields xlfd-regexp-weight-subnum nil) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
276 (aset xlfd-fields xlfd-regexp-slant-subnum nil) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
277 (aset xlfd-fields xlfd-regexp-swidth-subnum nil) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
278 (aset xlfd-fields xlfd-regexp-adstyle-subnum nil) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
279 (setq both-ignored (x-compose-font-name xlfd-fields t)) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
280 |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
281 (setq alternate-fontname-alist |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
282 (cons (list fontname style-ignored size-ignored both-ignored) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
283 alternate-fontname-alist)))))) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
284 |
17052 | 285 (defun x-complement-fontset-spec (xlfd-fields fontlist) |
286 "Complement FONTLIST for all charsets based on XLFD-FIELDS and return it. | |
287 XLFD-FIELDS is a vector of XLFD (X Logical Font Description) fields. | |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
288 FONTLIST is an alist of charsets vs the corresponding font names. |
17052 | 289 |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
290 Font names 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
|
291 XLFD-FIELDS and a property of x-charset-registry of each charset |
17052 | 292 automatically." |
19456
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
293 (let ((charsets charset-list)) |
17052 | 294 (while charsets |
295 (let ((charset (car charsets))) | |
19456
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
296 (unless (assq charset fontlist) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
297 (let ((registry (get-charset-property charset |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
298 'x-charset-registry)) |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
299 registry-val encoding-val fontname) |
19456
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
300 (if (string-match "-" registry) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
301 ;; REGISTRY contains `CHARSET_ENCODING' field. |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
302 (setq registry-val (substring registry 0 (match-beginning 0)) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
303 encoding-val (substring registry (match-end 0))) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
304 (setq registry-val (concat registry "*") |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
305 encoding-val "*")) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
306 (aset xlfd-fields xlfd-regexp-registry-subnum registry-val) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
307 (aset xlfd-fields xlfd-regexp-encoding-subnum encoding-val) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
308 (setq fontname (downcase (x-compose-font-name xlfd-fields))) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
309 (setq fontlist (cons (cons charset fontname) fontlist)) |
f5627d8c422a
(register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents:
19049
diff
changeset
|
310 (register-alternate-fontnames fontname)))) |
17052 | 311 (setq charsets (cdr charsets)))) |
18350
3f4364889538
(x-charset-registries): Name changed for consistency:
Kenichi Handa <handa@m17n.org>
parents:
17989
diff
changeset
|
312 |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
313 ;; If the font for ASCII can also be used for another charsets, use |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
314 ;; that font instead of what generated based on x-charset-registery |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
315 ;; in the previous code. |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
316 (let ((ascii-font (cdr (assq 'ascii fontlist))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
317 (l x-font-name-charset-alist)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
318 (while l |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
319 (if (string-match (car (car l)) ascii-font) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
320 (let ((charsets (cdr (car l)))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
321 (while charsets |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
322 (if (not (eq (car charsets) 'ascii)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
323 (setcdr (assq (car charsets) fontlist) ascii-font)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
324 (setq charsets (cdr charsets))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
325 (setq l nil)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
326 (setq l (cdr l))))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
327 |
17052 | 328 fontlist) |
329 | |
19049
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
330 (defun fontset-name-p (fontset) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
331 "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
|
332 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
|
333 with \"fontset\" in `<CHARSET_REGISTRY> field." |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
334 (and (string-match xlfd-tight-regexp fontset) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
335 (string= (match-string (1+ xlfd-regexp-registry-subnum) fontset) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
336 "fontset"))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
337 |
17052 | 338 ;; Return a list to be appended to `x-fixed-font-alist' when |
339 ;; `mouse-set-font' is called. | |
340 (defun generate-fontset-menu () | |
341 (let ((fontsets global-fontset-alist) | |
342 fontset-name | |
343 l) | |
344 (while fontsets | |
345 (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
|
346 (setq l (cons (list (fontset-plain-name fontset-name) fontset-name) l))) |
17052 | 347 (cons "Fontset" l))) |
348 | |
349 (defun fontset-plain-name (fontset) | |
350 "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
|
351 (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
|
352 (error "Invalid fontset: %s" fontset)) |
17052 | 353 (let ((xlfd-fields (x-decompose-font-name fontset))) |
354 (if xlfd-fields | |
355 (let ((weight (aref xlfd-fields xlfd-regexp-weight-subnum)) | |
356 (slant (aref xlfd-fields xlfd-regexp-slant-subnum)) | |
357 (swidth (aref xlfd-fields xlfd-regexp-swidth-subnum)) | |
358 (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
|
359 (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
|
360 (nickname (aref xlfd-fields xlfd-regexp-encoding-subnum)) |
17052 | 361 name) |
17755
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
362 (if (not (string= "fontset" charset)) |
17052 | 363 fontset |
17755
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
364 (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
|
365 (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
|
366 (setq name nickname)) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
367 (cond ((string-match "^medium$" weight) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
368 (setq name (concat name " " "medium"))) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
369 ((string-match "^bold$\\|^demibold$" weight) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
370 (setq name (concat name " " weight)))) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
371 (cond ((string-match "^i$" slant) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
372 (setq name (concat name " " "italic"))) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
373 ((string-match "^o$" slant) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
374 (setq name (concat name " " "slant"))) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
375 ((string-match "^ri$" slant) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
376 (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
|
377 ((string-match "^ro$" slant) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
378 (setq name (concat name " " "reverse slant")))) |
17052 | 379 name)) |
380 fontset))) | |
381 | |
19771
7de156b57f00
(uninstantiated-fontset-alist):
Richard M. Stallman <rms@gnu.org>
parents:
19456
diff
changeset
|
382 (defvar uninstantiated-fontset-alist nil |
7de156b57f00
(uninstantiated-fontset-alist):
Richard M. Stallman <rms@gnu.org>
parents:
19456
diff
changeset
|
383 "Alist of fontset names vs. information for instantiating them. |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
384 Each element has the form (FONTSET STYLE FONTLIST), where |
19771
7de156b57f00
(uninstantiated-fontset-alist):
Richard M. Stallman <rms@gnu.org>
parents:
19456
diff
changeset
|
385 FONTSET is a name of fontset not yet instantiated. |
19049
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
386 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
|
387 bold, demobold, italic, oblique, |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
388 bold-italic, demibold-italic, bold-oblique, demibold-oblique. |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
389 FONTLIST is an alist of charsets vs font names to be used in FONSET.") |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
390 |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
391 (defconst x-style-funcs-alist |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
392 '((bold x-make-font-bold) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
393 (demibold x-make-font-demibold) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
394 (italic x-make-font-italic) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
395 (oblique x-make-font-oblique) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
396 (bold-italic x-make-font-bold x-make-font-italic) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
397 (demibold-italic x-make-font-demibold x-make-font-italic) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
398 (demibold-oblique x-make-font-demibold x-make-font-oblique) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
399 (bold-oblique x-make-font-bold x-make-font-oblique)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
400 "Alist of font style vs functions to generate a X font name of the style.") |
19049
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
401 |
22128
8f7a59fc78db
(create-fontset-from-fontset-spec): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
19771
diff
changeset
|
402 ;;;###autoload |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
403 (defun create-fontset-from-fontset-spec (fontset-spec |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
404 &optional style-variant-p noerror) |
17052 | 405 "Create a fontset from fontset specification string FONTSET-SPEC. |
406 FONTSET-SPEC is a string of the format: | |
407 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
|
408 Any number of SPACE, TAB, and NEWLINE can be put before and after commas. |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
409 If optional argument STYLE-VARIANT-P is specified, it also creates |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
410 fontsets which differs from FONTSET-NAME in styles (e.g. bold, italic). |
18719
de8249499f33
(create-fontset-from-fontset-spec): Typo in doc-string fixed.
Kenichi Handa <handa@m17n.org>
parents:
18714
diff
changeset
|
411 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
|
412 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
|
413 (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
|
414 (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
|
415 (let ((idx (match-end 0)) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
416 (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
|
417 fontlist charset) |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
418 (if (query-fontset name) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
419 (or noerror |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
420 (error "Fontset \"%s\" already exists")) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
421 ;; At first, extract pairs of charset and fontname from FONTSET-SPEC. |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
422 (while (string-match "[, \t\n]*\\([^:]+\\):\\([^,]+\\)" fontset-spec idx) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
423 (setq idx (match-end 0)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
424 (setq charset (intern (match-string 1 fontset-spec))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
425 (if (charsetp charset) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
426 (setq fontlist (cons (cons charset (match-string 2 fontset-spec)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
427 fontlist)))) |
17755
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
428 |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
429 (if style-variant-p |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
430 ;; Generate fontset names of style variants and set them in |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
431 ;; uninstantiated-fontset-alist. |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
432 (let ((style-funcs-alist x-style-funcs-alist) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
433 new-name style funcs) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
434 (while style-funcs-alist |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
435 (setq style (car (car style-funcs-alist)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
436 funcs (cdr (car style-funcs-alist))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
437 (setq new-name name) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
438 (while funcs |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
439 (setq new-name (funcall (car funcs) new-name)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
440 (setq funcs (cdr funcs))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
441 (setq uninstantiated-fontset-alist |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
442 (cons (list new-name style fontlist) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
443 uninstantiated-fontset-alist)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
444 (setq style-funcs-alist (cdr style-funcs-alist))))) |
19049
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
445 |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
446 ;; If NAME conforms to XLFD, complement FONTLIST for charsets |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
447 ;; which are not specified in FONTSET-SPEC. |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
448 (let ((xlfd-fields (x-decompose-font-name name))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
449 (if xlfd-fields |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
450 (setq fontlist |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
451 (x-complement-fontset-spec xlfd-fields fontlist)))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
452 |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
453 ;; Create the fontset. |
18714
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
454 (new-fontset name fontlist) |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
455 |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
456 ;; Define the alias (short name) if appropriate. |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
457 (if (and (not (assoc name fontset-alias-alist)) |
18714
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
458 (string-match "fontset-.*$" name)) |
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
459 (let ((alias (match-string 0 name))) |
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
460 (or (rassoc alias fontset-alias-alist) |
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
461 (setq fontset-alias-alist |
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
462 (cons (cons name alias) fontset-alias-alist)))))))) |
17052 | 463 |
19771
7de156b57f00
(uninstantiated-fontset-alist):
Richard M. Stallman <rms@gnu.org>
parents:
19456
diff
changeset
|
464 (defun instantiate-fontset (fontset) |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
465 "Make FONTSET be readly to use. |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
466 FONTSET should be in the variable `uninstantiated-fontset-alist' in advance. |
19049
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
467 Return FONTSET if it is created successfully, else return nil." |
19771
7de156b57f00
(uninstantiated-fontset-alist):
Richard M. Stallman <rms@gnu.org>
parents:
19456
diff
changeset
|
468 (let ((fontset-data (assoc fontset uninstantiated-fontset-alist))) |
19049
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
469 (if (null fontset-data) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
470 nil |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
471 (let* ((xlfd-fields (x-decompose-font-name fontset)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
472 (fontlist (x-complement-fontset-spec xlfd-fields |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
473 (nth 2 fontset-data))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
474 (funcs (cdr (assq (nth 1 fontset-data) x-style-funcs-alist))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
475 ascii-font font font2) |
19771
7de156b57f00
(uninstantiated-fontset-alist):
Richard M. Stallman <rms@gnu.org>
parents:
19456
diff
changeset
|
476 (setq uninstantiated-fontset-alist |
7de156b57f00
(uninstantiated-fontset-alist):
Richard M. Stallman <rms@gnu.org>
parents:
19456
diff
changeset
|
477 (delete fontset-data uninstantiated-fontset-alist)) |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
478 (setq fontlist (x-complement-fontset-spec xlfd-fields fontlist)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
479 |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
480 ;; At first, check if ASCII font of this style is surely available. |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
481 (setq ascii-font (cdr (assq 'ascii fontlist))) |
19049
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
482 (if (= (length funcs) 1) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
483 (and (setq font (funcall (car funcs) ascii-font)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
484 (setq font (x-resolve-font-name font 'default))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
485 (and (setq font (funcall (car funcs) ascii-font)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
486 (not (equal font ascii-font)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
487 (setq font2 (funcall (nth 1 funcs) font)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
488 (not (equal font2 font)) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
489 (setq font (x-resolve-font-name font2 'default)))) |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
490 |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
491 ;; If ASCII font is available, instantiate the fontset. |
19049
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
492 (when font |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
493 (let ((new-fontlist (list (cons 'ascii font)))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
494 (while fontlist |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
495 (setq font (cdr (car fontlist))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
496 (or (eq (car (car fontlist)) 'ascii) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
497 (if (if (= (length funcs) 1) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
498 (setq font (funcall (car funcs) font)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
499 (and (setq font (funcall (car funcs) font)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
500 (not (equal font (cdr (car fontlist)))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
501 (setq font2 (funcall (nth 1 funcs) font)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
502 (not (equal font2 font)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
503 (setq font font2))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
504 (setq new-fontlist |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
505 (cons (cons (car fontlist) font) new-fontlist)))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
506 (setq fontlist (cdr fontlist))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
507 (new-fontset fontset (x-complement-fontset-spec xlfd-fields |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
508 fontlist)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
509 fontset)))))) |
17052 | 510 |
17842
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
511 ;; 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
|
512 ;; 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
|
513 ;; 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
|
514 ;; many cases. |
17842
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
515 (defvar standard-fontset-spec |
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
516 "-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard, |
17052 | 517 chinese-gb2312:-*-medium-r-normal-*-16-*-gb2312*-*, |
518 korean-ksc5601:-*-medium-r-normal-*-16-*-ksc5601*-*, | |
519 chinese-cns11643-1:-*-medium-r-normal-*-16-*-cns11643*-1, | |
520 chinese-cns11643-2:-*-medium-r-normal-*-16-*-cns11643*-2, | |
521 chinese-cns11643-3:-*-medium-r-normal-*-16-*-cns11643*-3, | |
522 chinese-cns11643-4:-*-medium-r-normal-*-16-*-cns11643*-4, | |
523 chinese-cns11643-5:-*-medium-r-normal-*-16-*-cns11643*-5, | |
524 chinese-cns11643-6:-*-medium-r-normal-*-16-*-cns11643*-6, | |
525 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
|
526 "String of fontset spec of the standard fontset. |
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
527 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
|
528 with correct glyphs by using the standard fontset. |
17052 | 529 See the documentation of `create-fontset-from-fontset-spec' for the format.") |
530 | |
531 ;; Create fontsets from X resources of the name `fontset-N (class | |
532 ;; Fontset-N)' where N is integer 0, 1, ... | |
533 ;; 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
|
534 ;; `standard-fontset-spec'. |
17052 | 535 |
536 (defun create-fontset-from-x-resource () | |
537 (let ((idx 0) | |
538 fontset-spec) | |
539 (while (setq fontset-spec (x-get-resource (concat "fontset-" idx) | |
540 (concat "Fontset-" idx))) | |
18714
5d47a06d19bf
(create-fontset-from-fontset-spec): Add
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
541 (create-fontset-from-fontset-spec fontset-spec nil 'noerror) |
17052 | 542 (setq idx (1+ idx))))) |
543 | |
544 (defsubst fontset-list () | |
545 "Returns a list of all defined fontset names." | |
546 (mapcar 'car global-fontset-alist)) | |
547 | |
548 ;; | |
549 (provide 'fontset) | |
550 | |
551 ;;; fontset.el ends here |