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