Mercurial > emacs
annotate lisp/international/fontset.el @ 88785:3387266b74c1
(utf-8-ccl-encode): Deleted.
(ucs-input-method): Modified.
author | Dave Love <fx@gnu.org> |
---|---|
date | Mon, 24 Jun 2002 19:26:00 +0000 |
parents | cd23fd4b0145 |
children | 86354924a790 |
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")) |
88694
cd23fd4b0145
Change registry for japanese-jisx0208
Kenichi Handa <handa@m17n.org>
parents:
88595
diff
changeset
|
61 (japanese-jisx0208 . (nil . "JISX0208*")) |
88405 | 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) | |
88694
cd23fd4b0145
Change registry for japanese-jisx0208
Kenichi Handa <handa@m17n.org>
parents:
88595
diff
changeset
|
138 ("JISX0208.1983" . japanese-jisx0208) |
88405 | 139 ("KSC5601.1987" . korean-ksc5601) |
140 ("JISX0212" . japanese-jisx0212) | |
141 ("CNS11643.1992-1" . chinese-cns11643-1) | |
142 ("CNS11643.1992-2" . chinese-cns11643-2) | |
143 ("CNS11643.1992-3" . chinese-cns11643-3) | |
144 ("CNS11643.1992-4" . chinese-cns11643-4) | |
145 ("CNS11643.1992-5" . chinese-cns11643-5) | |
146 ("CNS11643.1992-6" . chinese-cns11643-6) | |
147 ("CNS11643.1992-7" . chinese-cns11643-7) | |
148 ("Big5" . big5) | |
149 ("sisheng_cwnn" . chinese-sisheng) | |
150 ("VISCII" . viscii) | |
151 ("MuleArabic-0" . arabic-digit) | |
152 ("MuleArabic-1" . arabic-1-column) | |
153 ("MuleArabic-2" . arabic-2-column) | |
154 ("MuleIPA" . ipa) | |
155 ("Ethiopic-Unicode" . ethiopic) | |
156 ("IS13194-Devanagari" . indian-is13194) | |
157 ("MuleIndian-2" . indian-2-column) | |
158 ("MuleIndian-1" . indian-1-column) | |
159 ("MuleLao-1" . mule-lao) | |
160 ("MuleTibetan-2" . tibetan) | |
161 ("MuleTibetan-1" . tibetan-1-column) | |
162 ("ISO8859-14" . iso-8859-14) | |
163 ("ISO8859-15" . iso-8859-15) | |
164 ("JISX0213.2000-1" . japanese-jisx0213-1) | |
165 ("JISX0213.2000-2" . japanese-jisx0213-2) | |
88579 | 166 ("abobe-symbol" . symbol) |
88694
cd23fd4b0145
Change registry for japanese-jisx0208
Kenichi Handa <handa@m17n.org>
parents:
88595
diff
changeset
|
167 ("ISO10646-1" . unicode) |
cd23fd4b0145
Change registry for japanese-jisx0208
Kenichi Handa <handa@m17n.org>
parents:
88595
diff
changeset
|
168 ("ISO10646.indian-1" . unicode))) |
17052 | 169 |
170 ;; Set arguments in `font-encoding-alist' (which see). | |
88405 | 171 (defun set-font-encoding (pattern charset) |
17052 | 172 (let ((slot (assoc pattern font-encoding-alist))) |
173 (if slot | |
88405 | 174 (setcdr slot charset) |
17052 | 175 (setq font-encoding-alist |
88405 | 176 (cons (cons pattern charset) font-encoding-alist))))) |
32646
43edadfecb51
Use registry "MuleTibetan-2" for Tibetan.
Kenichi Handa <handa@m17n.org>
parents:
29427
diff
changeset
|
177 |
17052 | 178 ;; Setting for suppressing XLoadQueryFont on big fonts. |
179 (setq x-pixel-size-width-font-regexp | |
180 "gb2312\\|jisx0208\\|ksc5601\\|cns11643\\|big5") | |
181 | |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
182 ;; These fonts require vertical centering. |
26886
8a6d8101919e
(vertical-centering-font-regexp): New
Kenichi Handa <handa@m17n.org>
parents:
26013
diff
changeset
|
183 (setq vertical-centering-font-regexp |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
184 "gb2312\\|jisx0208\\|jisx0212\\|ksc5601\\|cns11643\\|big5") |
26886
8a6d8101919e
(vertical-centering-font-regexp): New
Kenichi Handa <handa@m17n.org>
parents:
26013
diff
changeset
|
185 |
88405 | 186 (defvar x-font-name-charset-alist nil |
187 "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
|
188 |
17052 | 189 ;;; XLFD (X Logical Font Description) format handler. |
190 | |
191 ;; Define XLFD's field index numbers. ; field name | |
88405 | 192 (defconst xlfd-regexp-family-subnum 0) ; FOUNDRY and FAMILY |
193 (defconst xlfd-regexp-weight-subnum 1) ; WEIGHT_NAME | |
194 (defconst xlfd-regexp-slant-subnum 2) ; SLANT | |
195 (defconst xlfd-regexp-swidth-subnum 3) ; SETWIDTH_NAME | |
196 (defconst xlfd-regexp-adstyle-subnum 4) ; ADD_STYLE_NAME | |
197 (defconst xlfd-regexp-pixelsize-subnum 5) ; PIXEL_SIZE | |
198 (defconst xlfd-regexp-pointsize-subnum 6) ; POINT_SIZE | |
199 (defconst xlfd-regexp-resx-subnum 7) ; RESOLUTION_X | |
200 (defconst xlfd-regexp-resy-subnum 8) ; RESOLUTION_Y | |
201 (defconst xlfd-regexp-spacing-subnum 8) ; SPACING | |
202 (defconst xlfd-regexp-avgwidth-subnum 10) ; AVERAGE_WIDTH | |
203 (defconst xlfd-regexp-registry-subnum 11) ; REGISTRY and ENCODING | |
17052 | 204 |
205 ;; Regular expression matching against a fontname which conforms to | |
206 ;; XLFD (X Logical Font Description). All fields in XLFD should be | |
207 ;; not be omitted (but can be a wild card) to be matched. | |
208 (defconst xlfd-tight-regexp | |
209 "^\ | |
88405 | 210 -\\([^-]*-[^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\ |
17052 | 211 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\ |
88405 | 212 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*-[^-]*\\)$") |
213 | |
214 ;; Regular expression matching against a fontname which conforms to | |
215 ;; XLFD (X Logical Font Description). All fields in XLFD from FOUNDRY | |
216 ;; to ADSTYLE, REGSITRY, and ENCODING should be not be omitted (but | |
217 ;; can be a wild card) to be matched. | |
218 (defconst xlfd-style-regexp | |
219 "^\ | |
220 -\\([^-]*-[^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-.*\ | |
221 -\\([^-]*-[^-]*\\)$") | |
17052 | 222 |
223 ;; List of field numbers of XLFD whose values are numeric. | |
224 (defconst xlfd-regexp-numeric-subnums | |
88405 | 225 (list xlfd-regexp-pixelsize-subnum ;5 |
226 xlfd-regexp-pointsize-subnum ;6 | |
227 xlfd-regexp-resx-subnum ;7 | |
228 xlfd-regexp-resy-subnum ;8 | |
229 xlfd-regexp-avgwidth-subnum ;10 | |
17052 | 230 )) |
231 | |
232 (defun x-decompose-font-name (pattern) | |
233 "Decompose PATTERN into XLFD's fields and return vector of the fields. | |
88405 | 234 The length of the vector is 12. |
17052 | 235 |
236 If PATTERN doesn't conform to XLFD, try to get a full XLFD name from | |
237 X server and use the information of the full name to decompose | |
238 PATTERN. If no full XLFD name is gotten, return nil." | |
239 (let (xlfd-fields fontname) | |
240 (if (string-match xlfd-tight-regexp pattern) | |
88405 | 241 (progn |
242 (setq xlfd-fields (make-vector 12 nil)) | |
243 (dotimes (i 12) | |
244 (aset xlfd-fields i (match-string (1+ i) pattern))) | |
245 (dotimes (i 12) | |
246 (if (string-match "^[*-]+$" (aref xlfd-fields i)) | |
247 (aset xlfd-fields i nil))) | |
17052 | 248 xlfd-fields) |
249 (setq fontname (condition-case nil | |
250 (x-resolve-font-name pattern) | |
251 (error))) | |
252 (if (and fontname | |
253 (string-match xlfd-tight-regexp fontname)) | |
23890
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
254 ;; We get a full XLFD name. |
17052 | 255 (let ((len (length pattern)) |
256 (i 0) | |
257 l) | |
23890
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
258 ;; 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
|
259 ;; should be a cons of matched index and matched string. |
88405 | 260 (setq xlfd-fields (make-vector 12 nil)) |
261 (dotimes (i 12) | |
17052 | 262 (aset xlfd-fields i |
263 (cons (match-beginning (1+ i)) | |
88405 | 264 (match-string (1+ i) fontname)))) |
23890
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
265 |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
266 ;; Replace wild cards in PATTERN by regexp codes. |
17052 | 267 (setq i 0) |
268 (while (< i len) | |
269 (let ((ch (aref pattern i))) | |
270 (if (= ch ??) | |
271 (setq pattern (concat (substring pattern 0 i) | |
272 "\\(.\\)" | |
273 (substring pattern (1+ i))) | |
274 len (+ len 4) | |
275 i (+ i 4)) | |
276 (if (= ch ?*) | |
277 (setq pattern (concat (substring pattern 0 i) | |
278 "\\(.*\\)" | |
279 (substring pattern (1+ i))) | |
280 len (+ len 5) | |
281 i (+ i 5)) | |
282 (setq i (1+ i)))))) | |
23890
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
283 |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
284 ;; 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
|
285 (if (string-match pattern fontname) |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
286 ;; The regular expression PATTERN matchs the full XLFD |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
287 ;; name. Set elements that correspond to a wild card |
88405 | 288 ;; 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
|
289 ;; exact strings in PATTERN. |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
290 (let ((l (cdr (cdr (match-data))))) |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
291 (setq i 0) |
88405 | 292 (while (< i 12) |
23890
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
293 (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
|
294 (progn |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
295 (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
|
296 (setq i (1+ i))) |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
297 (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
|
298 (progn |
88405 | 299 (aset xlfd-fields i nil) |
23890
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
300 (setq i (1+ i))) |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
301 (setq l (cdr (cdr l))))))) |
fa4839661777
(x-decompose-font-name): If PATTERN
Kenichi Handa <handa@m17n.org>
parents:
23655
diff
changeset
|
302 ;; 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
|
303 ;; in the corresonding fields in full XLFD name. |
88405 | 304 (dotimes (i 12) |
305 (aset xlfd-fields i (cdr (aref xlfd-fields i))))) | |
17052 | 306 xlfd-fields))))) |
307 | |
22449
c87830c691a5
(instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents:
22161
diff
changeset
|
308 (defun x-compose-font-name (fields &optional reduce) |
17052 | 309 "Compose X's fontname from FIELDS. |
88405 | 310 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
|
311 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
|
312 Optional argument REDUCE is always ignored. It exists just for |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
313 backward compatibility." |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
314 (concat "-" (mapconcat (lambda (x) (or x "*")) fields "-"))) |
23205
22df54cdb841
(resolved-ascii-font): New variable.
Kenichi Handa <handa@m17n.org>
parents:
23196
diff
changeset
|
315 |
40250
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
316 (defun x-must-resolve-font-name (xlfd-fields) |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
317 "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
|
318 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
|
319 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
|
320 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
|
321 Value is name of that font." |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
322 (let ((ascii-font nil) (index 0)) |
88405 | 323 (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
|
324 (let ((pattern (x-compose-font-name xlfd-fields))) |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
325 (condition-case nil |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
326 (setq ascii-font (x-resolve-font-name pattern)) |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
327 (error |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
328 (message "Warning: no fonts matching `%s' available" pattern) |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
329 (aset xlfd-fields index "*") |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
330 (setq index (1+ index)))))) |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
331 (unless ascii-font |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
332 (error "No fonts founds")) |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
333 ascii-font)) |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
334 |
4f3033e5b688
(x-must-resolve-font-name): New
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
335 |
17052 | 336 (defun x-complement-fontset-spec (xlfd-fields fontlist) |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
337 "Complement FONTLIST for charsets based on XLFD-FIELDS and return it. |
17052 | 338 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
|
339 FONTLIST is an alist of charsets vs the corresponding font names. |
17052 | 340 |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
341 The fonts are complemented as below. |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
342 |
88405 | 343 At first, if FONTLIST doesn't specify a font for ASCII charset, |
344 generate a font name for the charset from XLFD-FIELDS, and add that | |
345 information to FONTLIST. | |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
346 |
88405 | 347 Then, replace font names with the corresponding XLFD field vectors |
348 while substituting default field names for wild cards if they match | |
349 `xlfd-style-regexp'. The default field names are decided by | |
350 XLFD-FIELDS." | |
351 (let* ((default-spec (vector (aref xlfd-fields xlfd-regexp-family-subnum) | |
352 (aref xlfd-fields xlfd-regexp-weight-subnum) | |
353 (aref xlfd-fields xlfd-regexp-slant-subnum) | |
354 (aref xlfd-fields xlfd-regexp-swidth-subnum) | |
355 (aref xlfd-fields xlfd-regexp-adstyle-subnum) | |
356 (aref xlfd-fields xlfd-regexp-registry-subnum))) | |
357 (slot (assq 'ascii fontlist)) | |
36368
dbd54e46ee03
(x-complement-fontset-spec): In the
Kenichi Handa <handa@m17n.org>
parents:
34917
diff
changeset
|
358 (ascii-font (cdr slot)) |
88405 | 359 xlfd-ascii) |
34917
989f2f0c8a7e
(x-complement-fontset-spec): Resolve
Kenichi Handa <handa@m17n.org>
parents:
34245
diff
changeset
|
360 (if ascii-font |
88405 | 361 (progn |
362 (setcdr slot (setq ascii-font (x-resolve-font-name ascii-font))) | |
363 (setq xlfd-ascii (x-decompose-font-name ascii-font)) | |
364 (dotimes (i 11) | |
365 (or (aref xlfd-fields i) | |
366 (aset xlfd-fields i (aref xlfd-ascii i))))) | |
34917
989f2f0c8a7e
(x-complement-fontset-spec): Resolve
Kenichi Handa <handa@m17n.org>
parents:
34245
diff
changeset
|
367 ;; If font for ASCII is not specified, add it. |
88405 | 368 (setq xlfd-ascii (copy-sequence xlfd-fields)) |
369 (aset xlfd-ascii xlfd-regexp-registry-subnum "iso8859-1") | |
370 (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
|
371 (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
|
372 |
88405 | 373 (dolist (elt fontlist) |
374 (let ((name (cdr elt)) | |
375 font-spec) | |
376 (when (string-match xlfd-style-regexp name) | |
377 (setq font-spec (make-vector 6 nil)) | |
378 (dotimes (i 6) | |
379 (aset font-spec i (match-string (1+ i) name))) | |
380 (dotimes (i 6) | |
381 (if (string-match "^[*-]+$" (aref font-spec i)) | |
382 (aset font-spec i (aref default-spec i)))) | |
383 (setcdr elt font-spec)))) | |
384 | |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
385 fontlist)) |
17052 | 386 |
19049
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
387 (defun fontset-name-p (fontset) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
388 "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
|
389 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
|
390 with \"fontset\" in `<CHARSET_REGISTRY> field." |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
391 (and (string-match xlfd-tight-regexp fontset) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
392 (string= (match-string (1+ xlfd-regexp-registry-subnum) fontset) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
393 "fontset"))) |
cad4c032fa26
(fontset-name-p): New function.
Kenichi Handa <handa@m17n.org>
parents:
18719
diff
changeset
|
394 |
17052 | 395 ;; Return a list to be appended to `x-fixed-font-alist' when |
396 ;; `mouse-set-font' is called. | |
397 (defun generate-fontset-menu () | |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
398 (let ((fontsets (fontset-list)) |
17052 | 399 fontset-name |
400 l) | |
401 (while fontsets | |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
402 (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
|
403 (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
|
404 (cons "Fontset" |
ab814ec4995e
(generate-fontset-menu): Return a
Kenichi Handa <handa@m17n.org>
parents:
24153
diff
changeset
|
405 (sort l (function (lambda (x y) (string< (car x) (car y)))))))) |
17052 | 406 |
407 (defun fontset-plain-name (fontset) | |
408 "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
|
409 (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
|
410 (error "Invalid fontset: %s" fontset)) |
17052 | 411 (let ((xlfd-fields (x-decompose-font-name fontset))) |
412 (if xlfd-fields | |
413 (let ((weight (aref xlfd-fields xlfd-regexp-weight-subnum)) | |
414 (slant (aref xlfd-fields xlfd-regexp-slant-subnum)) | |
415 (swidth (aref xlfd-fields xlfd-regexp-swidth-subnum)) | |
416 (size (aref xlfd-fields xlfd-regexp-pixelsize-subnum)) | |
88405 | 417 (nickname (aref xlfd-fields xlfd-regexp-registry-subnum)) |
17052 | 418 name) |
88405 | 419 (if (not (string-match "^fontset-\\(.*\\)$" nickname)) |
17052 | 420 fontset |
88405 | 421 (setq nickname (match-string 1 nickname)) |
88484 | 422 (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
|
423 (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
|
424 (setq name nickname)) |
88483
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
425 (and weight |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
426 (cond ((string-match "^medium$" weight) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
427 (setq name (concat name " " "medium"))) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
428 ((string-match "^bold$\\|^demibold$" weight) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
429 (setq name (concat name " " weight))))) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
430 (and slant |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
431 (cond ((string-match "^i$" slant) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
432 (setq name (concat name " " "italic"))) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
433 ((string-match "^o$" slant) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
434 (setq name (concat name " " "slant"))) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
435 ((string-match "^ri$" slant) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
436 (setq name (concat name " " "reverse italic"))) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
437 ((string-match "^ro$" slant) |
b6df31da4a9e
(fontset-plain-name): Handle the case
Kenichi Handa <handa@m17n.org>
parents:
88449
diff
changeset
|
438 (setq name (concat name " " "reverse slant"))))) |
17052 | 439 name)) |
440 fontset))) | |
441 | |
22128
8f7a59fc78db
(create-fontset-from-fontset-spec): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
19771
diff
changeset
|
442 ;;;###autoload |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
443 (defun create-fontset-from-fontset-spec (fontset-spec |
22449
c87830c691a5
(instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents:
22161
diff
changeset
|
444 &optional style-variant noerror) |
17052 | 445 "Create a fontset from fontset specification string FONTSET-SPEC. |
446 FONTSET-SPEC is a string of the format: | |
447 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
|
448 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
|
449 |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
450 Optional 2nd argument is ignored. It exists just for backward |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
451 compatibility. |
22449
c87830c691a5
(instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents:
22161
diff
changeset
|
452 |
18719
de8249499f33
(create-fontset-from-fontset-spec): Typo in doc-string fixed.
Kenichi Handa <handa@m17n.org>
parents:
18714
diff
changeset
|
453 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
|
454 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
|
455 |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
456 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
|
457 (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
|
458 (error "Invalid fontset spec: %s" fontset-spec)) |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
459 (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
|
460 (let ((idx (match-end 0)) |
4c82e87c7d7c
(x-decompose-font-name): While seting each field of
Kenichi Handa <handa@m17n.org>
parents:
17339
diff
changeset
|
461 (name (match-string 0 fontset-spec)) |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
462 xlfd-fields charset fontlist ascii-font) |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
463 (if (query-fontset name) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
464 (or noerror |
23655
8aa7d51024b2
(create-fontset-from-fontset-spec): Give correct arg to `error'.
Kenichi Handa <handa@m17n.org>
parents:
23205
diff
changeset
|
465 (error "Fontset \"%s\" already exists" name)) |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
466 (setq xlfd-fields (x-decompose-font-name name)) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
467 (or xlfd-fields |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
468 (error "Fontset \"%s\" not conforming to XLFD" name)) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
469 |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
470 ;; 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
|
471 (while (string-match "[, \t\n]*\\([^:]+\\):\\([^,]+\\)" fontset-spec idx) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
472 (setq idx (match-end 0)) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
473 (setq charset (intern (match-string 1 fontset-spec))) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
474 (if (charsetp charset) |
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
475 (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
|
476 fontlist)))) |
34917
989f2f0c8a7e
(x-complement-fontset-spec): Resolve
Kenichi Handa <handa@m17n.org>
parents:
34245
diff
changeset
|
477 (setq ascii-font (cdr (assq 'ascii fontlist))) |
22449
c87830c691a5
(instantiate-fontset): Delete
Kenichi Handa <handa@m17n.org>
parents:
22161
diff
changeset
|
478 |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
479 ;; Complement FONTLIST. |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
480 (setq fontlist (x-complement-fontset-spec xlfd-fields fontlist)) |
88405 | 481 (setq name (x-compose-font-name xlfd-fields)) |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
482 (new-fontset name fontlist) |
22161
7a4c3fd89dda
(x-font-name-charset-alist): New
Kenichi Handa <handa@m17n.org>
parents:
22128
diff
changeset
|
483 |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
484 ;; Define the short name alias. |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
485 (if (and (string-match "fontset-.*$" name) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
486 (not (assoc name fontset-alias-alist))) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
487 (let ((alias (match-string 0 name))) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
488 (or (rassoc alias fontset-alias-alist) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
489 (setq fontset-alias-alist |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
490 (cons (cons name alias) fontset-alias-alist))))) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
491 |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
492 ;; Define the ASCII font name alias. |
34917
989f2f0c8a7e
(x-complement-fontset-spec): Resolve
Kenichi Handa <handa@m17n.org>
parents:
34245
diff
changeset
|
493 (or ascii-font |
989f2f0c8a7e
(x-complement-fontset-spec): Resolve
Kenichi Handa <handa@m17n.org>
parents:
34245
diff
changeset
|
494 (setq ascii-font (cdr (assq 'ascii fontlist)))) |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
495 (or (rassoc ascii-font fontset-alias-alist) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
496 (setq fontset-alias-alist |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
497 (cons (cons name ascii-font) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
498 fontset-alias-alist)))) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
499 |
22672
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
500 name)) |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
501 |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
502 (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
|
503 fontset-name) |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
504 "Create a fontset from an ASCII font FONT. |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
505 |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
506 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
|
507 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
|
508 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
|
509 |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
510 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
|
511 `<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
|
512 an appropriate name is generated automatically. |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
513 |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
514 It returns a name of the created fontset." |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
515 (setq font (downcase font)) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
516 (if resolved-font |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
517 (setq resolved-font (downcase resolved-font)) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
518 (setq resolved-font (downcase (x-resolve-font-name font)))) |
88405 | 519 (let ((xlfd (x-decompose-font-name resolved-font)) |
520 fontset) | |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
521 (if fontset-name |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
522 (setq fontset-name (downcase fontset-name)) |
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
523 (setq fontset-name |
88405 | 524 (subst-char-in-string |
525 "-" "_" (aref xlfd xlfd-regexp-registry-subnum) t))) | |
526 (aset xlfd xlfd-regexp-registry-subnum | |
527 (format "fontset-%s" fontset-name)) | |
22672
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
528 (setq fontset (x-compose-font-name xlfd)) |
9cfa1a788a5a
(create-fontset-from-fontset-spec):
Kenichi Handa <handa@m17n.org>
parents:
22618
diff
changeset
|
529 (or (query-fontset fontset) |
28215
ceaded4c2cb9
(x-charset-registries): Variable
Kenichi Handa <handa@m17n.org>
parents:
27534
diff
changeset
|
530 (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
|
531 |
17052 | 532 |
17842
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
533 ;; 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
|
534 ;; 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
|
535 ;; 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
|
536 ;; many cases. |
17842
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
537 (defvar standard-fontset-spec |
88405 | 538 (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
|
539 "String of fontset spec of the standard fontset. |
cb1af8ead3df
(standard-fontset-spec): Name changed from
Kenichi Handa <handa@m17n.org>
parents:
17755
diff
changeset
|
540 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
|
541 with correct glyphs by using the standard fontset. |
17052 | 542 See the documentation of `create-fontset-from-fontset-spec' for the format.") |
543 | |
544 ;; Create fontsets from X resources of the name `fontset-N (class | |
545 ;; Fontset-N)' where N is integer 0, 1, ... | |
546 ;; 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
|
547 ;; `standard-fontset-spec'. |
17052 | 548 |
549 (defun create-fontset-from-x-resource () | |
550 (let ((idx 0) | |
551 fontset-spec) | |
27534
eeb998860456
(standard-fontset-spec): Purecopy it.
Dave Love <fx@gnu.org>
parents:
26886
diff
changeset
|
552 (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
|
553 (format "Fontset-%d" idx))) |
24153
729affdf2ca1
(create-fontset-from-x-resource): Make style variants.
Kenichi Handa <handa@m17n.org>
parents:
23890
diff
changeset
|
554 (create-fontset-from-fontset-spec fontset-spec t 'noerror) |
17052 | 555 (setq idx (1+ idx))))) |
556 | |
557 ;; | |
558 (provide 'fontset) | |
559 | |
560 ;;; fontset.el ends here |