]> code.delx.au - gnu-emacs/blob - lisp/international/fontset.el
(miscdic-convert): For MS-DOS, if
[gnu-emacs] / lisp / international / fontset.el
1 ;;; fontset.el --- Commands for handling fontset.
2
3 ;; Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation.
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
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.
24
25 ;;; Code:
26
27 ;; Set standard fontname specification of characters in the default
28 ;; fontset to find an appropriate font for each charset. This is used
29 ;; to generate a font name for a fontset if the fontset doesn't
30 ;; specify a font name for a specific character. The specification
31 ;; has the form (FAMILY . REGISTRY). FAMILY may be nil, in which
32 ;; case, the family name of default face is used. If REGISTRY
33 ;; contains a character `-', the string before that is embedded in
34 ;; `CHARSET_REGISTRY' field, and the string after that is embedded in
35 ;; `CHARSET_ENCODING' field. If it does not contain `-', the whole
36 ;; string is embedded in `CHARSET_REGISTRY' field, and a wild card
37 ;; character `*' is embedded in `CHARSET_ENCODING' field. The
38 ;; REGISTRY for ASCII characters are predefined as "ISO8859-1".
39
40 (let ((l `((latin-iso8859-1 . (nil . "ISO8859-1"))
41 (latin-iso8859-2 . (nil . "ISO8859-2"))
42 (latin-iso8859-3 . (nil . "ISO8859-3"))
43 (latin-iso8859-4 . (nil . "ISO8859-4"))
44 (thai-tis620 . ("*" . "TIS620"))
45 (greek-iso8859-7 . ("*" . "ISO8859-7"))
46 (arabic-iso8859-6 . ("*" . "ISO8859-6"))
47 (hebrew-iso8859-8 . ("*" . "ISO8859-8"))
48 (katakana-jisx0201 . ("*" . "JISX0201"))
49 (latin-jisx0201 . (nil . "JISX0201"))
50 (cyrillic-iso8859-5 . ("*" . "ISO8859-5"))
51 (latin-iso8859-9 . (nil . "ISO8859-9"))
52 (japanese-jisx0208-1978 . ("*" . "JISX0208.1978"))
53 (chinese-gb2312 . ("*" . "GB2312.1980"))
54 (japanese-jisx0208 . ("*" . "JISX0208.1990"))
55 (korean-ksc5601 . ("*" . "KSC5601.1989"))
56 (japanese-jisx0212 . ("*" . "JISX0212"))
57 (chinese-cns11643-1 . ("*" . "CNS11643.1992-1"))
58 (chinese-cns11643-2 . ("*" . "CNS11643.1992-2"))
59 (chinese-cns11643-3 . ("*" . "CNS11643.1992-3"))
60 (chinese-cns11643-4 . ("*" . "CNS11643.1992-4"))
61 (chinese-cns11643-5 . ("*" . "CNS11643.1992-5"))
62 (chinese-cns11643-6 . ("*" . "CNS11643.1992-6"))
63 (chinese-cns11643-7 . ("*" . "CNS11643.1992-7"))
64 (chinese-big5-1 . ("*" . "Big5"))
65 (chinese-big5-2 . ("*" . "Big5"))
66 (chinese-sisheng . (nil . "sisheng_cwnn"))
67 (vietnamese-viscii-lower . (nil . "VISCII1.1"))
68 (vietnamese-viscii-upper . (nil . "VISCII1.1"))
69 (arabic-digit . ("*" . "MuleArabic-0"))
70 (arabic-1-column . ("*" . "MuleArabic-1"))
71 (arabic-2-column . ("*" . "MuleArabic-2"))
72 (ipa . (nil . "MuleIPA"))
73 (ethiopic . ("*" . "Ethiopic-Unicode"))
74 (ascii-right-to-left . (nil . "ISO8859-1"))
75 (indian-is13194 . ("*" . "IS13194-Devanagari"))
76 (indian-2-column . ("*" . "MuleIndian-2"))
77 (indian-1-column . ("*" . "MuleIndian-1"))
78 (lao . ("*" . "MuleLao-1"))
79 (tibetan . ("proportional" . "MuleTibetan-2"))
80 (tibetan-1-column . ("*" . "MuleTibetan-1"))
81 (latin-iso8859-14 . (nil . "ISO8859-14"))
82 (latin-iso8859-15 . (nil . "ISO8859-15"))
83 (mule-unicode-0100-24ff . (nil . "ISO10646-1"))
84 (mule-unicode-2500-33ff . (nil . "ISO10646-1"))
85 (mule-unicode-e000-ffff . (nil . "ISO10646-1"))
86 (japanese-jisx0213-1 . ("*" . "JISX0213.2000-1"))
87 (japanese-jisx0213-2 . ("*" . "JISX0213.2000-2"))
88 ))
89 charset font-spec arg)
90 (while l
91 (setq charset (car (car l)) font-spec (cdr (car l)) l (cdr l))
92 (if (symbolp charset)
93 (setq arg (make-char charset))
94 (setq arg charset))
95 (set-fontset-font "fontset-default" arg font-spec)))
96
97 ;; Set arguments in `font-encoding-alist' (which see).
98 (defun set-font-encoding (pattern charset encoding)
99 (let ((slot (assoc pattern font-encoding-alist)))
100 (if slot
101 (let ((place (assq charset (cdr slot))))
102 (if place
103 (setcdr place encoding)
104 (setcdr slot (cons (cons charset encoding) (cdr slot)))))
105 (setq font-encoding-alist
106 (cons (list pattern (cons charset encoding)) font-encoding-alist)))
107 ))
108
109 (set-font-encoding "ISO8859-1" 'ascii 0)
110 (set-font-encoding "JISX0201" 'latin-jisx0201 0)
111
112 (define-ccl-program ccl-encode-unicode-font
113 `(0
114 (if (r0 == ,(charset-id 'ascii))
115 ((r2 = r1)
116 (r1 = 0))
117 (if (r0 == ,(charset-id 'latin-iso8859-1))
118 ((r2 = (r1 + 128))
119 (r1 = 0))
120 (if (r0 == ,(charset-id 'mule-unicode-0100-24ff))
121 ((r1 *= 96)
122 (r1 += r2)
123 (r1 += ,(- #x100 (* 32 96) 32))
124 (r1 >8= 0)
125 (r2 = r7))
126 (if (r0 == ,(charset-id 'mule-unicode-2500-33ff))
127 ((r1 *= 96)
128 (r1 += r2)
129 (r1 += ,(- #x2500 (* 32 96) 32))
130 (r1 >8= 0)
131 (r2 = r7))
132 (if (r0 == ,(charset-id 'mule-unicode-e000-ffff))
133 ((r1 *= 96)
134 (r1 += r2)
135 (r1 += ,(- #xe000 (* 32 96) 32))
136 (r1 >8= 0)
137 (r2 = r7)))))))))
138
139 (setq font-ccl-encoder-alist
140 (cons '("ISO10646-1" . ccl-encode-unicode-font)
141 font-ccl-encoder-alist))
142
143 ;; Setting for suppressing XLoadQueryFont on big fonts.
144 (setq x-pixel-size-width-font-regexp
145 "gb2312\\|jisx0208\\|ksc5601\\|cns11643\\|big5")
146
147 ;; These fonts require vertical centering.
148 (setq vertical-centering-font-regexp
149 "gb2312\\|jisx0208\\|jisx0212\\|ksc5601\\|cns11643\\|big5")
150
151 (defvar x-font-name-charset-alist
152 '(("iso8859-1" ascii latin-iso8859-1)
153 ("iso8859-2" ascii latin-iso8859-2)
154 ("iso8859-3" ascii latin-iso8859-3)
155 ("iso8859-4" ascii latin-iso8859-4)
156 ("iso8859-5" ascii cyrillic-iso8859-5)
157 ("iso8859-6" ascii arabic-iso8859-6)
158 ("iso8859-7" ascii greek-iso8859-7)
159 ("iso8859-8" ascii hebrew-iso8859-8)
160 ("iso8859-14" ascii latin-iso8859-14)
161 ("iso8859-15" ascii latin-iso8859-15)
162 ("tis620" ascii thai-tis620)
163 ("koi8" ascii cyrillic-iso8859-5)
164 ("viscii" ascii vietnamese-viscii-upper vietnamese-viscii-lower)
165 ("vscii" ascii vietnamese-viscii-upper vietnamese-viscii-lower)
166 ("mulelao-1" ascii lao)
167 ("iso10646-1" ascii latin-iso8859-1 mule-unicode-0100-24ff
168 mule-unicode-2500-33ff mule-unicode-e000-ffff))
169 "Alist of font names vs list of charsets the font can display.
170
171 When a font name which matches some element of this alist is given as
172 `-fn' command line argument or is specified by X resource, a fontset
173 which uses the specified font for the corresponding charsets are
174 created and used for the initial frame.")
175
176 ;;; XLFD (X Logical Font Description) format handler.
177
178 ;; Define XLFD's field index numbers. ; field name
179 (defconst xlfd-regexp-foundry-subnum 0) ; FOUNDRY
180 (defconst xlfd-regexp-family-subnum 1) ; FAMILY_NAME
181 (defconst xlfd-regexp-weight-subnum 2) ; WEIGHT_NAME
182 (defconst xlfd-regexp-slant-subnum 3) ; SLANT
183 (defconst xlfd-regexp-swidth-subnum 4) ; SETWIDTH_NAME
184 (defconst xlfd-regexp-adstyle-subnum 5) ; ADD_STYLE_NAME
185 (defconst xlfd-regexp-pixelsize-subnum 6) ; PIXEL_SIZE
186 (defconst xlfd-regexp-pointsize-subnum 7) ; POINT_SIZE
187 (defconst xlfd-regexp-resx-subnum 8) ; RESOLUTION_X
188 (defconst xlfd-regexp-resy-subnum 9) ; RESOLUTION_Y
189 (defconst xlfd-regexp-spacing-subnum 10) ; SPACING
190 (defconst xlfd-regexp-avgwidth-subnum 11) ; AVERAGE_WIDTH
191 (defconst xlfd-regexp-registry-subnum 12) ; CHARSET_REGISTRY
192 (defconst xlfd-regexp-encoding-subnum 13) ; CHARSET_ENCODING
193
194 ;; Regular expression matching against a fontname which conforms to
195 ;; XLFD (X Logical Font Description). All fields in XLFD should be
196 ;; not be omitted (but can be a wild card) to be matched.
197 (defconst xlfd-tight-regexp
198 "^\
199 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\
200 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\
201 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)$")
202
203 ;; List of field numbers of XLFD whose values are numeric.
204 (defconst xlfd-regexp-numeric-subnums
205 (list xlfd-regexp-pixelsize-subnum ;6
206 xlfd-regexp-pointsize-subnum ;7
207 xlfd-regexp-resx-subnum ;8
208 xlfd-regexp-resy-subnum ;9
209 xlfd-regexp-avgwidth-subnum ;11
210 ))
211
212 (defun x-decompose-font-name (pattern)
213 "Decompose PATTERN into XLFD's fields and return vector of the fields.
214 The length of the vector is 14.
215
216 If PATTERN doesn't conform to XLFD, try to get a full XLFD name from
217 X server and use the information of the full name to decompose
218 PATTERN. If no full XLFD name is gotten, return nil."
219 (let (xlfd-fields fontname)
220 (if (string-match xlfd-tight-regexp pattern)
221 (let ((i 0))
222 (setq xlfd-fields (make-vector 14 nil))
223 (while (< i 14)
224 (aset xlfd-fields i (match-string (1+ i) pattern))
225 (setq i (1+ i)))
226 xlfd-fields)
227 (setq fontname (condition-case nil
228 (x-resolve-font-name pattern)
229 (error)))
230 (if (and fontname
231 (string-match xlfd-tight-regexp fontname))
232 ;; We get a full XLFD name.
233 (let ((len (length pattern))
234 (i 0)
235 l)
236 ;; Setup xlfd-fields by the full XLFD name. Each element
237 ;; should be a cons of matched index and matched string.
238 (setq xlfd-fields (make-vector 14 nil))
239 (while (< i 14)
240 (aset xlfd-fields i
241 (cons (match-beginning (1+ i))
242 (match-string (1+ i) fontname)))
243 (setq i (1+ i)))
244
245 ;; Replace wild cards in PATTERN by regexp codes.
246 (setq i 0)
247 (while (< i len)
248 (let ((ch (aref pattern i)))
249 (if (= ch ??)
250 (setq pattern (concat (substring pattern 0 i)
251 "\\(.\\)"
252 (substring pattern (1+ i)))
253 len (+ len 4)
254 i (+ i 4))
255 (if (= ch ?*)
256 (setq pattern (concat (substring pattern 0 i)
257 "\\(.*\\)"
258 (substring pattern (1+ i)))
259 len (+ len 5)
260 i (+ i 5))
261 (setq i (1+ i))))))
262
263 ;; Set each element of xlfd-fields to proper strings.
264 (if (string-match pattern fontname)
265 ;; The regular expression PATTERN matchs the full XLFD
266 ;; name. Set elements that correspond to a wild card
267 ;; in PATTERN to "*", set the other elements to the
268 ;; exact strings in PATTERN.
269 (let ((l (cdr (cdr (match-data)))))
270 (setq i 0)
271 (while (< i 14)
272 (if (or (null l) (< (car (aref xlfd-fields i)) (car l)))
273 (progn
274 (aset xlfd-fields i (cdr (aref xlfd-fields i)))
275 (setq i (1+ i)))
276 (if (< (car (aref xlfd-fields i)) (car (cdr l)))
277 (progn
278 (aset xlfd-fields i "*")
279 (setq i (1+ i)))
280 (setq l (cdr (cdr l)))))))
281 ;; Set each element of xlfd-fields to the exact string
282 ;; in the corresonding fields in full XLFD name.
283 (setq i 0)
284 (while (< i 14)
285 (aset xlfd-fields i (cdr (aref xlfd-fields i)))
286 (setq i (1+ i))))
287 xlfd-fields)))))
288
289 ;; Replace consecutive wild-cards (`*') in NAME to one.
290 ;; Ex. (x-reduce-font-name "-*-*-*-iso8859-1") => "-*-iso8859-1"
291 (defsubst x-reduce-font-name (name)
292 (while (string-match "-\\*-\\(\\*-\\)+" name)
293 (setq name (replace-match "-*-" t t name)))
294 name)
295
296 (defun x-compose-font-name (fields &optional reduce)
297 "Compose X's fontname from FIELDS.
298 FIELDS is a vector of XLFD fields, the length 14.
299 If a field is nil, wild-card letter `*' is embedded.
300 Optional argument REDUCE is always ignored. It exists just for
301 backward compatibility."
302 (concat "-" (mapconcat (lambda (x) (or x "*")) fields "-")))
303
304 (defun x-complement-fontset-spec (xlfd-fields fontlist)
305 "Complement FONTLIST for charsets based on XLFD-FIELDS and return it.
306 XLFD-FIELDS is a vector of XLFD (X Logical Font Description) fields.
307 FONTLIST is an alist of charsets vs the corresponding font names.
308
309 The fonts are complemented as below.
310
311 If FONTLIST doesn't specify a font for ASCII charset, generate a font
312 name for the charset from XLFD-FIELDS, and add that information to
313 FONTLIST.
314
315 If a font specifid for ASCII supports the other charsets (see the
316 variable `x-font-name-charset-alist'), add that information to FONTLIST."
317 (let* ((slot (assq 'ascii fontlist))
318 (ascii-font (cdr slot))
319 ascii-font-spec)
320 (if ascii-font
321 (setcdr slot (setq ascii-font (x-resolve-font-name ascii-font)))
322 ;; If font for ASCII is not specified, add it.
323 (aset xlfd-fields xlfd-regexp-registry-subnum "iso8859")
324 (aset xlfd-fields xlfd-regexp-encoding-subnum "1")
325 (setq ascii-font (x-resolve-font-name (x-compose-font-name xlfd-fields)))
326 (setq fontlist (cons (cons 'ascii ascii-font) fontlist)))
327
328 ;; If the font for ASCII also supports the other charsets, and
329 ;; they are not specified in FONTLIST, add them.
330 (setq xlfd-fields (x-decompose-font-name ascii-font))
331 (if (not xlfd-fields)
332 (setq ascii-font-spec ascii-font)
333 (setq ascii-font-spec
334 (cons (format "%s-%s"
335 (aref xlfd-fields xlfd-regexp-foundry-subnum)
336 (aref xlfd-fields xlfd-regexp-family-subnum))
337 (format "%s-%s"
338 (aref xlfd-fields xlfd-regexp-registry-subnum)
339 (aref xlfd-fields xlfd-regexp-encoding-subnum)))))
340 (let ((tail x-font-name-charset-alist)
341 elt)
342 (while tail
343 (setq elt (car tail) tail (cdr tail))
344 (if (string-match (car elt) ascii-font)
345 (let ((charsets (cdr elt))
346 charset)
347 (while charsets
348 (setq charset (car charsets) charsets (cdr charsets))
349 (or (assq charset fontlist)
350 (setq fontlist
351 (cons (cons charset ascii-font-spec) fontlist))))))))
352
353 fontlist))
354
355 (defun fontset-name-p (fontset)
356 "Return non-nil if FONTSET is valid as fontset name.
357 A valid fontset name should conform to XLFD (X Logical Font Description)
358 with \"fontset\" in `<CHARSET_REGISTRY> field."
359 (and (string-match xlfd-tight-regexp fontset)
360 (string= (match-string (1+ xlfd-regexp-registry-subnum) fontset)
361 "fontset")))
362
363 ;; Return a list to be appended to `x-fixed-font-alist' when
364 ;; `mouse-set-font' is called.
365 (defun generate-fontset-menu ()
366 (let ((fontsets (fontset-list))
367 fontset-name
368 l)
369 (while fontsets
370 (setq fontset-name (car fontsets) fontsets (cdr fontsets))
371 (setq l (cons (list (fontset-plain-name fontset-name) fontset-name) l)))
372 (cons "Fontset"
373 (sort l (function (lambda (x y) (string< (car x) (car y))))))))
374
375 (defun fontset-plain-name (fontset)
376 "Return a plain and descriptive name of FONTSET."
377 (if (not (setq fontset (query-fontset fontset)))
378 (error "Invalid fontset: %s" fontset))
379 (let ((xlfd-fields (x-decompose-font-name fontset)))
380 (if xlfd-fields
381 (let ((weight (aref xlfd-fields xlfd-regexp-weight-subnum))
382 (slant (aref xlfd-fields xlfd-regexp-slant-subnum))
383 (swidth (aref xlfd-fields xlfd-regexp-swidth-subnum))
384 (size (aref xlfd-fields xlfd-regexp-pixelsize-subnum))
385 (charset (aref xlfd-fields xlfd-regexp-registry-subnum))
386 (nickname (aref xlfd-fields xlfd-regexp-encoding-subnum))
387 name)
388 (if (not (string= "fontset" charset))
389 fontset
390 (if (> (string-to-int size) 0)
391 (setq name (format "%s: %s-dot" nickname size))
392 (setq name nickname))
393 (cond ((string-match "^medium$" weight)
394 (setq name (concat name " " "medium")))
395 ((string-match "^bold$\\|^demibold$" weight)
396 (setq name (concat name " " weight))))
397 (cond ((string-match "^i$" slant)
398 (setq name (concat name " " "italic")))
399 ((string-match "^o$" slant)
400 (setq name (concat name " " "slant")))
401 ((string-match "^ri$" slant)
402 (setq name (concat name " " "reverse italic")))
403 ((string-match "^ro$" slant)
404 (setq name (concat name " " "reverse slant"))))
405 name))
406 fontset)))
407
408 ;;;###autoload
409 (defun create-fontset-from-fontset-spec (fontset-spec
410 &optional style-variant noerror)
411 "Create a fontset from fontset specification string FONTSET-SPEC.
412 FONTSET-SPEC is a string of the format:
413 FONTSET-NAME,CHARSET-NAME0:FONT-NAME0,CHARSET-NAME1:FONT-NAME1, ...
414 Any number of SPACE, TAB, and NEWLINE can be put before and after commas.
415
416 Optional 2nd argument is ignored. It exists just for backward
417 compatibility.
418
419 If this function attempts to create already existing fontset, error is
420 signaled unless the optional 3rd argument NOERROR is non-nil.
421
422 It returns a name of the created fontset."
423 (if (not (string-match "^[^,]+" fontset-spec))
424 (error "Invalid fontset spec: %s" fontset-spec))
425 (setq fontset-spec (downcase fontset-spec))
426 (let ((idx (match-end 0))
427 (name (match-string 0 fontset-spec))
428 xlfd-fields charset fontlist ascii-font)
429 (if (query-fontset name)
430 (or noerror
431 (error "Fontset \"%s\" already exists" name))
432 (setq xlfd-fields (x-decompose-font-name name))
433 (or xlfd-fields
434 (error "Fontset \"%s\" not conforming to XLFD" name))
435
436 ;; At first, extract pairs of charset and fontname from FONTSET-SPEC.
437 (while (string-match "[, \t\n]*\\([^:]+\\):\\([^,]+\\)" fontset-spec idx)
438 (setq idx (match-end 0))
439 (setq charset (intern (match-string 1 fontset-spec)))
440 (if (charsetp charset)
441 (setq fontlist (cons (cons charset (match-string 2 fontset-spec))
442 fontlist))))
443 (setq ascii-font (cdr (assq 'ascii fontlist)))
444
445 ;; Complement FONTLIST.
446 (setq fontlist (x-complement-fontset-spec xlfd-fields fontlist))
447
448 (new-fontset name fontlist)
449
450 ;; Define the short name alias.
451 (if (and (string-match "fontset-.*$" name)
452 (not (assoc name fontset-alias-alist)))
453 (let ((alias (match-string 0 name)))
454 (or (rassoc alias fontset-alias-alist)
455 (setq fontset-alias-alist
456 (cons (cons name alias) fontset-alias-alist)))))
457
458 ;; Define the ASCII font name alias.
459 (or ascii-font
460 (setq ascii-font (cdr (assq 'ascii fontlist))))
461 (or (rassoc ascii-font fontset-alias-alist)
462 (setq fontset-alias-alist
463 (cons (cons name ascii-font)
464 fontset-alias-alist))))
465
466 name))
467
468 (defun create-fontset-from-ascii-font (font &optional resolved-font
469 fontset-name)
470 "Create a fontset from an ASCII font FONT.
471
472 Optional 1st arg RESOLVED-FONT is a resolved name of FONT. If
473 omitted, x-resolve-font-name is called to get the resolved name. At
474 this time, if FONT is not available, error is signaled.
475
476 Optional 2nd arg FONTSET-NAME is a string to be used in
477 `<CHARSET_ENCODING>' fields of a new fontset name. If it is omitted,
478 an appropriate name is generated automatically.
479
480 It returns a name of the created fontset."
481 (setq font (downcase font))
482 (if resolved-font
483 (setq resolved-font (downcase resolved-font))
484 (setq resolved-font (downcase (x-resolve-font-name font))))
485 (let ((xlfd (x-decompose-font-name font))
486 (resolved-xlfd (x-decompose-font-name resolved-font))
487 fontset fontset-spec)
488 (aset xlfd xlfd-regexp-foundry-subnum nil)
489 (aset xlfd xlfd-regexp-family-subnum nil)
490 (aset xlfd xlfd-regexp-registry-subnum "fontset")
491 (if fontset-name
492 (setq fontset-name (downcase fontset-name))
493 (setq fontset-name
494 (format "%s_%s_%s"
495 (aref resolved-xlfd xlfd-regexp-registry-subnum)
496 (aref resolved-xlfd xlfd-regexp-encoding-subnum)
497 (aref resolved-xlfd xlfd-regexp-pixelsize-subnum))))
498 (aset xlfd xlfd-regexp-encoding-subnum fontset-name)
499 (setq fontset (x-compose-font-name xlfd))
500 (or (query-fontset fontset)
501 (create-fontset-from-fontset-spec (concat fontset ", ascii:" font)))))
502
503 \f
504 ;; Create standard fontset from 16 dots fonts which are the most widely
505 ;; installed fonts. Fonts for Chinese-GB, Korean, and Chinese-CNS are
506 ;; specified here because FAMILY of those fonts are not "fixed" in
507 ;; many cases.
508 (defvar standard-fontset-spec
509 (purecopy "-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard,
510 chinese-gb2312:-*-medium-r-normal-*-16-*-gb2312*-*,
511 korean-ksc5601:-*-medium-r-normal-*-16-*-ksc5601*-*,
512 chinese-cns11643-1:-*-medium-r-normal-*-16-*-cns11643*-1,
513 chinese-cns11643-2:-*-medium-r-normal-*-16-*-cns11643*-2,
514 chinese-cns11643-3:-*-medium-r-normal-*-16-*-cns11643*-3,
515 chinese-cns11643-4:-*-medium-r-normal-*-16-*-cns11643*-4,
516 chinese-cns11643-5:-*-medium-r-normal-*-16-*-cns11643*-5,
517 chinese-cns11643-6:-*-medium-r-normal-*-16-*-cns11643*-6,
518 chinese-cns11643-7:-*-medium-r-normal-*-16-*-cns11643*-7")
519 "String of fontset spec of the standard fontset.
520 You have the biggest chance to display international characters
521 with correct glyphs by using the standard fontset.
522 See the documentation of `create-fontset-from-fontset-spec' for the format.")
523
524 ;; Create fontsets from X resources of the name `fontset-N (class
525 ;; Fontset-N)' where N is integer 0, 1, ...
526 ;; The values of the resources the string of the same format as
527 ;; `standard-fontset-spec'.
528
529 (defun create-fontset-from-x-resource ()
530 (let ((idx 0)
531 fontset-spec)
532 (while (setq fontset-spec (x-get-resource (format "fontset-%d" idx)
533 (format "Fontset-%d" idx)))
534 (create-fontset-from-fontset-spec fontset-spec t 'noerror)
535 (setq idx (1+ idx)))))
536
537 ;;
538 (provide 'fontset)
539
540 ;;; fontset.el ends here