Mercurial > emacs
annotate lisp/international/fontset.el @ 88595:c348d8f35224
Add setting for unicode font at the end of the default fontset.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 22 May 2002 05:56:05 +0000 |
parents | 101343133fe3 |
children | cd23fd4b0145 |
rev | line source |
---|---|
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36368
diff
changeset
|
1 ;;; fontset.el --- commands for handling fontset |
17052 | 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. |
40250
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
5 ;; Copyright (C) 2001 Free Software Foundation, Inc. |
17052 | 6 |
7 ;; Keywords: mule, multilingual, fontset | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
17071 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
17052 | 25 |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36368
diff
changeset
|
26 ;;; Commentary: |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36368
diff
changeset
|
27 |
17052 | 28 ;;; Code: |
29 | |
29234
c9a5f356fe77
Set family names of non-latin charsets in default fontset to "*".
Kenichi Handa <handa@m17n.org>
parents:
29168
diff
changeset
|
30 ;; Set standard fontname specification of characters in the default |
c9a5f356fe77
Set family names of non-latin charsets in default fontset to "*".
Kenichi Handa <handa@m17n.org>
parents:
29168
diff
changeset
|
31 ;; fontset to find an appropriate font for each charset. This is used |
c9a5f356fe77
Set family names of non-latin charsets in default fontset to "*".
Kenichi Handa <handa@m17n.org>
parents:
29168
diff
changeset
|
32 ;; to generate a font name for a fontset if the fontset doesn't |
c9a5f356fe77
Set family names of non-latin charsets in default fontset to "*".
Kenichi Handa <handa@m17n.org>
parents:
29168
diff
changeset
|
33 ;; specify a font name for a specific character. The specification |
c9a5f356fe77
Set family names of non-latin charsets in default fontset to "*".
Kenichi Handa <handa@m17n.org>
parents:
29168
diff
changeset
|
34 ;; has the form (FAMILY . REGISTRY). FAMILY may be nil, in which |
c9a5f356fe77
Set family names of non-latin charsets in default fontset to "*".
Kenichi Handa <handa@m17n.org>
parents:
29168
diff
changeset
|
35 ;; case, the family name of default face is used. If REGISTRY |
c9a5f356fe77
Set family names of non-latin charsets in default fontset to "*".
Kenichi Handa <handa@m17n.org>
parents:
29168
diff
changeset
|
36 ;; contains a character `-', the string before that is embedded in |
c9a5f356fe77
Set family names of non-latin charsets in default fontset to "*".
Kenichi Handa <handa@m17n.org>
parents:
29168
diff
changeset
|
37 ;; `CHARSET_REGISTRY' field, and the string after that is embedded in |
c9a5f356fe77
Set family names of non-latin charsets in default fontset to "*".
Kenichi Handa <handa@m17n.org>
parents:
29168
diff
changeset
|
38 ;; `CHARSET_ENCODING' field. If it does not contain `-', the whole |
c9a5f356fe77
Set family names of non-latin charsets in default fontset to "*".
Kenichi Handa <handa@m17n.org>
parents:
29168
diff
changeset
|
39 ;; string is embedded in `CHARSET_REGISTRY' field, and a wild card |
c9a5f356fe77
Set family names of non-latin charsets in default fontset to "*".
Kenichi Handa <handa@m17n.org>
parents:
29168
diff
changeset
|
40 ;; character `*' is embedded in `CHARSET_ENCODING' field. The |
c9a5f356fe77
Set family names of non-latin charsets in default fontset to "*".
Kenichi Handa <handa@m17n.org>
parents:
29168
diff
changeset
|
41 ;; REGISTRY for ASCII characters are predefined as "ISO8859-1". |
17052 | 42 |
42072
9f1fa0a02eb3
Build the list L at compile time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41467
diff
changeset
|
43 (let ((l |
9f1fa0a02eb3
Build the list L at compile time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41467
diff
changeset
|
44 ;; Eval this at compile-time, since fontset.el is always loaded |
9f1fa0a02eb3
Build the list L at compile time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41467
diff
changeset
|
45 ;; when run under X and this would always load ind-util.el as well. |
9f1fa0a02eb3
Build the list L at compile time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41467
diff
changeset
|
46 (eval-when-compile |
88405 | 47 `((ascii . (nil . "ISO8859-1")) |
48 (iso-8859-1 . (nil . "ISO8859-1")) | |
49 (iso-8859-2 . (nil . "ISO8859-2")) | |
50 (iso-8859-3 . (nil . "ISO8859-3")) | |
51 (iso-8859-4 . (nil . "ISO8859-4")) | |
52 (tis620-2533 . (nil . "TIS620*")) | |
53 (iso-8859-7 . (nil . "ISO8859-7")) | |
54 (iso-8859-6 . (nil . "ISO8859-6")) | |
55 (iso-8859-8 . (nil . "ISO8859-8")) | |
56 (iso-8859-5 . (nil . "ISO8859-5")) | |
57 (iso-8859-9 . (nil . "ISO8859-9")) | |
58 (iso-8859-14 . (nil . "ISO8859-14")) | |
59 (iso-8859-15 . (nil . "ISO8859-15")) | |
88449
76fc6c1146aa
Change the registry for chinese-gb2312 and add the registry for
Kenichi Handa <handa@m17n.org>
parents:
88405
diff
changeset
|
60 (chinese-gb2312 . (nil . "GB2312.1980-0")) |
88405 | 61 (japanese-jisx0208 . (nil . "JISX0208.1990*")) |
62 (korean-ksc5601 . (nil . "KSC5601.1987*")) | |
63 (japanese-jisx0212 . (nil . "JISX0212*")) | |
64 (big5 . (nil . "Big5")) | |
65 (chinese-cns11643-1 . (nil . "CNS11643.1992-1")) | |
66 (chinese-cns11643-2 . (nil . "CNS11643.1992-2")) | |
67 (chinese-cns11643-3 . (nil . "CNS11643.1992-3")) | |
68 (chinese-cns11643-4 . (nil . "CNS11643.1992-4")) | |
69 (chinese-cns11643-5 . (nil . "CNS11643.1992-5")) | |
70 (chinese-cns11643-6 . (nil . "CNS11643.1992-6")) | |
71 (chinese-cns11643-7 . (nil . "CNS11643.1992-7")) | |
88449
76fc6c1146aa
Change the registry for chinese-gb2312 and add the registry for
Kenichi Handa <handa@m17n.org>
parents:
88405
diff
changeset
|
72 (chinese-gbk . (nil . "gbk-0")) |
29234
c9a5f356fe77
Set family names of non-latin charsets in default fontset to "*".
Kenichi Handa <handa@m17n.org>
parents:
29168
diff
changeset
|
73 (chinese-sisheng . (nil . "sisheng_cwnn")) |
88405 | 74 (viscii . (nil . "VISCII1.1*")) |
75 (arabic-digit . (nil . "MuleArabic-0")) | |
76 (arabic-1-column . (nil . "MuleArabic-1")) | |
77 (arabic-2-column . (nil . "MuleArabic-2")) | |
29234
c9a5f356fe77
Set family names of non-latin charsets in default fontset to "*".
Kenichi Handa <handa@m17n.org>
parents:
29168
diff
changeset
|
78 (ipa . (nil . "MuleIPA")) |
88405 | 79 (ethiopic . (nil . "Ethiopic-Unicode")) |
80 (indian-is13194 . (nil . "IS13194-Devanagari")) | |
81 (indian-2-column . (nil . "MuleIndian-2")) | |
82 (mule-lao . (nil . "MuleLao-1")) | |
32646
43edadfecb51
Use registry "MuleTibetan-2" for Tibetan.
Kenichi Handa <handa@m17n.org>
parents:
29427
diff
changeset
|
83 (tibetan . ("proportional" . "MuleTibetan-2")) |
88405 | 84 (tibetan-1-column . (nil . "MuleTibetan-1")) |
85 (jisx0201 . (nil . "JISX0201*")) | |
86 (japanese-jisx0208-1978 . (nil . "JISX0208.1978*")) | |
87 (japanese-jisx0213-1 . (nil . "JISX0213.2000-1")) | |
88 (japanese-jisx0213-2 . (nil . "JISX0213.2000-2")) | |
41467
55c3397b3029
Delete the setting for indian-1-column
Richard M. Stallman <rms@gnu.org>
parents:
40250
diff
changeset
|
89 ;; unicode |
55c3397b3029
Delete the setting for indian-1-column
Richard M. Stallman <rms@gnu.org>
parents:
40250
diff
changeset
|
90 ((,(decode-char 'ucs #x0900) |
88405 | 91 . ,(decode-char 'ucs #x097F)) . (nil . "ISO10646.indian-1")) |
41467
55c3397b3029
Delete the setting for indian-1-column
Richard M. Stallman <rms@gnu.org>
parents:
40250
diff
changeset
|
92 ;; indian |
88405 | 93 (indian-glyph . (nil . "Devanagari-CDAC")) |
41467
55c3397b3029
Delete the setting for indian-1-column
Richard M. Stallman <rms@gnu.org>
parents:
40250
diff
changeset
|
94 ((,(indian-glyph-char 0 'devanagari) |
88405 | 95 . ,(indian-glyph-char 255 'devanagari)) . (nil . "Devanagari-CDAC")) |
41467
55c3397b3029
Delete the setting for indian-1-column
Richard M. Stallman <rms@gnu.org>
parents:
40250
diff
changeset
|
96 ((,(indian-glyph-char 0 'sanskrit) |
88405 | 97 . ,(indian-glyph-char 255 'sanskrit)) . (nil . "Sanskrit-CDAC")) |
41467
55c3397b3029
Delete the setting for indian-1-column
Richard M. Stallman <rms@gnu.org>
parents:
40250
diff
changeset
|
98 ((,(indian-glyph-char 0 'bengali) |
88405 | 99 . ,(indian-glyph-char 255 'bengali)) . (nil . "Bengali-CDAC")) |
41467
55c3397b3029
Delete the setting for indian-1-column
Richard M. Stallman <rms@gnu.org>
parents:
40250
diff
changeset
|
100 ((,(indian-glyph-char 0 'assamese) |
88405 | 101 . ,(indian-glyph-char 255 'assamese)) . (nil . "Assamese-CDAC")) |
41467
55c3397b3029
Delete the setting for indian-1-column
Richard M. Stallman <rms@gnu.org>
parents:
40250
diff
changeset
|
102 ((,(indian-glyph-char 0 'punjabi) |
88405 | 103 . ,(indian-glyph-char 255 'punjabi)) . (nil . "Punjabi-CDAC")) |
41467
55c3397b3029
Delete the setting for indian-1-column
Richard M. Stallman <rms@gnu.org>
parents:
40250
diff
changeset
|
104 ((,(indian-glyph-char 0 'gujarati) |
88405 | 105 . ,(indian-glyph-char 255 'gujarati)) . (nil . "Gujarati-CDAC")) |
41467
55c3397b3029
Delete the setting for indian-1-column
Richard M. Stallman <rms@gnu.org>
parents:
40250
diff
changeset
|
106 ((,(indian-glyph-char 0 'oriya) |
88405 | 107 . ,(indian-glyph-char 255 'oriya)) . (nil . "Oriya-CDAC")) |
41467
55c3397b3029
Delete the setting for indian-1-column
Richard M. Stallman <rms@gnu.org>
parents:
40250
diff
changeset
|
108 ((,(indian-glyph-char 0 'tamil) |
88405 | 109 . ,(indian-glyph-char 255 'tamil)) . (nil . "Tamil-CDAC")) |
41467
55c3397b3029
Delete the setting for indian-1-column
Richard M. Stallman <rms@gnu.org>
parents:
40250
diff
changeset
|
110 ((,(indian-glyph-char 0 'telugu) |
88405 | 111 . ,(indian-glyph-char 255 'telugu)) . (nil . "Telugu-CDAC")) |
41467
55c3397b3029
Delete the setting for indian-1-column
Richard M. Stallman <rms@gnu.org>
parents:
40250
diff
changeset
|
112 ((,(indian-glyph-char 0 'kannada) |
88405 | 113 . ,(indian-glyph-char 255 'kannada)) . (nil . "Kannada-CDAC")) |
41467
55c3397b3029
Delete the setting for indian-1-column
Richard M. Stallman <rms@gnu.org>
parents:
40250
diff
changeset
|
114 ((,(indian-glyph-char 0 'malayalam) |
88405 | 115 . ,(indian-glyph-char 255 'malayalam)) . (nil . "Malayalam-CDAC")) |
88595
c348d8f35224
Add setting for unicode font at the end of the default fontset.
Kenichi Handa <handa@m17n.org>
parents:
88579
diff
changeset
|
116 (unicode . (nil . "ISO10646-1")) |
42072
9f1fa0a02eb3
Build the list L at compile time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41467
diff
changeset
|
117 ))) |
88405 | 118 charset font-spec) |
17052 | 119 (while l |
29234
c9a5f356fe77
Set family names of non-latin charsets in default fontset to "*".
Kenichi Handa <handa@m17n.org>
parents:
29168
diff
changeset
|
120 (setq charset (car (car l)) font-spec (cdr (car l)) l (cdr l)) |
88405 | 121 (set-fontset-font "fontset-default" charset font-spec))) |
122 | |
123 (setq font-encoding-alist | |
124 '(("ISO8859-1" . iso-8859-1) | |
125 ("ISO8859-2" . iso-8859-2) | |
126 ("ISO8859-3" . iso-8859-3) | |
127 ("ISO8859-4" . iso-8859-4) | |
128 ("TIS620" . tis620-2533) | |
129 ("ISO8859-7" . iso-8859-7) | |
130 ("ISO8859-6" . iso-8859-6) | |
131 ("ISO8859-8" . iso-8859-8) | |
132 ("JISX0201" . jisx0201) | |
133 ("ISO8859-5" . iso-8859-5) | |
134 ("ISO8859-9" . iso-8859-9) | |
135 ("JISX0208.1978" . japanese-jisx0208-1978) | |
136 ("GB2312.1980" . chinese-gb2312) | |
137 ("JISX0208.1990" . japanese-jisx0208) | |
138 ("KSC5601.1987" . korean-ksc5601) | |
139 ("JISX0212" . japanese-jisx0212) | |
140 ("CNS11643.1992-1" . chinese-cns11643-1) | |
141 ("CNS11643.1992-2" . chinese-cns11643-2) | |
142 ("CNS11643.1992-3" . chinese-cns11643-3) | |
143 ("CNS11643.1992-4" . chinese-cns11643-4) | |
144 ("CNS11643.1992-5" . chinese-cns11643-5) | |
145 ("CNS11643.1992-6" . chinese-cns11643-6) | |
146 ("CNS11643.1992-7" . chinese-cns11643-7) | |
147 ("Big5" . big5) | |
148 ("sisheng_cwnn" . chinese-sisheng) | |
149 ("VISCII" . viscii) | |
150 ("MuleArabic-0" . arabic-digit) | |
151 ("MuleArabic-1" . arabic-1-column) | |
152 ("MuleArabic-2" . arabic-2-column) | |
153 ("MuleIPA" . ipa) | |
154 ("Ethiopic-Unicode" . ethiopic) | |
155 ("IS13194-Devanagari" . indian-is13194) | |
156 ("MuleIndian-2" . indian-2-column) | |
157 ("MuleIndian-1" . indian-1-column) | |
158 ("MuleLao-1" . mule-lao) | |
159 ("MuleTibetan-2" . tibetan) | |
160 ("MuleTibetan-1" . tibetan-1-column) | |
161 ("ISO8859-14" . iso-8859-14) | |
162 ("ISO8859-15" . iso-8859-15) | |
163 ("JISX0213.2000-1" . japanese-jisx0213-1) | |
164 ("JISX0213.2000-2" . japanese-jisx0213-2) | |
88579 | 165 ("abobe-symbol" . symbol) |
88405 | 166 ("ISO10646-1" . unicode))) |
17052 | 167 |
168 ;; Set arguments in `font-encoding-alist' (which see). | |
88405 | 169 (defun set-font-encoding (pattern charset) |
17052 | 170 (let ((slot (assoc pattern font-encoding-alist))) |
171 (if slot | |
88405 | 172 (setcdr slot charset) |
17052 | 173 (setq font-encoding-alist |
88405 | 174 (cons (cons pattern charset) font-encoding-alist))))) |
32646
43edadfecb51
Use registry "MuleTibetan-2" for Tibetan.
Kenichi Handa <handa@m17n.org>
parents:
29427
diff
changeset
|
175 |
17052 | 176 ;; Setting for suppressing XLoadQueryFont on big fonts. |
177 (setq x-pixel-size-width-font-regexp | |
178 "gb2312\\|jisx0208\\|ksc5601\\|cns11643\\|big5") | |
179 | |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
180 ;; These fonts require vertical centering. |
26886
8a6d8101919e
(vertical-centering-font-regexp): New
Kenichi Handa <handa@m17n.org>
parents:
26013
diff
changeset
|
181 (setq vertical-centering-font-regexp |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
182 "gb2312\\|jisx0208\\|jisx0212\\|ksc5601\\|cns11643\\|big5") |
26886
8a6d8101919e
(vertical-centering-font-regexp): New
Kenichi Handa <handa@m17n.org>
parents:
26013
diff
changeset
|
183 |
88405 | 184 (defvar x-font-name-charset-alist nil |
185 "This variable has no meaning now. Just kept for backward compatibility.") | |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
186 |
17052 | 187 ;;; XLFD (X Logical Font Description) format handler. |
188 | |
189 ;; Define XLFD's field index numbers. ; field name | |
88405 | 190 (defconst xlfd-regexp-family-subnum 0) ; FOUNDRY and FAMILY |
191 (defconst xlfd-regexp-weight-subnum 1) ; WEIGHT_NAME | |
192 (defconst xlfd-regexp-slant-subnum 2) ; SLANT | |
193 (defconst xlfd-regexp-swidth-subnum 3) ; SETWIDTH_NAME | |
194 (defconst xlfd-regexp-adstyle-subnum 4) ; ADD_STYLE_NAME | |
195 (defconst xlfd-regexp-pixelsize-subnum 5) ; PIXEL_SIZE | |
196 (defconst xlfd-regexp-pointsize-subnum 6) ; POINT_SIZE | |
197 (defconst xlfd-regexp-resx-subnum 7) ; RESOLUTION_X | |
198 (defconst xlfd-regexp-resy-subnum 8) ; RESOLUTION_Y | |
199 (defconst xlfd-regexp-spacing-subnum 8) ; SPACING | |
200 (defconst xlfd-regexp-avgwidth-subnum 10) ; AVERAGE_WIDTH | |
201 (defconst xlfd-regexp-registry-subnum 11) ; REGISTRY and ENCODING | |
17052 | 202 |
203 ;; Regular expression matching against a fontname which conforms to | |
204 ;; XLFD (X Logical Font Description). All fields in XLFD should be | |
205 ;; not be omitted (but can be a wild card) to be matched. | |
206 (defconst xlfd-tight-regexp | |
207 "^\ | |
88405 | 208 -\\([^-]*-[^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\ |
17052 | 209 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\ |
88405 | 210 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*-[^-]*\\)$") |
211 | |
212 ;; Regular expression matching against a fontname which conforms to | |
213 ;; XLFD (X Logical Font Description). All fields in XLFD from FOUNDRY | |
214 ;; to ADSTYLE, REGSITRY, and ENCODING should be not be omitted (but | |
215 ;; can be a wild card) to be matched. | |
216 (defconst xlfd-style-regexp | |
217 "^\ | |
218 -\\([^-]*-[^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-.*\ | |
219 -\\([^-]*-[^-]*\\)$") | |
17052 | 220 |
221 ;; List of field numbers of XLFD whose values are numeric. | |
222 (defconst xlfd-regexp-numeric-subnums | |
88405 | 223 (list xlfd-regexp-pixelsize-subnum ;5 |
224 xlfd-regexp-pointsize-subnum ;6 | |
225 xlfd-regexp-resx-subnum ;7 | |
226 xlfd-regexp-resy-subnum ;8 | |
227 xlfd-regexp-avgwidth-subnum ;10 | |
17052 | 228 )) |
229 | |
230 (defun x-decompose-font-name (pattern) | |
231 "Decompose PATTERN into XLFD's fields and return vector of the fields. | |
88405 | 232 The length of the vector is 12. |
17052 | 233 |
234 If PATTERN doesn't conform to XLFD, try to get a full XLFD name from | |
235 X server and use the information of the full name to decompose | |
236 PATTERN. If no full XLFD name is gotten, return nil." | |
237 (let (xlfd-fields fontname) | |
238 (if (string-match xlfd-tight-regexp pattern) | |
88405 | 239 (progn |
240 (setq xlfd-fields (make-vector 12 nil)) | |
241 (dotimes (i 12) | |
242 (aset xlfd-fields i (match-string (1+ i) pattern))) | |
243 (dotimes (i 12) | |
244 (if (string-match "^[*-]+$" (aref xlfd-fields i)) | |
245 (aset xlfd-fields i nil))) | |
17052 | 246 xlfd-fields) |
247 (setq fontname (condition-case nil | |
248 (x-resolve-font-name pattern) | |
249 (error))) | |
250 (if (and fontname | |
251 (string-match xlfd-tight-regexp fontname)) | |
23890
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
252 ;; We get a full XLFD name. |
17052 | 253 (let ((len (length pattern)) |
254 (i 0) | |
255 l) | |
23890
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
256 ;; 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
|
257 ;; should be a cons of matched index and matched string. |
88405 | 258 (setq xlfd-fields (make-vector 12 nil)) |
259 (dotimes (i 12) | |
17052 | 260 (aset xlfd-fields i |
261 (cons (match-beginning (1+ i)) | |
88405 | 262 (match-string (1+ i) fontname)))) |
23890
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
263 |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
264 ;; Replace wild cards in PATTERN by regexp codes. |
17052 | 265 (setq i 0) |
266 (while (< i len) | |
267 (let ((ch (aref pattern i))) | |
268 (if (= ch ??) | |
269 (setq pattern (concat (substring pattern 0 i) | |
270 "\\(.\\)" | |
271 (substring pattern (1+ i))) | |
272 len (+ len 4) | |
273 i (+ i 4)) | |
274 (if (= ch ?*) | |
275 (setq pattern (concat (substring pattern 0 i) | |
276 "\\(.*\\)" | |
277 (substring pattern (1+ i))) | |
278 len (+ len 5) | |
279 i (+ i 5)) | |
280 (setq i (1+ i)))))) | |
23890
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
281 |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
282 ;; 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
|
283 (if (string-match pattern fontname) |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
284 ;; The regular expression PATTERN matchs the full XLFD |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
285 ;; name. Set elements that correspond to a wild card |
88405 | 286 ;; in PATTERN to nil, set the other elements to the |
23890
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
287 ;; exact strings in PATTERN. |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
288 (let ((l (cdr (cdr (match-data))))) |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
289 (setq i 0) |
88405 | 290 (while (< i 12) |
23890
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
291 (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
|
292 (progn |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
293 (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
|
294 (setq i (1+ i))) |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
295 (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
|
296 (progn |
88405 | 297 (aset xlfd-fields i nil) |
23890
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
298 (setq i (1+ i))) |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
299 (setq l (cdr (cdr l))))))) |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
300 ;; 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
|
301 ;; in the corresonding fields in full XLFD name. |
88405 | 302 (dotimes (i 12) |
303 (aset xlfd-fields i (cdr (aref xlfd-fields i))))) | |
17052 | 304 xlfd-fields))))) |
305 | |
22449
c87830c691a5
(instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents:
22161
diff
changeset
|
306 (defun x-compose-font-name (fields &optional reduce) |
17052 | 307 "Compose X's fontname from FIELDS. |
88405 | 308 FIELDS is a vector of XLFD fields, the length 12. |
17177
9e550b522bc0
(x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
309 If a field is nil, wild-card letter `*' is embedded. |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
310 Optional argument REDUCE is always ignored. It exists just for |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
311 backward compatibility." |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
312 (concat "-" (mapconcat (lambda (x) (or x "*")) fields "-"))) |
23205
22df54cdb841
(resolved-ascii-font): New variable.
Kenichi Handa <handa@m17n.org>
parents:
23196
diff
changeset
|
313 |
40250
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
314 (defun x-must-resolve-font-name (xlfd-fields) |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
315 "Like `x-resolve-font-name', but always return a font name. |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
316 XLFD-FIELDS is a vector of XLFD (X Logical Font Description) fields. |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
317 If no font matching XLFD-FIELDS is available, successively replace |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
318 parts of the font name pattern with \"*\" until some font is found. |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
319 Value is name of that font." |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
320 (let ((ascii-font nil) (index 0)) |
88405 | 321 (while (and (null ascii-font) (<= index xlfd-regexp-registry-subnum)) |
40250
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
322 (let ((pattern (x-compose-font-name xlfd-fields))) |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
323 (condition-case nil |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
324 (setq ascii-font (x-resolve-font-name pattern)) |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
325 (error |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
326 (message "Warning: no fonts matching `%s' available" pattern) |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
327 (aset xlfd-fields index "*") |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
328 (setq index (1+ index)))))) |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
329 (unless ascii-font |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
330 (error "No fonts founds")) |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
331 ascii-font)) |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
332 |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
333 |
17052 | 334 (defun x-complement-fontset-spec (xlfd-fields fontlist) |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
335 "Complement FONTLIST for charsets based on XLFD-FIELDS and return it. |
17052 | 336 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
|
337 FONTLIST is an alist of charsets vs the corresponding font names. |
17052 | 338 |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
339 The fonts are complemented as below. |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
340 |
88405 | 341 At first, if FONTLIST doesn't specify a font for ASCII charset, |
342 generate a font name for the charset from XLFD-FIELDS, and add that | |
343 information to FONTLIST. | |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
344 |
88405 | 345 Then, replace font names with the corresponding XLFD field vectors |
346 while substituting default field names for wild cards if they match | |
347 `xlfd-style-regexp'. The default field names are decided by | |
348 XLFD-FIELDS." | |
349 (let* ((default-spec (vector (aref xlfd-fields xlfd-regexp-family-subnum) | |
350 (aref xlfd-fields xlfd-regexp-weight-subnum) | |
351 (aref xlfd-fields xlfd-regexp-slant-subnum) | |
352 (aref xlfd-fields xlfd-regexp-swidth-subnum) | |
353 (aref xlfd-fields xlfd-regexp-adstyle-subnum) | |
354 (aref xlfd-fields xlfd-regexp-registry-subnum))) | |
355 (slot (assq 'ascii fontlist)) | |
36368
dbd54e46ee03
(x-complement-fontset-spec): In the
Kenichi Handa <handa@m17n.org>
parents:
34917
diff
changeset
|
356 (ascii-font (cdr slot)) |
88405 | 357 xlfd-ascii) |
34917
989f2f0c8a7e
(x-complement-fontset-spec): Resolve
Kenichi Handa <handa@m17n.org>
parents:
34245
diff
changeset
|
358 (if ascii-font |
88405 | 359 (progn |
360 (setcdr slot (setq ascii-font (x-resolve-font-name ascii-font))) | |
361 (setq xlfd-ascii (x-decompose-font-name ascii-font)) | |
362 (dotimes (i 11) | |
363 (or (aref xlfd-fields i) | |
364 (aset xlfd-fields i (aref xlfd-ascii i))))) | |
34917
989f2f0c8a7e
(x-complement-fontset-spec): Resolve
Kenichi Handa <handa@m17n.org>
parents:
34245
diff
changeset
|
365 ;; If font for ASCII is not specified, add it. |
88405 | 366 (setq xlfd-ascii (copy-sequence xlfd-fields)) |
367 (aset xlfd-ascii xlfd-regexp-registry-subnum "iso8859-1") | |
368 (setq ascii-font (x-must-resolve-font-name xlfd-ascii)) | |
29234
c9a5f356fe77
Set family names of non-latin charsets in default fontset to "*".
Kenichi Handa <handa@m17n.org>
parents:
29168
diff
changeset
|
369 (setq fontlist (cons (cons 'ascii ascii-font) fontlist))) |
18350
3f4364889538
(x-charset-registries): Name changed for consistency:
Kenichi Handa <handa@m17n.org>
parents:
17989
diff
changeset
|
370 |
88405 | 371 (dolist (elt fontlist) |
372 (let ((name (cdr elt)) | |
373 font-spec) | |
374 (when (string-match xlfd-style-regexp name) | |
375 (setq font-spec (make-vector 6 nil)) | |
376 (dotimes (i 6) | |
377 (aset font-spec i (match-string (1+ i) name))) | |
378 (dotimes (i 6) | |
379 (if (string-match "^[*-]+$" (aref font-spec i)) | |
380 (aset font-spec i (aref default-spec i)))) | |
381 (setcdr elt font-spec)))) | |
382 | |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
383 fontlist)) |
17052 | 384 |
19049
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
385 (defun fontset-name-p (fontset) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
386 "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
|
387 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
|
388 with \"fontset\" in `<CHARSET_REGISTRY> field." |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
389 (and (string-match xlfd-tight-regexp fontset) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
390 (string= (match-string (1+ xlfd-regexp-registry-subnum) fontset) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
391 "fontset"))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
392 |
17052 | 393 ;; Return a list to be appended to `x-fixed-font-alist' when |
394 ;; `mouse-set-font' is called. | |
395 (defun generate-fontset-menu () | |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
396 (let ((fontsets (fontset-list)) |
17052 | 397 fontset-name |
398 l) | |
399 (while fontsets | |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
400 (setq fontset-name (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
|
401 (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
|
402 (cons "Fontset" |
ab814ec4995e
(generate-fontset-menu): Return a
Kenichi Handa <handa@m17n.org>
parents:
24153
diff
changeset
|
403 (sort l (function (lambda (x y) (string< (car x) (car y)))))))) |
17052 | 404 |
405 (defun fontset-plain-name (fontset) | |
406 "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
|
407 (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
|
408 (error "Invalid fontset: %s" fontset)) |
17052 | 409 (let ((xlfd-fields (x-decompose-font-name fontset))) |
410 (if xlfd-fields | |
411 (let ((weight (aref xlfd-fields xlfd-regexp-weight-subnum)) | |
412 (slant (aref xlfd-fields xlfd-regexp-slant-subnum)) | |
413 (swidth (aref xlfd-fields xlfd-regexp-swidth-subnum)) | |
414 (size (aref xlfd-fields xlfd-regexp-pixelsize-subnum)) | |
88405 | 415 (nickname (aref xlfd-fields xlfd-regexp-registry-subnum)) |
17052 | 416 name) |
88405 | 417 (if (not (string-match "^fontset-\\(.*\\)$" nickname)) |
17052 | 418 fontset |
88405 | 419 (setq nickname (match-string 1 nickname)) |
88484 | 420 (if (and size (> (string-to-int size) 0)) |
17755
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
421 (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
|
422 (setq name nickname)) |
88483
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
423 (and weight |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
424 (cond ((string-match "^medium$" weight) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
425 (setq name (concat name " " "medium"))) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
426 ((string-match "^bold$\\|^demibold$" weight) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
427 (setq name (concat name " " weight))))) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
428 (and slant |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
429 (cond ((string-match "^i$" slant) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
430 (setq name (concat name " " "italic"))) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
431 ((string-match "^o$" slant) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
432 (setq name (concat name " " "slant"))) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
433 ((string-match "^ri$" slant) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
434 (setq name (concat name " " "reverse italic"))) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
435 ((string-match "^ro$" slant) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
436 (setq name (concat name " " "reverse slant"))))) |
17052 | 437 name)) |
438 fontset))) | |
439 | |
22128
8f7a59fc78db
(create-fontset-from-fontset-spec): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
19771
diff
changeset
|
440 ;;;###autoload |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
441 (defun create-fontset-from-fontset-spec (fontset-spec |
22449
c87830c691a5
(instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents:
22161
diff
changeset
|
442 &optional style-variant noerror) |
17052 | 443 "Create a fontset from fontset specification string FONTSET-SPEC. |
444 FONTSET-SPEC is a string of the format: | |
445 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
|
446 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
|
447 |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
448 Optional 2nd argument is ignored. It exists just for backward |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
449 compatibility. |
22449
c87830c691a5
(instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents:
22161
diff
changeset
|
450 |
18719
de8249499f33
(create-fontset-from-fontset-spec): Typo in doc-string fixed.
Kenichi Handa <handa@m17n.org>
parents:
18714
diff
changeset
|
451 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
|
452 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
|
453 |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
454 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
|
455 (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
|
456 (error "Invalid fontset spec: %s" fontset-spec)) |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
457 (setq fontset-spec (downcase fontset-spec)) |
17755
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
458 (let ((idx (match-end 0)) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
459 (name (match-string 0 fontset-spec)) |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
460 xlfd-fields charset fontlist ascii-font) |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
461 (if (query-fontset name) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
462 (or noerror |
23655
8aa7d51024b2
(create-fontset-from-fontset-spec): Give correct arg to `error'.
Kenichi Handa <handa@m17n.org>
parents:
23205
diff
changeset
|
463 (error "Fontset \"%s\" already exists" name)) |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
464 (setq xlfd-fields (x-decompose-font-name name)) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
465 (or xlfd-fields |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
466 (error "Fontset \"%s\" not conforming to XLFD" name)) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
467 |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
468 ;; 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
|
469 (while (string-match "[, \t\n]*\\([^:]+\\):\\([^,]+\\)" fontset-spec idx) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
470 (setq idx (match-end 0)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
471 (setq charset (intern (match-string 1 fontset-spec))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
472 (if (charsetp charset) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
473 (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
|
474 fontlist)))) |
34917
989f2f0c8a7e
(x-complement-fontset-spec): Resolve
Kenichi Handa <handa@m17n.org>
parents:
34245
diff
changeset
|
475 (setq ascii-font (cdr (assq 'ascii fontlist))) |
22449
c87830c691a5
(instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents:
22161
diff
changeset
|
476 |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
477 ;; Complement FONTLIST. |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
478 (setq fontlist (x-complement-fontset-spec xlfd-fields fontlist)) |
88405 | 479 (setq name (x-compose-font-name xlfd-fields)) |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
480 (new-fontset name fontlist) |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
481 |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
482 ;; Define the short name alias. |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
483 (if (and (string-match "fontset-.*$" name) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
484 (not (assoc name fontset-alias-alist))) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
485 (let ((alias (match-string 0 name))) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
486 (or (rassoc alias fontset-alias-alist) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
487 (setq fontset-alias-alist |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
488 (cons (cons name alias) fontset-alias-alist))))) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
489 |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
490 ;; Define the ASCII font name alias. |
34917
989f2f0c8a7e
(x-complement-fontset-spec): Resolve
Kenichi Handa <handa@m17n.org>
parents:
34245
diff
changeset
|
491 (or ascii-font |
989f2f0c8a7e
(x-complement-fontset-spec): Resolve
Kenichi Handa <handa@m17n.org>
parents:
34245
diff
changeset
|
492 (setq ascii-font (cdr (assq 'ascii fontlist)))) |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
493 (or (rassoc ascii-font fontset-alias-alist) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
494 (setq fontset-alias-alist |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
495 (cons (cons name ascii-font) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
496 fontset-alias-alist)))) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
497 |
22672
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
498 name)) |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
499 |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
500 (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
|
501 fontset-name) |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
502 "Create a fontset from an ASCII font FONT. |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
503 |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
504 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
|
505 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
|
506 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
|
507 |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
508 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
|
509 `<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
|
510 an appropriate name is generated automatically. |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
511 |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
512 It returns a name of the created fontset." |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
513 (setq font (downcase font)) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
514 (if resolved-font |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
515 (setq resolved-font (downcase resolved-font)) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
516 (setq resolved-font (downcase (x-resolve-font-name font)))) |
88405 | 517 (let ((xlfd (x-decompose-font-name resolved-font)) |
518 fontset) | |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
519 (if fontset-name |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
520 (setq fontset-name (downcase fontset-name)) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
521 (setq fontset-name |
88405 | 522 (subst-char-in-string |
523 "-" "_" (aref xlfd xlfd-regexp-registry-subnum) t))) | |
524 (aset xlfd xlfd-regexp-registry-subnum | |
525 (format "fontset-%s" fontset-name)) | |
22672
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
526 (setq fontset (x-compose-font-name xlfd)) |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
527 (or (query-fontset fontset) |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
528 (create-fontset-from-fontset-spec (concat fontset ", ascii:" font))))) |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
529 |
17052 | 530 |
17842
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
531 ;; 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
|
532 ;; 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
|
533 ;; 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
|
534 ;; many cases. |
17842
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
535 (defvar standard-fontset-spec |
88405 | 536 (purecopy "-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard") |
17842
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
537 "String of fontset spec of the standard fontset. |
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
538 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
|
539 with correct glyphs by using the standard fontset. |
17052 | 540 See the documentation of `create-fontset-from-fontset-spec' for the format.") |
541 | |
542 ;; Create fontsets from X resources of the name `fontset-N (class | |
543 ;; Fontset-N)' where N is integer 0, 1, ... | |
544 ;; 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
|
545 ;; `standard-fontset-spec'. |
17052 | 546 |
547 (defun create-fontset-from-x-resource () | |
548 (let ((idx 0) | |
549 fontset-spec) | |
27534
eeb998860456
(standard-fontset-spec): Purecopy it.
Dave Love <fx@gnu.org>
parents:
26886
diff
changeset
|
550 (while (setq fontset-spec (x-get-resource (format "fontset-%d" idx) |
eeb998860456
(standard-fontset-spec): Purecopy it.
Dave Love <fx@gnu.org>
parents:
26886
diff
changeset
|
551 (format "Fontset-%d" idx))) |
24153
729affdf2ca1
(create-fontset-from-x-resource): Make style variants.
Kenichi Handa <handa@m17n.org>
parents:
23890
diff
changeset
|
552 (create-fontset-from-fontset-spec fontset-spec t 'noerror) |
17052 | 553 (setq idx (1+ idx))))) |
554 | |
555 ;; | |
556 (provide 'fontset) | |
557 | |
558 ;;; fontset.el ends here |