annotate lisp/international/fontset.el @ 17738:f20c2a909ad3

(command_loop_1): Use an int for last_command_char.
author Richard M. Stallman <rms@gnu.org>
date Sat, 10 May 1997 21:48:30 +0000
parents 8ce3d2e461bc
children 4c82e87c7d7c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1 ;;; fontset.el --- Commands for handling fontset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1995 Free Software Foundation, Inc.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6 ;; Keywords: mule, multilingual, fontset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
7
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
9
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13 ;; any later version.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
14
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
19
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
23 ;; Boston, MA 02111-1307, USA.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
24
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
25 ;;; Code:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
26
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
27 ;; Set default REGISTRY property of charset to find an appropriate
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
28 ;; font for each charset. This is used to generate a font name in a
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
29 ;; fontset. If the value contains a character `-', the string before
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30 ;; that is embeded in `CHARSET_REGISTRY' field, and the string after
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
31 ;; that is embeded in `CHARSET_ENCODING' field. If the value does not
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
32 ;; contain `-', the whole string is embeded in `CHARSET_REGISTRY'
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
33 ;; field, and a wild card character `*' is embeded in
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
34 ;; `CHARSET_ENCODING' field.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
35
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
36 (defvar x-charset-registries
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
37 '((ascii . "ISO8859-1")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
38 (latin-iso8859-1 . "ISO8859-1")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
39 (latin-iso8859-2 . "ISO8859-2")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40 (latin-iso8859-3 . "ISO8859-3")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41 (latin-iso8859-4 . "ISO8859-4")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42 (thai-tis620 . "TIS620")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
43 (greek-iso8859-7 . "ISO8859-7")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44 (arabic-iso8859-6 . "ISO8859-6")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 (hebrew-iso8859-8 . "ISO8859-8")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 (katakana-jisx0201 . "JISX0201")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
47 (latin-jisx0201 . "JISX0201")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48 (cyrillic-iso8859-5 . "ISO8859-5")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
49 (latin-iso8859-9 . "ISO8859-9")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
50 (japanese-jisx0208-1978 . "JISX0208.1978")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51 (chinese-gb2312 . "GB2312")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
52 (japanese-jisx0208 . "JISX0208.1983")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
53 (korean-ksc5601 . "KSC5601")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54 (japanese-jisx0212 . "JISX0212")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
55 (chinese-cns11643-1 . "CNS11643.1992-1")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
56 (chinese-cns11643-2 . "CNS11643.1992-2")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
57 (chinese-cns11643-3 . "CNS11643.1992-3")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
58 (chinese-cns11643-4 . "CNS11643.1992-4")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
59 (chinese-cns11643-5 . "CNS11643.1992-5")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
60 (chinese-cns11643-6 . "CNS11643.1992-6")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
61 (chinese-cns11643-7 . "CNS11643.1992-7")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
62 (chinese-big5-1 . "Big5")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
63 (chinese-big5-2 . "Big5")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
64 (chinese-sisheng . "sisheng_cwnn")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65 (vietnamese-viscii-lower . "VISCII1.1")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66 (vietnamese-viscii-upper . "VISCII1.1")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
67 (arabic-digit . "MuleArabic-0")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
68 (arabic-1-column . "MuleArabic-1")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
69 (arabic-2-column . "MuleArabic-2")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
70 (ipa . "MuleIPA")
17177
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
71 (ethiopic . "Ethiopic-Unicode")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
72 (ascii-right-to-left . "ISO8859-1")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
73 (indian-is13194 . "IS13194-Devanagari")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
74 (indian-2-column . "MuleIndian-2")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
75 (indian-1-column . "MuleIndian-1")
17295
34efd2073019 (x-charset-registries): Add Tibetan entries.
Kenichi Handa <handa@m17n.org>
parents: 17195
diff changeset
76 (lao . "lao.mule-1")
17339
8ce3d2e461bc When calling put-charset-property, ignore errors.
Richard M. Stallman <rms@gnu.org>
parents: 17336
diff changeset
77 (tibetan . "Mule.Tibetan-0")
8ce3d2e461bc When calling put-charset-property, ignore errors.
Richard M. Stallman <rms@gnu.org>
parents: 17336
diff changeset
78 (tibetan-1-column . "Mule.Tibetan-1")
17295
34efd2073019 (x-charset-registries): Add Tibetan entries.
Kenichi Handa <handa@m17n.org>
parents: 17195
diff changeset
79 ))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
80
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
81 (let ((l x-charset-registries))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
82 (while l
17339
8ce3d2e461bc When calling put-charset-property, ignore errors.
Richard M. Stallman <rms@gnu.org>
parents: 17336
diff changeset
83 (condition-case nil
8ce3d2e461bc When calling put-charset-property, ignore errors.
Richard M. Stallman <rms@gnu.org>
parents: 17336
diff changeset
84 (put-charset-property (car (car l)) 'x-charset-registry (cdr (car l)))
8ce3d2e461bc When calling put-charset-property, ignore errors.
Richard M. Stallman <rms@gnu.org>
parents: 17336
diff changeset
85 (error nil))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
86 (setq l (cdr l))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
87
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
88 ;; Set arguments in `font-encoding-alist' (which see).
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
89 (defun set-font-encoding (pattern charset encoding)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
90 (let ((slot (assoc pattern font-encoding-alist)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
91 (if slot
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
92 (let ((place (assq charset (cdr slot))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
93 (if place
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
94 (setcdr place encoding)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
95 (setcdr slot (cons (cons charset encoding) (cdr slot)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
96 (setq font-encoding-alist
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
97 (cons (list pattern (cons charset encoding)) font-encoding-alist)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
98 ))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
99
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100 (set-font-encoding "ISO8859-1" 'ascii 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 (set-font-encoding "JISX0201" 'latin-jisx0201 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
102
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
103 ;; Setting for suppressing XLoadQueryFont on big fonts.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
104 (setq x-pixel-size-width-font-regexp
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
105 "gb2312\\|jisx0208\\|ksc5601\\|cns11643\\|big5")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
106
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
107 ;;; XLFD (X Logical Font Description) format handler.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
108
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
109 ;; Define XLFD's field index numbers. ; field name
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
110 (defconst xlfd-regexp-foundry-subnum 0) ; FOUNDRY
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
111 (defconst xlfd-regexp-family-subnum 1) ; FAMILY_NAME
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
112 (defconst xlfd-regexp-weight-subnum 2) ; WEIGHT_NAME
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
113 (defconst xlfd-regexp-slant-subnum 3) ; SLANT
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
114 (defconst xlfd-regexp-swidth-subnum 4) ; SETWIDTH_NAME
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
115 (defconst xlfd-regexp-adstyle-subnum 5) ; ADD_STYLE_NAME
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
116 (defconst xlfd-regexp-pixelsize-subnum 6) ; PIXEL_SIZE
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
117 (defconst xlfd-regexp-pointsize-subnum 7) ; POINT_SIZE
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
118 (defconst xlfd-regexp-resx-subnum 8) ; RESOLUTION_X
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
119 (defconst xlfd-regexp-resy-subnum 9) ; RESOLUTION_Y
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
120 (defconst xlfd-regexp-spacing-subnum 10) ; SPACING
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
121 (defconst xlfd-regexp-avgwidth-subnum 11) ; AVERAGE_WIDTH
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
122 (defconst xlfd-regexp-registry-subnum 12) ; CHARSET_REGISTRY
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
123 (defconst xlfd-regexp-encoding-subnum 13) ; CHARSET_ENCODING
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
124
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
125 ;; Regular expression matching against a fontname which conforms to
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
126 ;; XLFD (X Logical Font Description). All fields in XLFD should be
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
127 ;; not be omitted (but can be a wild card) to be matched.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128 (defconst xlfd-tight-regexp
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
129 "^\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 -\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)-\\([^-]*\\)$")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
133
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
134 ;; List of field numbers of XLFD whose values are numeric.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
135 (defconst xlfd-regexp-numeric-subnums
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136 (list xlfd-regexp-pixelsize-subnum ;6
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137 xlfd-regexp-pointsize-subnum ;7
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138 xlfd-regexp-resx-subnum ;8
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139 xlfd-regexp-resy-subnum ;9
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140 xlfd-regexp-avgwidth-subnum ;11
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141 ))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
142
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
143 (defun x-decompose-font-name (pattern)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
144 "Decompose PATTERN into XLFD's fields and return vector of the fields.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
145 The length of the vector is 14.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
146
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
147 If PATTERN doesn't conform to XLFD, try to get a full XLFD name from
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148 X server and use the information of the full name to decompose
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
149 PATTERN. If no full XLFD name is gotten, return nil."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
150 (let (xlfd-fields fontname)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
151 (if (string-match xlfd-tight-regexp pattern)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
152 (let ((i 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
153 (setq xlfd-fields (make-vector 14 nil))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
154 (while (< i 14)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
155 (aset xlfd-fields i (match-string (1+ i) pattern))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156 (setq i (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
157 xlfd-fields)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
158 (setq fontname (condition-case nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
159 (x-resolve-font-name pattern)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
160 (error)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161 (if (and fontname
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
162 (string-match xlfd-tight-regexp fontname))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163 (let ((len (length pattern))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
164 (i 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165 l)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166 (setq xlfd-fields (make-vector 14 nil))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
167 (while (< i 14)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168 (aset xlfd-fields i
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
169 (cons (match-beginning (1+ i))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170 (match-string (1+ i) fontname)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
171 (setq i (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
172 (setq i 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
173 (while (< i len)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
174 (let ((ch (aref pattern i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
175 (if (= ch ??)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
176 (setq pattern (concat (substring pattern 0 i)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
177 "\\(.\\)"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
178 (substring pattern (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
179 len (+ len 4)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
180 i (+ i 4))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
181 (if (= ch ?*)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
182 (setq pattern (concat (substring pattern 0 i)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
183 "\\(.*\\)"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
184 (substring pattern (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
185 len (+ len 5)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
186 i (+ i 5))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
187 (setq i (1+ i))))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
188 (string-match pattern fontname)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
189 (setq l (cdr (cdr (match-data))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
190 (setq i 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
191 (while (< i 14)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
192 (if (or (null l) (< (car (aref xlfd-fields i)) (car l)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
193 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
194 (aset xlfd-fields i (cdr (aref xlfd-fields i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
195 (setq i (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
196 (if (< (car (aref xlfd-fields i)) (car (cdr l)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
197 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
198 (aset xlfd-fields i nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
199 (setq i (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
200 (setq l (cdr (cdr l))))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
201 xlfd-fields)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
202
17177
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
203 ;; Replace consecutive wild-cards (`*') in NAME to one.
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
204 ;; Ex. (x-reduce-font-name "-*-*-*-iso8859-1") => "-*-iso8859-1"
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
205 (defsubst x-reduce-font-name (name)
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
206 (while (string-match "-\\*-\\(\\*-\\)+" name)
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
207 (setq name (replace-match "-*-" t t name)))
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
208 name)
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
209
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
210 (defun x-compose-font-name (xlfd-fields &optional reduce)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
211 "Compose X's fontname from FIELDS.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
212 FIELDS is a vector of XLFD fields.
17177
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
213 If a field is nil, wild-card letter `*' is embedded.
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
214 Optional argument REDUCE non-nil means consecutive wild-cards are
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
215 reduced to be one."
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
216 (let ((name
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
217 (concat "-" (mapconcat (lambda (x) (or x "*")) xlfd-fields "-"))))
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
218 (if reduce
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
219 (x-reduce-font-name name)
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
220 name)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
221
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
222 (defun x-complement-fontset-spec (xlfd-fields fontlist)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
223 "Complement FONTLIST for all charsets based on XLFD-FIELDS and return it.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
224 XLFD-FIELDS is a vector of XLFD (X Logical Font Description) fields.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
225 FONTLIST is an alist of cons of charset and fontname.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
226
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
227 Fontnames for charsets not listed in FONTLIST are generated from
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
228 XLFD-FIELDS and a property of x-charset-register of each charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
229 automatically."
17195
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
230 (let ((charsets charset-list)
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
231 (loose-xlfd-fields (copy-sequence xlfd-fields)))
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
232 (aset loose-xlfd-fields xlfd-regexp-pixelsize-subnum nil)
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
233 (aset loose-xlfd-fields xlfd-regexp-pointsize-subnum nil)
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
234 (aset loose-xlfd-fields xlfd-regexp-resx-subnum nil)
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
235 (aset loose-xlfd-fields xlfd-regexp-resy-subnum nil)
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
236 (aset loose-xlfd-fields xlfd-regexp-spacing-subnum nil)
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
237 (aset loose-xlfd-fields xlfd-regexp-avgwidth-subnum nil)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
238 (while charsets
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
239 (let ((charset (car charsets)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
240 (if (null (assq charset fontlist))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
241 (let ((registry (get-charset-property charset
17195
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
242 'x-charset-registry))
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
243 registry-val encoding-val fontname loose-fontname)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
244 (if (string-match "-" registry)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
245 ;; REGISTRY contains `CHARSET_ENCODING' field.
17195
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
246 (setq registry-val (substring registry 0 (match-beginning 0))
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
247 encoding-val (substring registry (match-end 0)))
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
248 (setq registry-val (concat registry "*")
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
249 encoding-val "*"))
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
250 (aset xlfd-fields xlfd-regexp-registry-subnum registry-val)
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
251 (aset xlfd-fields xlfd-regexp-encoding-subnum encoding-val)
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
252 (aset loose-xlfd-fields xlfd-regexp-registry-subnum registry-val)
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
253 (aset loose-xlfd-fields xlfd-regexp-encoding-subnum encoding-val)
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
254 (setq fontname (x-compose-font-name xlfd-fields t))
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
255 (setq fontlist (cons (cons charset fontname) fontlist))
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
256 (or (assoc fontname alternative-fontname-alist)
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
257 (setq alternative-fontname-alist
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
258 (cons (list
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
259 fontname
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
260 (x-compose-font-name loose-xlfd-fields t)
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
261 (concat "*-" registry-val "-" encoding-val))
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
262 alternative-fontname-alist)))
9c0c6ae6dcad (x-complement-fontset-spec): Setup
Kenichi Handa <handa@m17n.org>
parents: 17177
diff changeset
263 )))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
264 (setq charsets (cdr charsets))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
265 fontlist)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
266
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
267 ;; Return a list to be appended to `x-fixed-font-alist' when
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
268 ;; `mouse-set-font' is called.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
269 (defun generate-fontset-menu ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
270 (let ((fontsets global-fontset-alist)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
271 fontset-name
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
272 l)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
273 (while fontsets
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
274 (setq fontset-name (car (car fontsets)) fontsets (cdr fontsets))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
275 (if (string-match "fontset-\\([^-]+\\)" fontset-name)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
276 ;; This fontset has a nickname. Just show it.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
277 (let ((nickname (match-string 1 fontset-name)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
278 (setq l (cons (list (concat ".." nickname) fontset-name) l)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
279 (setq l (cons (list fontset-name fontset-name) l))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
280 (cons "Fontset" l)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
281
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
282 (defun fontset-plain-name (fontset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
283 "Return a plain and descriptive name of FONTSET."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
284 (let ((xlfd-fields (x-decompose-font-name fontset)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
285 (if xlfd-fields
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
286 (let ((weight (aref xlfd-fields xlfd-regexp-weight-subnum))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
287 (slant (aref xlfd-fields xlfd-regexp-slant-subnum))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
288 (swidth (aref xlfd-fields xlfd-regexp-swidth-subnum))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
289 (size (aref xlfd-fields xlfd-regexp-pixelsize-subnum))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
290 name)
17177
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
291 (if (> (string-to-int size) 0)
9e550b522bc0 (x-charset-registries): Change entry for Ethiopic.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
292 (setq name (format "%s " size))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
293 (setq name ""))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
294 (if (string-match "bold\\|demibold" weight)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
295 (setq name (concat name weight " ")))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
296 (cond ((string= slant "i")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
297 (setq name (concat name "italic ")))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
298 ((string= slant "o")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
299 (setq name (concat name "slant ")))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
300 ((string= slant "ri")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
301 (setq name (concat name "reverse italic ")))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
302 ((string= slant "ro")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
303 (setq name (concat name "reverse slant "))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
304 (if (= (length name) 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
305 ;; No descriptive fields found.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
306 fontset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
307 name))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
308 fontset)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
309
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
310 (defun create-fontset-from-fontset-spec (fontset-spec)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
311 "Create a fontset from fontset specification string FONTSET-SPEC.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
312 FONTSET-SPEC is a string of the format:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
313 FONTSET-NAME,CHARSET-NAME0:FONT-NAME0,CHARSET-NAME1:FONT-NAME1, ...
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
314 Any number of SPACE, TAB, and NEWLINE can be put before and after commas."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
315 (if (string-match "[^,]+" fontset-spec)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
316 (let* ((idx2 (match-end 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
317 (name (match-string 0 fontset-spec))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
318 fontlist charset xlfd-fields)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
319 (while (string-match "[, \t\n]*\\([^:]+\\):\\([^,]+\\)"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
320 fontset-spec idx2)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
321 (setq idx2 (match-end 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
322 (setq charset (intern (match-string 1 fontset-spec)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
323 (if (charsetp charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
324 (setq fontlist (cons (cons charset (match-string 2 fontset-spec))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
325 fontlist))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
326 (if (setq xlfd-fields (x-decompose-font-name name))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
327 ;; If NAME conforms to XLFD, complement FONTLIST for
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
328 ;; charsets not specified in FONTSET-SPEC.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
329 (setq fontlist
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
330 (x-complement-fontset-spec xlfd-fields fontlist)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
331 (new-fontset name fontlist))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
332
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
333
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
334 ;; Create default fontset from 16 dots fonts which are the most widely
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
335 ;; installed fonts.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
336 (defvar default-fontset-spec
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
337 "-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-default,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
338 chinese-gb2312:-*-medium-r-normal-*-16-*-gb2312*-*,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
339 korean-ksc5601:-*-medium-r-normal-*-16-*-ksc5601*-*,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
340 chinese-cns11643-1:-*-medium-r-normal-*-16-*-cns11643*-1,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
341 chinese-cns11643-2:-*-medium-r-normal-*-16-*-cns11643*-2,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
342 chinese-cns11643-3:-*-medium-r-normal-*-16-*-cns11643*-3,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
343 chinese-cns11643-4:-*-medium-r-normal-*-16-*-cns11643*-4,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
344 chinese-cns11643-5:-*-medium-r-normal-*-16-*-cns11643*-5,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
345 chinese-cns11643-6:-*-medium-r-normal-*-16-*-cns11643*-6,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
346 chinese-cns11643-7:-*-medium-r-normal-*-16-*-cns11643*-7"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
347 "String of fontset spec of a default fontset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
348 See the documentation of `create-fontset-from-fontset-spec' for the format.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
349
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
350 ;; Create fontsets from X resources of the name `fontset-N (class
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
351 ;; Fontset-N)' where N is integer 0, 1, ...
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
352 ;; The values of the resources the string of the same format as
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
353 ;; `default-fontset-spec'.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
354
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
355 (defun create-fontset-from-x-resource ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
356 (let ((idx 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
357 fontset-spec)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
358 (while (setq fontset-spec (x-get-resource (concat "fontset-" idx)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
359 (concat "Fontset-" idx)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
360 (create-fontset-from-fontset-spec fontset-spec)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
361 (setq idx (1+ idx)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
362
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
363 (defsubst fontset-list ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
364 "Returns a list of all defined fontset names."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
365 (mapcar 'car global-fontset-alist))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
366
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
367 ;;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
368 (provide 'fontset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
369
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
370 ;;; fontset.el ends here