annotate lisp/international/fontset.el @ 25213:11d01c90da6d

(realize_default_face) [MSDOS]: Don't take default colors from the frame here. (realize_tty_face) [MSDOS]: Do it here. Update the face attributes with the actual name of the color taken from the frame.
author Eli Zaretskii <eliz@gnu.org>
date Tue, 10 Aug 1999 10:38:37 +0000
parents 38dc0ce2bf99
children 987e55950346
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1 ;;; fontset.el --- Commands for handling fontset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
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
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6 ;; Keywords: mule, multilingual, fontset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
7
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
9
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13 ;; any later version.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
14
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
19
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
23 ;; Boston, MA 02111-1307, USA.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
24
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
25 ;;; Code:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
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
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
28 ;; font for each charset. This is used to generate a font name in a
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
29 ;; fontset. If the value contains a character `-', the string before
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23161
diff changeset
30 ;; that is embedded in `CHARSET_REGISTRY' field, and the string after
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23161
diff changeset
31 ;; that is embedded in `CHARSET_ENCODING' field. If the value does not
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23161
diff changeset
32 ;; contain `-', the whole string is embedded in `CHARSET_REGISTRY'
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23161
diff changeset
33 ;; field, and a wild card character `*' is embedded in
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
34 ;; `CHARSET_ENCODING' field.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
35
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
36 (defvar x-charset-registries
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
37 '((ascii . "ISO8859-1")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
38 (latin-iso8859-1 . "ISO8859-1")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
39 (latin-iso8859-2 . "ISO8859-2")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40 (latin-iso8859-3 . "ISO8859-3")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41 (latin-iso8859-4 . "ISO8859-4")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42 (thai-tis620 . "TIS620")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
43 (greek-iso8859-7 . "ISO8859-7")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44 (arabic-iso8859-6 . "ISO8859-6")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 (hebrew-iso8859-8 . "ISO8859-8")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 (katakana-jisx0201 . "JISX0201")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
47 (latin-jisx0201 . "JISX0201")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48 (cyrillic-iso8859-5 . "ISO8859-5")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
49 (latin-iso8859-9 . "ISO8859-9")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
50 (japanese-jisx0208-1978 . "JISX0208.1978")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51 (chinese-gb2312 . "GB2312")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
52 (japanese-jisx0208 . "JISX0208.1983")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
53 (korean-ksc5601 . "KSC5601")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54 (japanese-jisx0212 . "JISX0212")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
55 (chinese-cns11643-1 . "CNS11643.1992-1")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
56 (chinese-cns11643-2 . "CNS11643.1992-2")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
57 (chinese-cns11643-3 . "CNS11643.1992-3")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
58 (chinese-cns11643-4 . "CNS11643.1992-4")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
59 (chinese-cns11643-5 . "CNS11643.1992-5")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
60 (chinese-cns11643-6 . "CNS11643.1992-6")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
61 (chinese-cns11643-7 . "CNS11643.1992-7")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
62 (chinese-big5-1 . "Big5")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
63 (chinese-big5-2 . "Big5")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
64 (chinese-sisheng . "sisheng_cwnn")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65 (vietnamese-viscii-lower . "VISCII1.1")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66 (vietnamese-viscii-upper . "VISCII1.1")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
67 (arabic-digit . "MuleArabic-0")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
68 (arabic-1-column . "MuleArabic-1")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
69 (arabic-2-column . "MuleArabic-2")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
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
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
72 (ascii-right-to-left . "ISO8859-1")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
73 (indian-is13194 . "IS13194-Devanagari")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
74 (indian-2-column . "MuleIndian-2")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
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
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
80
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
81 (let ((l x-charset-registries))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
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
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
86 (setq l (cdr l))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
87
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
88 ;; Set arguments in `font-encoding-alist' (which see).
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
89 (defun set-font-encoding (pattern charset encoding)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
90 (let ((slot (assoc pattern font-encoding-alist)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
91 (if slot
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
92 (let ((place (assq charset (cdr slot))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
93 (if place
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
94 (setcdr place encoding)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
95 (setcdr slot (cons (cons charset encoding) (cdr slot)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
96 (setq font-encoding-alist
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
97 (cons (list pattern (cons charset encoding)) font-encoding-alist)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
98 ))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
99
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100 (set-font-encoding "ISO8859-1" 'ascii 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 (set-font-encoding "JISX0201" 'latin-jisx0201 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
102
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
103 ;; Setting for suppressing XLoadQueryFont on big fonts.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
104 (setq x-pixel-size-width-font-regexp
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
105 "gb2312\\|jisx0208\\|ksc5601\\|cns11643\\|big5")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
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
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128 ;;; XLFD (X Logical Font Description) format handler.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
129
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130 ;; Define XLFD's field index numbers. ; field name
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 (defconst xlfd-regexp-foundry-subnum 0) ; FOUNDRY
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 (defconst xlfd-regexp-family-subnum 1) ; FAMILY_NAME
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
133 (defconst xlfd-regexp-weight-subnum 2) ; WEIGHT_NAME
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
134 (defconst xlfd-regexp-slant-subnum 3) ; SLANT
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
135 (defconst xlfd-regexp-swidth-subnum 4) ; SETWIDTH_NAME
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136 (defconst xlfd-regexp-adstyle-subnum 5) ; ADD_STYLE_NAME
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137 (defconst xlfd-regexp-pixelsize-subnum 6) ; PIXEL_SIZE
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138 (defconst xlfd-regexp-pointsize-subnum 7) ; POINT_SIZE
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139 (defconst xlfd-regexp-resx-subnum 8) ; RESOLUTION_X
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140 (defconst xlfd-regexp-resy-subnum 9) ; RESOLUTION_Y
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141 (defconst xlfd-regexp-spacing-subnum 10) ; SPACING
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
142 (defconst xlfd-regexp-avgwidth-subnum 11) ; AVERAGE_WIDTH
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
143 (defconst xlfd-regexp-registry-subnum 12) ; CHARSET_REGISTRY
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
144 (defconst xlfd-regexp-encoding-subnum 13) ; CHARSET_ENCODING
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
145
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
146 ;; Regular expression matching against a fontname which conforms to
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
147 ;; XLFD (X Logical Font Description). All fields in XLFD should be
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148 ;; not be omitted (but can be a wild card) to be matched.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
149 (defconst xlfd-tight-regexp
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
150 "^\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
151 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
152 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
153 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)$")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
154
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
155 ;; List of field numbers of XLFD whose values are numeric.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156 (defconst xlfd-regexp-numeric-subnums
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
157 (list xlfd-regexp-pixelsize-subnum ;6
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
158 xlfd-regexp-pointsize-subnum ;7
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
159 xlfd-regexp-resx-subnum ;8
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
160 xlfd-regexp-resy-subnum ;9
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161 xlfd-regexp-avgwidth-subnum ;11
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
162 ))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
164 (defun x-decompose-font-name (pattern)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165 "Decompose PATTERN into XLFD's fields and return vector of the fields.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166 The length of the vector is 14.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
167
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168 If PATTERN doesn't conform to XLFD, try to get a full XLFD name from
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
169 X server and use the information of the full name to decompose
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170 PATTERN. If no full XLFD name is gotten, return nil."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
171 (let (xlfd-fields fontname)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
172 (if (string-match xlfd-tight-regexp pattern)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
173 (let ((i 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
174 (setq xlfd-fields (make-vector 14 nil))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
175 (while (< i 14)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
176 (aset xlfd-fields i (match-string (1+ i) pattern))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
177 (setq i (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
178 xlfd-fields)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
179 (setq fontname (condition-case nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
180 (x-resolve-font-name pattern)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
181 (error)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
182 (if (and fontname
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
183 (string-match xlfd-tight-regexp fontname))
23890
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
184 ;; We get a full XLFD name.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
185 (let ((len (length pattern))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
186 (i 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
187 l)
23890
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
188 ;; Setup xlfd-fields by the full XLFD name. Each element
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
189 ;; should be a cons of matched index and matched string.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
190 (setq xlfd-fields (make-vector 14 nil))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
191 (while (< i 14)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
192 (aset xlfd-fields i
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
193 (cons (match-beginning (1+ i))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
194 (match-string (1+ i) fontname)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
195 (setq i (1+ i)))
23890
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
196
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
197 ;; Replace wild cards in PATTERN by regexp codes.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
198 (setq i 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
199 (while (< i len)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
200 (let ((ch (aref pattern i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
201 (if (= ch ??)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
202 (setq pattern (concat (substring pattern 0 i)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
203 "\\(.\\)"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
204 (substring pattern (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
205 len (+ len 4)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
206 i (+ i 4))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
207 (if (= ch ?*)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
208 (setq pattern (concat (substring pattern 0 i)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
209 "\\(.*\\)"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
210 (substring pattern (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
211 len (+ len 5)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
212 i (+ i 5))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
213 (setq i (1+ i))))))
23890
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
214
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
215 ;; Set each element of xlfd-fields to proper strings.
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
216 (if (string-match pattern fontname)
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
217 ;; The regular expression PATTERN matchs the full XLFD
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
218 ;; name. Set elements that correspond to a wild card
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
219 ;; in PATTERN to "*", set the other elements to the
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
220 ;; exact strings in PATTERN.
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
221 (let ((l (cdr (cdr (match-data)))))
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
222 (setq i 0)
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
223 (while (< i 14)
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
224 (if (or (null l) (< (car (aref xlfd-fields i)) (car l)))
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
225 (progn
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
226 (aset xlfd-fields i (cdr (aref xlfd-fields i)))
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
227 (setq i (1+ i)))
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
228 (if (< (car (aref xlfd-fields i)) (car (cdr l)))
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
229 (progn
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
230 (aset xlfd-fields i "*")
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
231 (setq i (1+ i)))
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
232 (setq l (cdr (cdr l)))))))
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
233 ;; Set each element of xlfd-fields to the exact string
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
234 ;; in the corresonding fields in full XLFD name.
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
235 (setq i 0)
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
236 (while (< i 14)
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
237 (aset xlfd-fields i (cdr (aref xlfd-fields i)))
fa4839661777 (x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents: 23655
diff changeset
238 (setq i (1+ i))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
239 xlfd-fields)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
240
17177
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
241 ;; 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
242 ;; 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
243 (defsubst x-reduce-font-name (name)
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
244 (while (string-match "-\\*-\\(\\*-\\)+" name)
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
245 (setq name (replace-match "-*-" t t name)))
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
246 name)
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
247
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
248 (defun x-compose-font-name (fields &optional reduce)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
249 "Compose X's fontname from FIELDS.
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
250 FIELDS is a vector of XLFD fields, the length 14.
17177
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
251 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
252 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
253 reduced to be one."
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
254 (let ((name
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
255 (concat "-" (mapconcat (lambda (x) (or x "*")) fields "-"))))
17177
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
256 (if reduce
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
257 (x-reduce-font-name name)
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
258 name)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
259
19456
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
260 (defun register-alternate-fontnames (fontname)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
261 "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
262 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
263 registered in the variable `alternate-fontname-alist' (which see).
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
264
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
265 For FONTNAME, the following three alternate fontnames are registered:
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
266 fontname which ignores style specification of FONTNAME,
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
267 fontname which ignores size specification of FONTNAME,
22161
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
268 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
269 Emacs tries to open fonts in this order."
19456
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
270 (unless (assoc fontname alternate-fontname-alist)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
271 (let ((xlfd-fields (x-decompose-font-name fontname))
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
272 style-ignored size-ignored both-ignored)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
273 (when xlfd-fields
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
274 (aset xlfd-fields xlfd-regexp-foundry-subnum nil)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
275 (aset xlfd-fields xlfd-regexp-family-subnum nil)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
276
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
277 (let ((temp (copy-sequence xlfd-fields)))
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
278 (aset temp xlfd-regexp-weight-subnum nil)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
279 (aset temp xlfd-regexp-slant-subnum nil)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
280 (aset temp xlfd-regexp-swidth-subnum nil)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
281 (aset temp xlfd-regexp-adstyle-subnum nil)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
282 (setq style-ignored (x-compose-font-name temp t)))
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
283
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
284 (aset xlfd-fields xlfd-regexp-pixelsize-subnum nil)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
285 (aset xlfd-fields xlfd-regexp-pointsize-subnum nil)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
286 (aset xlfd-fields xlfd-regexp-resx-subnum nil)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
287 (aset xlfd-fields xlfd-regexp-resy-subnum nil)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
288 (aset xlfd-fields xlfd-regexp-spacing-subnum nil)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
289 (aset xlfd-fields xlfd-regexp-avgwidth-subnum nil)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
290 (setq size-ignored (x-compose-font-name xlfd-fields t))
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
291
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
292 (aset xlfd-fields xlfd-regexp-weight-subnum nil)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
293 (aset xlfd-fields xlfd-regexp-slant-subnum nil)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
294 (aset xlfd-fields xlfd-regexp-swidth-subnum nil)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
295 (aset xlfd-fields xlfd-regexp-adstyle-subnum nil)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
296 (setq both-ignored (x-compose-font-name xlfd-fields t))
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
297
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
298 (setq alternate-fontname-alist
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
299 (cons (list fontname style-ignored size-ignored both-ignored)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
300 alternate-fontname-alist))))))
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
301
23205
22df54cdb841 (resolved-ascii-font): New variable.
Kenichi Handa <handa@m17n.org>
parents: 23196
diff changeset
302 ;; Just to avoid compiler waring. The gloval value is never used.
22df54cdb841 (resolved-ascii-font): New variable.
Kenichi Handa <handa@m17n.org>
parents: 23196
diff changeset
303 (defvar resolved-ascii-font nil)
22df54cdb841 (resolved-ascii-font): New variable.
Kenichi Handa <handa@m17n.org>
parents: 23196
diff changeset
304
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
305 (defun x-complement-fontset-spec (xlfd-fields fontlist)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
306 "Complement FONTLIST for all charsets based on XLFD-FIELDS and return it.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
307 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
308 FONTLIST is an alist of charsets vs the corresponding font names.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
309
22161
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
310 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
311 XLFD-FIELDS and a property of x-charset-registry of each charset
23205
22df54cdb841 (resolved-ascii-font): New variable.
Kenichi Handa <handa@m17n.org>
parents: 23196
diff changeset
312 automatically.
22df54cdb841 (resolved-ascii-font): New variable.
Kenichi Handa <handa@m17n.org>
parents: 23196
diff changeset
313
22df54cdb841 (resolved-ascii-font): New variable.
Kenichi Handa <handa@m17n.org>
parents: 23196
diff changeset
314 By side effect, this sets `resolved-ascii-font' to the resolved name
22df54cdb841 (resolved-ascii-font): New variable.
Kenichi Handa <handa@m17n.org>
parents: 23196
diff changeset
315 of ASCII font."
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
316 (let ((charsets charset-list)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
317 (xlfd-fields-non-ascii (copy-sequence xlfd-fields))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
318 (new-fontlist nil))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
319 (aset xlfd-fields-non-ascii xlfd-regexp-foundry-subnum nil)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
320 (aset xlfd-fields-non-ascii xlfd-regexp-family-subnum nil)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
321 (aset xlfd-fields-non-ascii xlfd-regexp-adstyle-subnum nil)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
322 (aset xlfd-fields-non-ascii xlfd-regexp-avgwidth-subnum nil)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
323 (while charsets
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
324 (let ((charset (car charsets)))
19456
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
325 (unless (assq charset fontlist)
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
326 (let ((registry (get-charset-property charset 'x-charset-registry))
22161
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
327 registry-val encoding-val fontname)
19456
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
328 (if (string-match "-" registry)
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
329 ;; REGISTRY contains `CHARSET_ENCODING' field.
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
330 (setq registry-val (substring registry 0 (match-beginning 0))
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
331 encoding-val (substring registry (match-end 0)))
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
332 (setq registry-val (concat registry "*")
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
333 encoding-val "*"))
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
334 (let ((xlfd (if (eq charset 'ascii) xlfd-fields
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
335 xlfd-fields-non-ascii)))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
336 (aset xlfd xlfd-regexp-registry-subnum registry-val)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
337 (aset xlfd xlfd-regexp-encoding-subnum encoding-val)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
338 (setq fontname (downcase (x-compose-font-name xlfd))))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
339 (setq new-fontlist (cons (cons charset fontname) new-fontlist))
19456
f5627d8c422a (register-alternate-fontnames): New
Kenichi Handa <handa@m17n.org>
parents: 19049
diff changeset
340 (register-alternate-fontnames fontname))))
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
341 (setq charsets (cdr charsets)))
18350
3f4364889538 (x-charset-registries): Name changed for consistency:
Kenichi Handa <handa@m17n.org>
parents: 17989
diff changeset
342
22720
ab4f30149aa0 (x-complement-fontset-spec): Typo fixed.
Kenichi Handa <handa@m17n.org>
parents: 22672
diff changeset
343 ;; Be sure that ASCII font is available.
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
344 (let ((slot (or (assq 'ascii fontlist) (assq 'ascii new-fontlist)))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
345 ascii-font)
23161
55a8313019f3 (x-complement-fontset-spec): If ASCII
Kenichi Handa <handa@m17n.org>
parents: 22720
diff changeset
346 (setq ascii-font (condition-case nil
55a8313019f3 (x-complement-fontset-spec): If ASCII
Kenichi Handa <handa@m17n.org>
parents: 22720
diff changeset
347 (x-resolve-font-name (cdr slot))
55a8313019f3 (x-complement-fontset-spec): If ASCII
Kenichi Handa <handa@m17n.org>
parents: 22720
diff changeset
348 (error nil)))
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
349 (if ascii-font
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
350 (let ((l x-font-name-charset-alist))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
351 ;; If the ASCII font can also be used for another
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
352 ;; charsets, use that font instead of what generated based
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23161
diff changeset
353 ;; on x-charset-registry in the previous code.
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
354 (while l
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
355 (if (string-match (car (car l)) ascii-font)
23205
22df54cdb841 (resolved-ascii-font): New variable.
Kenichi Handa <handa@m17n.org>
parents: 23196
diff changeset
356 (let ((charsets (cdr (car l)))
22df54cdb841 (resolved-ascii-font): New variable.
Kenichi Handa <handa@m17n.org>
parents: 23196
diff changeset
357 slot2)
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
358 (while charsets
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
359 (if (and (not (eq (car charsets) 'ascii))
23205
22df54cdb841 (resolved-ascii-font): New variable.
Kenichi Handa <handa@m17n.org>
parents: 23196
diff changeset
360 (setq slot2 (assq (car charsets) new-fontlist)))
22df54cdb841 (resolved-ascii-font): New variable.
Kenichi Handa <handa@m17n.org>
parents: 23196
diff changeset
361 (setcdr slot2 (cdr slot)))
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
362 (setq charsets (cdr charsets)))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
363 (setq l nil))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
364 (setq l (cdr l))))
23205
22df54cdb841 (resolved-ascii-font): New variable.
Kenichi Handa <handa@m17n.org>
parents: 23196
diff changeset
365 (setq resolved-ascii-font ascii-font)
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
366 (append fontlist new-fontlist))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
367
19049
cad4c032fa26 (fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents: 18719
diff changeset
368 (defun fontset-name-p (fontset)
cad4c032fa26 (fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents: 18719
diff changeset
369 "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
370 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
371 with \"fontset\" in `<CHARSET_REGISTRY> field."
cad4c032fa26 (fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents: 18719
diff changeset
372 (and (string-match xlfd-tight-regexp fontset)
cad4c032fa26 (fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents: 18719
diff changeset
373 (string= (match-string (1+ xlfd-regexp-registry-subnum) fontset)
cad4c032fa26 (fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents: 18719
diff changeset
374 "fontset")))
cad4c032fa26 (fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents: 18719
diff changeset
375
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
376 ;; Return a list to be appended to `x-fixed-font-alist' when
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
377 ;; `mouse-set-font' is called.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
378 (defun generate-fontset-menu ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
379 (let ((fontsets global-fontset-alist)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
380 fontset-name
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
381 l)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
382 (while fontsets
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
383 (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
384 (setq l (cons (list (fontset-plain-name fontset-name) fontset-name) l)))
24160
ab814ec4995e (generate-fontset-menu): Return a
Kenichi Handa <handa@m17n.org>
parents: 24153
diff changeset
385 (cons "Fontset"
ab814ec4995e (generate-fontset-menu): Return a
Kenichi Handa <handa@m17n.org>
parents: 24153
diff changeset
386 (sort l (function (lambda (x y) (string< (car x) (car y))))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
387
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
388 (defun fontset-plain-name (fontset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
389 "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
390 (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
391 (error "Invalid fontset: %s" fontset))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
392 (let ((xlfd-fields (x-decompose-font-name fontset)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
393 (if xlfd-fields
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
394 (let ((weight (aref xlfd-fields xlfd-regexp-weight-subnum))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
395 (slant (aref xlfd-fields xlfd-regexp-slant-subnum))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
396 (swidth (aref xlfd-fields xlfd-regexp-swidth-subnum))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
397 (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
398 (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
399 (nickname (aref xlfd-fields xlfd-regexp-encoding-subnum))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
400 name)
17755
4c82e87c7d7c (x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents: 17339
diff changeset
401 (if (not (string= "fontset" charset))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
402 fontset
17755
4c82e87c7d7c (x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents: 17339
diff changeset
403 (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
404 (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
405 (setq name nickname))
4c82e87c7d7c (x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents: 17339
diff changeset
406 (cond ((string-match "^medium$" weight)
4c82e87c7d7c (x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents: 17339
diff changeset
407 (setq name (concat name " " "medium")))
4c82e87c7d7c (x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents: 17339
diff changeset
408 ((string-match "^bold$\\|^demibold$" weight)
4c82e87c7d7c (x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents: 17339
diff changeset
409 (setq name (concat name " " weight))))
4c82e87c7d7c (x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents: 17339
diff changeset
410 (cond ((string-match "^i$" slant)
4c82e87c7d7c (x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents: 17339
diff changeset
411 (setq name (concat name " " "italic")))
4c82e87c7d7c (x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents: 17339
diff changeset
412 ((string-match "^o$" slant)
4c82e87c7d7c (x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents: 17339
diff changeset
413 (setq name (concat name " " "slant")))
4c82e87c7d7c (x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents: 17339
diff changeset
414 ((string-match "^ri$" slant)
4c82e87c7d7c (x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents: 17339
diff changeset
415 (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
416 ((string-match "^ro$" slant)
4c82e87c7d7c (x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents: 17339
diff changeset
417 (setq name (concat name " " "reverse slant"))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
418 name))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
419 fontset)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
420
19771
7de156b57f00 (uninstantiated-fontset-alist):
Richard M. Stallman <rms@gnu.org>
parents: 19456
diff changeset
421 (defvar uninstantiated-fontset-alist nil
7de156b57f00 (uninstantiated-fontset-alist):
Richard M. Stallman <rms@gnu.org>
parents: 19456
diff changeset
422 "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
423 Each element has the form (FONTSET STYLE FONTLIST), where
19771
7de156b57f00 (uninstantiated-fontset-alist):
Richard M. Stallman <rms@gnu.org>
parents: 19456
diff changeset
424 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
425 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
426 bold, demobold, italic, oblique,
cad4c032fa26 (fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents: 18719
diff changeset
427 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
428 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
429
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
430 (defconst x-style-funcs-alist
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
431 `((bold . x-make-font-bold)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
432 (demibold . x-make-font-demibold)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
433 (italic . x-make-font-italic)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
434 (oblique . x-make-font-oblique)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
435 (bold-italic . x-make-font-bold-italic)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
436 (demibold-italic
22510
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
437 . ,(function (lambda (x)
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
438 (let ((y (x-make-font-demibold x)))
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
439 (and y (x-make-font-italic y))))))
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
440 (demibold-oblique
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
441 . ,(function (lambda (x)
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
442 (let ((y (x-make-font-demibold x)))
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
443 (and y (x-make-font-oblique y))))))
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
444 (bold-oblique
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
445 . ,(function (lambda (x)
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
446 (let ((y (x-make-font-bold x)))
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
447 (and y (x-make-font-oblique y)))))))
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
448 "Alist of font style vs function to generate a X font name of the style.
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
449 The function is called with one argument, a font name.")
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
450
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
451 (defcustom fontset-default-styles '(bold italic bold-italic)
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
452 "List of alternative styles to create for a fontset.
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
453 Valid elements include `bold', `demibold'; `italic', `oblique';
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
454 and combinations of one from each group,
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
455 such as `bold-italic' and `demibold-oblique'."
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
456 :group 'faces
22601
6eb4e6832d2d (fontset-default-styles): Fix custom type.
Richard M. Stallman <rms@gnu.org>
parents: 22561
diff changeset
457 :type '(set (const bold) (const demibold) (const italic) (const oblique)
6eb4e6832d2d (fontset-default-styles): Fix custom type.
Richard M. Stallman <rms@gnu.org>
parents: 22561
diff changeset
458 (const bold-italic) (const bold-oblique) (const demibold-italic)
6eb4e6832d2d (fontset-default-styles): Fix custom type.
Richard M. Stallman <rms@gnu.org>
parents: 22561
diff changeset
459 (const demibold-oblique)))
22510
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
460
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
461 (defun x-modify-font-name (fontname style)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
462 "Substitute style specification part of FONTNAME for STYLE.
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
463 STYLE should be listed in the variable `x-style-funcs-alist'."
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
464 (let ((func (cdr (assq style x-style-funcs-alist))))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
465 (if func
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
466 (funcall func fontname))))
19049
cad4c032fa26 (fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents: 18719
diff changeset
467
22128
8f7a59fc78db (create-fontset-from-fontset-spec): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 19771
diff changeset
468 ;;;###autoload
22161
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
469 (defun create-fontset-from-fontset-spec (fontset-spec
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
470 &optional style-variant noerror)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
471 "Create a fontset from fontset specification string FONTSET-SPEC.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
472 FONTSET-SPEC is a string of the format:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
473 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
474 Any number of SPACE, TAB, and NEWLINE can be put before and after commas.
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
475
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
476 Optional 2nd argument STYLE-VARIANT is a list of font styles
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
477 \(e.g. bold, italic) or the symbol t to specify all available styles.
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
478 If this argument is specified, fontsets which differs from
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
479 FONTSET-NAME in styles are also created. An element of STYLE-VARIANT
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
480 may be cons of style and a font name. In this case, the style variant
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
481 fontset uses the font for ASCII character set.
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
482
18719
de8249499f33 (create-fontset-from-fontset-spec): Typo in doc-string fixed.
Kenichi Handa <handa@m17n.org>
parents: 18714
diff changeset
483 If this function attempts to create already existing fontset, error is
22672
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
484 signaled unless the optional 3rd argument NOERROR is non-nil.
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
485
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
486 It returns a name of the created fontset."
17755
4c82e87c7d7c (x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents: 17339
diff changeset
487 (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
488 (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
489 (let ((idx (match-end 0))
4c82e87c7d7c (x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents: 17339
diff changeset
490 (name (match-string 0 fontset-spec))
22618
ed91f54d85b9 (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22601
diff changeset
491 fontlist full-fontlist ascii-font resolved-ascii-font charset)
22161
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
492 (if (query-fontset name)
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
493 (or noerror
23655
8aa7d51024b2 (create-fontset-from-fontset-spec): Give correct arg to `error'.
Kenichi Handa <handa@m17n.org>
parents: 23205
diff changeset
494 (error "Fontset \"%s\" already exists" name))
22161
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
495 ;; 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
496 (while (string-match "[, \t\n]*\\([^:]+\\):\\([^,]+\\)" fontset-spec idx)
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
497 (setq idx (match-end 0))
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
498 (setq charset (intern (match-string 1 fontset-spec)))
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
499 (if (charsetp charset)
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
500 (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
501 fontlist))))
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
502 ;; Remember the specified ASCII font name now because it will be
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
503 ;; replaced by resolved font name by x-complement-fontset-spec.
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
504 (setq ascii-font (cdr (assq 'ascii fontlist)))
19049
cad4c032fa26 (fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents: 18719
diff changeset
505
22161
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
506 ;; 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
507 ;; which are not specified in FONTSET-SPEC.
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
508 (let ((fields (x-decompose-font-name name)))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
509 (if fields
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
510 (setq full-fontlist (x-complement-fontset-spec fields fontlist))))
22161
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
511
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
512 (when full-fontlist
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
513 ;; Create the fontset.
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
514 (new-fontset name full-fontlist)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
515
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
516 ;; Define aliases: short name (if appropriate) and ASCII font name.
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
517 (if (and (string-match "fontset-.*$" name)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
518 (not (assoc name fontset-alias-alist)))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
519 (let ((alias (match-string 0 name)))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
520 (or (rassoc alias fontset-alias-alist)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
521 (setq fontset-alias-alist
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
522 (cons (cons name alias) fontset-alias-alist)))))
24609
38dc0ce2bf99 (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 24160
diff changeset
523 (or (rassoc resolved-ascii-font fontset-alias-alist)
38dc0ce2bf99 (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 24160
diff changeset
524 (setq fontset-alias-alist
38dc0ce2bf99 (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 24160
diff changeset
525 (cons (cons name resolved-ascii-font)
38dc0ce2bf99 (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 24160
diff changeset
526 fontset-alias-alist)))
22618
ed91f54d85b9 (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22601
diff changeset
527 (or (equal ascii-font resolved-ascii-font)
24609
38dc0ce2bf99 (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 24160
diff changeset
528 (rassoc ascii-font fontset-alias-alist)
22618
ed91f54d85b9 (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22601
diff changeset
529 (setq fontset-alias-alist
ed91f54d85b9 (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22601
diff changeset
530 (cons (cons name ascii-font)
ed91f54d85b9 (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22601
diff changeset
531 fontset-alias-alist)))
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
532
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
533 ;; At last, handle style variants.
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
534 (if (eq style-variant t)
22510
3c054c9dea07 (x-style-funcs-alist):
Karl Heuer <kwzh@gnu.org>
parents: 22449
diff changeset
535 (setq style-variant fontset-default-styles))
22161
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
536
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
537 (if style-variant
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
538 ;; Generate fontset names of style variants and set them
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
539 ;; in uninstantiated-fontset-alist.
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
540 (let* (nonascii-fontlist
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
541 new-name new-ascii-font style font)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
542 (if ascii-font
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
543 (setq nonascii-fontlist (delete (cons 'ascii ascii-font)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
544 (copy-sequence fontlist)))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
545 (setq ascii-font (cdr (assq 'ascii full-fontlist))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
546 nonascii-fontlist fontlist))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
547 (while style-variant
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
548 (setq style (car style-variant))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
549 (if (symbolp style)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
550 (setq font nil)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
551 (setq font (cdr style)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
552 style (car style)))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
553 (setq new-name (x-modify-font-name name style))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
554 (when new-name
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
555 ;; Modify ASCII font name for the style...
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
556 (setq new-ascii-font
22618
ed91f54d85b9 (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22601
diff changeset
557 (or font
ed91f54d85b9 (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22601
diff changeset
558 (x-modify-font-name resolved-ascii-font style)))
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
559 ;; but leave fonts for the other charsets unmodified
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23161
diff changeset
560 ;; for the moment. They are modified for the style
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
561 ;; in instantiate-fontset.
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
562 (setq uninstantiated-fontset-alist
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
563 (cons (list new-name
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
564 style
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
565 (cons (cons 'ascii new-ascii-font)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
566 nonascii-fontlist))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
567 uninstantiated-fontset-alist))
24609
38dc0ce2bf99 (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 24160
diff changeset
568 (or (rassoc new-ascii-font fontset-alias-alist)
38dc0ce2bf99 (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 24160
diff changeset
569 (setq fontset-alias-alist
38dc0ce2bf99 (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 24160
diff changeset
570 (cons (cons new-name new-ascii-font)
38dc0ce2bf99 (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 24160
diff changeset
571 fontset-alias-alist))))
22672
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
572 (setq style-variant (cdr style-variant)))))))
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
573 name))
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
574
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
575 (defun create-fontset-from-ascii-font (font &optional resolved-font
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
576 fontset-name)
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
577 "Create a fontset from an ASCII font FONT.
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
578
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
579 Optional 1st arg RESOLVED-FONT is a resolved name of FONT. If
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
580 omitted, x-resolve-font-name is called to get the resolved name. At
22720
ab4f30149aa0 (x-complement-fontset-spec): Typo fixed.
Kenichi Handa <handa@m17n.org>
parents: 22672
diff changeset
581 this time, if FONT is not available, error is signaled.
22672
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
582
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
583 Optional 2nd arg FONTSET-NAME is a string to be used in
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
584 `<CHARSET_ENCODING>' fields of a new fontset name. If it is omitted,
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
585 an appropriate name is generated automatically.
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
586
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
587 Style variants of the fontset is created too. Font names in the
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23161
diff changeset
588 variants are generated automatically from FONT unless X resources
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23161
diff changeset
589 XXX.attributeFont explicitly specify them.
22672
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
590
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
591 It returns a name of the created fontset."
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
592 (or resolved-font
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
593 (setq resolved-font (x-resolve-font-name font)))
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
594 (let* ((faces (copy-sequence fontset-default-styles))
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
595 (styles faces)
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
596 (xlfd (x-decompose-font-name font))
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
597 (resolved-xlfd (x-decompose-font-name resolved-font))
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
598 face face-font fontset fontset-spec)
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
599 (while faces
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
600 (setq face (car faces))
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
601 (setq face-font (x-get-resource (concat (symbol-name face)
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
602 ".attributeFont")
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
603 "Face.AttributeFont"))
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
604 (if face-font
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
605 (setcar faces (cons face face-font)))
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
606 (setq faces (cdr faces)))
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
607 (aset xlfd xlfd-regexp-foundry-subnum nil)
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
608 (aset xlfd xlfd-regexp-family-subnum nil)
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
609 (aset xlfd xlfd-regexp-registry-subnum "fontset")
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
610 (or fontset-name
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
611 (setq fontset-name
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
612 (format "%s_%s_%s"
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
613 (aref resolved-xlfd xlfd-regexp-registry-subnum)
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
614 (aref resolved-xlfd xlfd-regexp-encoding-subnum)
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
615 (aref resolved-xlfd xlfd-regexp-pixelsize-subnum))))
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
616 (aset xlfd xlfd-regexp-encoding-subnum fontset-name)
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
617 ;; The fontset name should have concrete values in weight and
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
618 ;; slant field.
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
619 (let ((weight (aref xlfd xlfd-regexp-weight-subnum))
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
620 (slant (aref xlfd xlfd-regexp-slant-subnum)))
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
621 (if (or (not weight) (string-match "[*?]*" weight))
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
622 (aset xlfd xlfd-regexp-weight-subnum
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
623 (aref resolved-xlfd xlfd-regexp-weight-subnum)))
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
624 (if (or (not slant) (string-match "[*?]*" slant))
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
625 (aset xlfd xlfd-regexp-slant-subnum
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
626 (aref resolved-xlfd xlfd-regexp-slant-subnum))))
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
627 (setq fontset (x-compose-font-name xlfd))
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
628 (or (query-fontset fontset)
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
629 (create-fontset-from-fontset-spec (concat fontset ", ascii:" font)
9cfa1a788a5a (create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents: 22618
diff changeset
630 styles))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
631
19771
7de156b57f00 (uninstantiated-fontset-alist):
Richard M. Stallman <rms@gnu.org>
parents: 19456
diff changeset
632 (defun instantiate-fontset (fontset)
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23161
diff changeset
633 "Make FONTSET be ready to use.
22161
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
634 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
635 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
636 (let ((fontset-data (assoc fontset uninstantiated-fontset-alist)))
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
637 (when fontset-data
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
638 (setq uninstantiated-fontset-alist
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
639 (delete fontset-data uninstantiated-fontset-alist))
22161
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
640
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
641 (let* ((fields (x-decompose-font-name fontset))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
642 (style (nth 1 fontset-data))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
643 (fontlist (x-complement-fontset-spec fields (nth 2 fontset-data)))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
644 (font (cdr (assq 'ascii fontlist))))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
645 ;; If ASCII font is available, instantiate this fontset.
19049
cad4c032fa26 (fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents: 18719
diff changeset
646 (when font
22161
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
647 (let ((new-fontlist (list (cons 'ascii font))))
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
648 ;; Fonts for non-ascii charsets should be modified for
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
649 ;; this style now.
22161
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
650 (while fontlist
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
651 (setq font (cdr (car fontlist)))
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
652 (or (eq (car (car fontlist)) 'ascii)
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
653 (setq new-fontlist
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
654 (cons (cons (car (car fontlist))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
655 (x-modify-font-name font style))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
656 new-fontlist)))
22161
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
657 (setq fontlist (cdr fontlist)))
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
658 (new-fontset fontset new-fontlist)
22161
7a4c3fd89dda (x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents: 22128
diff changeset
659 fontset))))))
22449
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
660
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
661 (defun resolve-fontset-name (pattern)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
662 "Return a fontset name matching PATTERN."
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
663 (let ((fontset (car (rassoc pattern fontset-alias-alist))))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
664 (or fontset (setq fontset pattern))
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
665 (if (assoc fontset uninstantiated-fontset-alist)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
666 (instantiate-fontset fontset)
c87830c691a5 (instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents: 22161
diff changeset
667 (query-fontset fontset))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
668
17842
cb1af8ead3df (standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 17755
diff changeset
669 ;; 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
670 ;; 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
671 ;; 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
672 ;; many cases.
17842
cb1af8ead3df (standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 17755
diff changeset
673 (defvar standard-fontset-spec
cb1af8ead3df (standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 17755
diff changeset
674 "-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard,
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
675 chinese-gb2312:-*-medium-r-normal-*-16-*-gb2312*-*,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
676 korean-ksc5601:-*-medium-r-normal-*-16-*-ksc5601*-*,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
677 chinese-cns11643-1:-*-medium-r-normal-*-16-*-cns11643*-1,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
678 chinese-cns11643-2:-*-medium-r-normal-*-16-*-cns11643*-2,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
679 chinese-cns11643-3:-*-medium-r-normal-*-16-*-cns11643*-3,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
680 chinese-cns11643-4:-*-medium-r-normal-*-16-*-cns11643*-4,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
681 chinese-cns11643-5:-*-medium-r-normal-*-16-*-cns11643*-5,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
682 chinese-cns11643-6:-*-medium-r-normal-*-16-*-cns11643*-6,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
683 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
684 "String of fontset spec of the standard fontset.
cb1af8ead3df (standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 17755
diff changeset
685 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
686 with correct glyphs by using the standard fontset.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
687 See the documentation of `create-fontset-from-fontset-spec' for the format.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
688
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
689 ;; Create fontsets from X resources of the name `fontset-N (class
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
690 ;; Fontset-N)' where N is integer 0, 1, ...
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
691 ;; 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
692 ;; `standard-fontset-spec'.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
693
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
694 (defun create-fontset-from-x-resource ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
695 (let ((idx 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
696 fontset-spec)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
697 (while (setq fontset-spec (x-get-resource (concat "fontset-" idx)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
698 (concat "Fontset-" idx)))
24153
729affdf2ca1 (create-fontset-from-x-resource): Make style variants.
Kenichi Handa <handa@m17n.org>
parents: 23890
diff changeset
699 (create-fontset-from-fontset-spec fontset-spec t 'noerror)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
700 (setq idx (1+ idx)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
701
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
702 (defsubst fontset-list ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
703 "Returns a list of all defined fontset names."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
704 (mapcar 'car global-fontset-alist))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
705
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
706 ;;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
707 (provide 'fontset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
708
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
709 ;;; fontset.el ends here