Mercurial > emacs
annotate src/font.c @ 90472:138027c8c982
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 300-313)
- Update from CVS
- Update from CVS: lispref/display.texi (Forcing Redisplay): Fix typo.
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 105-106)
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-74
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sat, 17 Jun 2006 20:57:37 +0000 |
parents | 5424215feef6 |
children | 017a6aec5d77 |
rev | line source |
---|---|
90400 | 1 /* font.c -- "Font" primitives. |
2 Copyright (C) 2006 Free Software Foundation, Inc. | |
3 Copyright (C) 2006 | |
4 National Institute of Advanced Industrial Science and Technology (AIST) | |
5 Registration Number H13PRO009 | |
6 | |
7 This file is part of GNU Emacs. | |
8 | |
9 GNU Emacs is free software; you can redistribute it and/or modify | |
10 it under the terms of the GNU General Public License as published by | |
11 the Free Software Foundation; either version 2, or (at your option) | |
12 any later version. | |
13 | |
14 GNU Emacs is distributed in the hope that it will be useful, | |
15 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 GNU General Public License for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
20 along with GNU Emacs; see the file COPYING. If not, write to | |
21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
22 Boston, MA 02110-1301, USA. */ | |
23 | |
24 #include <config.h> | |
25 #include <stdio.h> | |
26 #include <stdlib.h> | |
27 #include <ctype.h> | |
28 | |
29 #include "lisp.h" | |
30 #include "buffer.h" | |
31 #include "frame.h" | |
32 #include "dispextern.h" | |
33 #include "charset.h" | |
34 #include "character.h" | |
35 #include "composite.h" | |
36 #include "fontset.h" | |
37 #include "font.h" | |
38 | |
39 #define FONT_DEBUG | |
40 | |
41 #ifdef FONT_DEBUG | |
42 #undef xassert | |
43 #define xassert(X) do {if (!(X)) abort ();} while (0) | |
44 #else | |
45 #define xassert(X) (void) 0 | |
46 #endif | |
47 | |
48 int enable_font_backend; | |
49 | |
50 Lisp_Object Qfontp; | |
51 | |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
52 /* Important character set symbols. */ |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
53 Lisp_Object Qiso8859_1, Qiso10646_1, Qunicode_bmp; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
54 |
90400 | 55 /* Like CHECK_FONT_SPEC but also validate properties of the font-spec, |
56 and set X to the validated result. */ | |
57 | |
58 #define CHECK_VALIDATE_FONT_SPEC(x) \ | |
59 do { \ | |
60 if (! FONT_SPEC_P (x)) x = wrong_type_argument (Qfont, x); \ | |
61 x = font_prop_validate (x); \ | |
62 } while (0) | |
63 | |
64 /* Number of pt per inch (from the TeXbook). */ | |
65 #define PT_PER_INCH 72.27 | |
66 | |
67 /* Return a pixel size corresponding to POINT size (1/10 pt unit) on | |
68 resolution RESY. */ | |
69 #define POINT_TO_PIXEL(POINT, RESY) ((POINT) * (RESY) / PT_PER_INCH / 10 + 0.5) | |
70 | |
71 #define PIXEL_TO_POINT(PIXEL, RESY) ((PIXEL) * PT_PER_INCH * 10 / (RESY) + 0.5) | |
72 | |
73 /* Special string of zero length. It is used to specify a NULL name | |
74 in a font properties (e.g. adstyle). We don't use the symbol of | |
75 NULL name because it's confusing (Lisp printer prints nothing for | |
76 it). */ | |
77 Lisp_Object null_string; | |
78 | |
79 /* Special vector of zero length. This is repeatedly used by (struct | |
80 font_driver *)->list when a specified font is not found. */ | |
81 Lisp_Object null_vector; | |
82 | |
83 /* Vector of 3 elements. Each element is an alist for one of font | |
84 style properties (weight, slant, width). The alist contains a | |
85 mapping between symbolic property values (e.g. `medium' for weight) | |
86 and numeric property values (e.g. 100). So, it looks like this: | |
87 [((thin . 0) ... (heavy . 210)) | |
88 ((ro . 0) ... (ot . 210)) | |
89 ((ultracondensed . 50) ... (wide . 200))] */ | |
90 static Lisp_Object font_style_table; | |
91 | |
92 /* Alist of font family vs the corresponding aliases. | |
93 Each element has this form: | |
94 (FAMILY ALIAS1 ALIAS2 ...) */ | |
95 | |
96 static Lisp_Object font_family_alist; | |
97 | |
98 /* Symbols representing keys of normal font properties. */ | |
99 extern Lisp_Object QCtype, QCfamily, QCweight, QCslant, QCwidth, QCsize, QCname; | |
100 Lisp_Object QCfoundry, QCadstyle, QCregistry, QCextra; | |
101 /* Symbols representing keys of font extra info. */ | |
102 Lisp_Object QCotf, QClanguage, QCscript; | |
103 | |
104 /* List of all font drivers. All font-backends (XXXfont.c) call | |
105 add_font_driver in syms_of_XXXfont to register the font-driver | |
106 here. */ | |
107 static struct font_driver_list *font_driver_list; | |
108 | |
109 static Lisp_Object prop_name_to_numeric P_ ((enum font_property_index, | |
110 Lisp_Object)); | |
111 static Lisp_Object prop_numeric_to_name P_ ((enum font_property_index, int)); | |
112 static Lisp_Object font_open_entity P_ ((FRAME_PTR, Lisp_Object, int)); | |
113 | |
114 /* Number of registered font drivers. */ | |
115 static int num_font_drivers; | |
116 | |
117 /* Return a numeric value corresponding to PROP's NAME (symbol). If | |
118 NAME is not registered in font_style_table, return Qnil. PROP must | |
119 be one of FONT_{WEIGHT|SLANT|SWIDTH}_INDEX. */ | |
120 | |
121 static Lisp_Object | |
122 prop_name_to_numeric (prop, name) | |
123 enum font_property_index prop; | |
124 Lisp_Object name; | |
125 { | |
126 int table_index = prop - FONT_WEIGHT_INDEX; | |
127 Lisp_Object val; | |
128 | |
129 val = assq_no_quit (name, AREF (font_style_table, table_index)); | |
130 return (NILP (val) ? Qnil : XCDR (val)); | |
131 } | |
132 | |
133 | |
134 /* Return a name (symbol) corresponding to PROP's NUMERIC value. If | |
135 no name is registered for NUMERIC in font_style_table, return a | |
136 symbol of integer name (e.g. `123'). PROP must be one of | |
137 FONT_{WEIGHT|SLANT|SWIDTH}_INDEX. */ | |
138 | |
139 static Lisp_Object | |
140 prop_numeric_to_name (prop, numeric) | |
141 enum font_property_index prop; | |
142 int numeric; | |
143 { | |
144 int table_index = prop - FONT_WEIGHT_INDEX; | |
145 Lisp_Object table = AREF (font_style_table, table_index); | |
146 char buf[10]; | |
147 | |
148 while (! NILP (table)) | |
149 { | |
150 if (XINT (XCDR (XCAR (table))) >= numeric) | |
151 { | |
152 if (XINT (XCDR (XCAR (table))) == numeric) | |
153 return XCAR (XCAR (table)); | |
154 else | |
155 break; | |
156 } | |
157 table = XCDR (table); | |
158 } | |
159 sprintf (buf, "%d", numeric); | |
160 return intern (buf); | |
161 } | |
162 | |
163 | |
164 /* Return a symbol whose name is STR (length LEN). If STR contains | |
165 uppercase letters, downcase them in advance. */ | |
166 | |
167 Lisp_Object | |
168 intern_downcase (str, len) | |
169 char *str; | |
170 int len; | |
171 { | |
172 char *buf; | |
173 int i; | |
174 | |
175 for (i = 0; i < len; i++) | |
176 if (isupper (str[i])) | |
177 break; | |
178 if (i == len) | |
179 return Fintern (make_unibyte_string (str, len), Qnil); | |
180 buf = alloca (len); | |
181 if (! buf) | |
182 return Fintern (null_string, Qnil); | |
183 bcopy (str, buf, len); | |
184 for (; i < len; i++) | |
185 if (isascii (buf[i])) | |
186 buf[i] = tolower (buf[i]); | |
187 return Fintern (make_unibyte_string (buf, len), Qnil); | |
188 } | |
189 | |
190 extern Lisp_Object Vface_alternative_font_family_alist; | |
191 | |
192 static void | |
193 build_font_family_alist () | |
194 { | |
195 Lisp_Object alist = Vface_alternative_font_family_alist; | |
196 | |
197 for (; CONSP (alist); alist = XCDR (alist)) | |
198 { | |
199 Lisp_Object tail, elt; | |
200 | |
201 for (tail = XCAR (alist), elt = Qnil ; CONSP (tail); tail = XCDR (tail)) | |
202 elt = nconc2 (elt, Fcons (Fintern (XCAR (tail), Qnil), Qnil)); | |
203 font_family_alist = Fcons (elt, font_family_alist); | |
204 } | |
205 } | |
206 | |
207 | |
208 /* Font property validater. */ | |
209 | |
210 static Lisp_Object | |
211 font_prop_validate_type (prop, val) | |
212 enum font_property_index prop; | |
213 Lisp_Object val; | |
214 { | |
215 return (SYMBOLP (val) ? val : Qerror); | |
216 } | |
217 | |
218 static Lisp_Object | |
219 font_prop_validate_symbol (prop, val) | |
220 enum font_property_index prop; | |
221 Lisp_Object val; | |
222 { | |
223 if (STRINGP (val)) | |
224 val = (SCHARS (val) == 0 ? null_string | |
225 : intern_downcase ((char *) SDATA (val), SBYTES (val))); | |
226 else if (SYMBOLP (val)) | |
227 { | |
228 if (SCHARS (SYMBOL_NAME (val)) == 0) | |
229 val = null_string; | |
230 } | |
231 else | |
232 val = Qerror; | |
233 return val; | |
234 } | |
235 | |
236 static Lisp_Object | |
237 font_prop_validate_style (prop, val) | |
238 enum font_property_index prop; | |
239 Lisp_Object val; | |
240 { | |
241 if (! INTEGERP (val)) | |
242 { | |
243 if (STRINGP (val)) | |
244 val = intern_downcase ((char *) SDATA (val), SBYTES (val)); | |
245 if (! SYMBOLP (val)) | |
246 val = Qerror; | |
247 else | |
248 { | |
249 val = prop_name_to_numeric (prop, val); | |
250 if (NILP (val)) | |
251 val = Qerror; | |
252 } | |
253 } | |
254 return val; | |
255 } | |
256 | |
257 static Lisp_Object | |
258 font_prop_validate_size (prop, val) | |
259 enum font_property_index prop; | |
260 Lisp_Object val; | |
261 { | |
262 return (NATNUMP (val) || (FLOATP (val) && XFLOAT_DATA (val) >= 0) | |
263 ? val : Qerror); | |
264 } | |
265 | |
266 static Lisp_Object | |
267 font_prop_validate_extra (prop, val) | |
268 enum font_property_index prop; | |
269 Lisp_Object val; | |
270 { | |
271 Lisp_Object tail; | |
272 | |
273 for (tail = val; CONSP (tail); tail = XCDR (tail)) | |
274 { | |
275 Lisp_Object key = Fcar (XCAR (tail)), this_val = Fcdr (XCAR (tail)); | |
276 | |
277 if (NILP (this_val)) | |
278 return Qnil; | |
279 if (EQ (key, QClanguage)) | |
280 if (! SYMBOLP (this_val)) | |
281 { | |
282 for (; CONSP (this_val); this_val = XCDR (this_val)) | |
283 if (! SYMBOLP (XCAR (this_val))) | |
284 return Qerror; | |
285 if (! NILP (this_val)) | |
286 return Qerror; | |
287 } | |
288 if (EQ (key, QCotf)) | |
289 if (! STRINGP (this_val)) | |
290 return Qerror; | |
291 } | |
292 return (NILP (tail) ? val : Qerror); | |
293 } | |
294 | |
295 | |
296 struct | |
297 { | |
298 Lisp_Object *key; | |
299 Lisp_Object (*validater) P_ ((enum font_property_index prop, | |
300 Lisp_Object val)); | |
301 } font_property_table[FONT_SPEC_MAX] = | |
302 { { &QCtype, font_prop_validate_type }, | |
303 { &QCfoundry, font_prop_validate_symbol }, | |
304 { &QCfamily, font_prop_validate_symbol }, | |
305 { &QCadstyle, font_prop_validate_symbol }, | |
306 { &QCregistry, font_prop_validate_symbol }, | |
307 { &QCweight, font_prop_validate_style }, | |
308 { &QCslant, font_prop_validate_style }, | |
309 { &QCwidth, font_prop_validate_style }, | |
310 { &QCsize, font_prop_validate_size }, | |
311 { &QCextra, font_prop_validate_extra } | |
312 }; | |
313 | |
314 static enum font_property_index | |
315 check_font_prop_name (key) | |
316 Lisp_Object key; | |
317 { | |
318 enum font_property_index i; | |
319 | |
320 for (i = FONT_TYPE_INDEX; i < FONT_SPEC_MAX; i++) | |
321 if (EQ (key, *font_property_table[i].key)) | |
322 break; | |
323 return i; | |
324 } | |
325 | |
326 static Lisp_Object | |
327 font_prop_validate (spec) | |
328 Lisp_Object spec; | |
329 { | |
330 enum font_property_index i; | |
331 Lisp_Object val; | |
332 | |
333 for (i = FONT_TYPE_INDEX; i <= FONT_EXTRA_INDEX; i++) | |
334 { | |
335 if (! NILP (AREF (spec, i))) | |
336 { | |
337 val = (font_property_table[i].validater) (i, AREF (spec, i)); | |
338 if (EQ (val, Qerror)) | |
339 Fsignal (Qerror, list3 (build_string ("invalid font property"), | |
340 *font_property_table[i].key, | |
341 AREF (spec, i))); | |
342 ASET (spec, i, val); | |
343 } | |
344 } | |
345 return spec; | |
346 } | |
347 | |
348 | |
349 /* Font name parser and unparser */ | |
350 | |
351 /* An enumerator for each field of an XLFD font name. */ | |
352 | |
353 enum xlfd_field_index | |
354 { | |
355 XLFD_FOUNDRY_INDEX, | |
356 XLFD_FAMILY_INDEX, | |
357 XLFD_WEIGHT_INDEX, | |
358 XLFD_SLANT_INDEX, | |
359 XLFD_SWIDTH_INDEX, | |
360 XLFD_ADSTYLE_INDEX, | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
361 XLFD_PIXEL_INDEX, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
362 XLFD_POINT_INDEX, |
90400 | 363 XLFD_RESX_INDEX, |
364 XLFD_RESY_INDEX, | |
365 XLFD_SPACING_INDEX, | |
366 XLFD_AVGWIDTH_INDEX, | |
367 XLFD_REGISTRY_INDEX, | |
368 XLFD_ENCODING_INDEX, | |
369 XLFD_LAST_INDEX | |
370 }; | |
371 | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
372 enum xlfd_field_mask |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
373 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
374 XLFD_FOUNDRY_MASK = 0x0001, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
375 XLFD_FAMILY_MASK = 0x0002, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
376 XLFD_WEIGHT_MASK = 0x0004, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
377 XLFD_SLANT_MASK = 0x0008, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
378 XLFD_SWIDTH_MASK = 0x0010, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
379 XLFD_ADSTYLE_MASK = 0x0020, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
380 XLFD_PIXEL_MASK = 0x0040, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
381 XLFD_POINT_MASK = 0x0080, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
382 XLFD_RESX_MASK = 0x0100, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
383 XLFD_RESY_MASK = 0x0200, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
384 XLFD_SPACING_MASK = 0x0400, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
385 XLFD_AVGWIDTH_MASK = 0x0800, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
386 XLFD_REGISTRY_MASK = 0x1000, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
387 XLFD_ENCODING_MASK = 0x2000 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
388 }; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
389 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
390 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
391 /* Return a Lispy value for string at STR and bytes LEN. |
90400 | 392 If LEN == 0, return a null string. |
393 If the string is "*", return Qnil. | |
394 It is assured that LEN < 256. */ | |
395 | |
396 static Lisp_Object | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
397 intern_font_field (str, len) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
398 char *str; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
399 int len; |
90400 | 400 { |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
401 int i; |
90400 | 402 |
403 if (len == 0) | |
404 return null_string; | |
405 if (*str == '*' && len == 1) | |
406 return Qnil; | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
407 if (isdigit (*str)) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
408 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
409 for (i = 1; i < len; i++) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
410 if (! isdigit (str[i])) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
411 break; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
412 if (i == len) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
413 return make_number (atoi (str)); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
414 } |
90400 | 415 return intern_downcase (str, len); |
416 } | |
417 | |
418 /* Parse P pointing the pixel/point size field of the form | |
419 `[A B C D]' which specifies a transformation matrix: | |
420 | |
421 A B 0 | |
422 C D 0 | |
423 0 0 1 | |
424 | |
425 by which all glyphs of the font are transformed. The spec says | |
426 that scalar value N for the pixel/point size is equivalent to: | |
427 A = N * resx/resy, B = C = 0, D = N. | |
428 | |
429 Return the scalar value N if the form is valid. Otherwise return | |
430 -1. */ | |
431 | |
432 static int | |
433 parse_matrix (p) | |
434 char *p; | |
435 { | |
436 double matrix[4]; | |
437 char *end; | |
438 int i; | |
439 | |
440 for (i = 0, p++; i < 4 && *p && *p != ']'; i++) | |
441 { | |
442 if (*p == '~') | |
443 matrix[i] = - strtod (p + 1, &end); | |
444 else | |
445 matrix[i] = strtod (p, &end); | |
446 p = end; | |
447 } | |
448 return (i == 4 ? (int) matrix[3] : -1); | |
449 } | |
450 | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
451 /* Expand a wildcard field in FIELD (the first N fields are filled) to |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
452 multiple fields to fill in all 14 XLFD fields while restring a |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
453 field position by its contents. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
454 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
455 int |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
456 font_expand_wildcards (field, n) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
457 Lisp_Object field[XLFD_LAST_INDEX]; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
458 int n; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
459 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
460 /* Copy of FIELD. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
461 Lisp_Object tmp[XLFD_LAST_INDEX]; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
462 /* Array of information about where this element can go. Nth |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
463 element is for Nth element of FIELD. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
464 struct { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
465 /* Minimum possible field. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
466 int from; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
467 /* Maxinum possible field. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
468 int to; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
469 /* Bit mask of possible field. Nth bit corresponds to Nth field. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
470 int mask; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
471 } range[XLFD_LAST_INDEX]; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
472 int i, j; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
473 unsigned range_mask; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
474 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
475 #define XLFD_SYMBOL_MASK (XLFD_FOUNDRY_MASK | XLFD_FAMILY_MASK \ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
476 | XLFD_ADSTYLE_MASK | XLFD_REGISTRY_MASK) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
477 #define XLFD_NULL_MASK (XLFD_FOUNDRY_MASK | XLFD_ADSTYLE_MASK) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
478 #define XLFD_LARGENUM_MASK (XLFD_POINT_MASK | XLFD_RESX_MASK | XLFD_RESY_MASK \ |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
479 | XLFD_AVGWIDTH_MASK) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
480 #define XLFD_REGENC_MASK (XLFD_REGISTRY_MASK | XLFD_ENCODING_MASK) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
481 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
482 /* Initialize RANGE_MASK for FIELD[0] which can be 0th to (14 - N)th |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
483 field. The value is shifted to left one bit by one in the |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
484 following loop. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
485 for (i = 0, range_mask = 0; i <= 14 - n; i++) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
486 range_mask = (range_mask << 1) | 1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
487 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
488 for (i = 0; i < n; i++, range_mask <<= 1) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
489 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
490 /* The triplet RANGE_FROM, RANGE_TO, and RANGE_MASK is a |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
491 position-based retriction for FIELD[I]. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
492 int range_from = i, range_to = 14 - n + i; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
493 Lisp_Object val = field[i]; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
494 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
495 tmp[i] = val; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
496 if (NILP (val)) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
497 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
498 /* Wildcard. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
499 range[i].from = range_from; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
500 range[i].to = range_to; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
501 range[i].mask = range_mask; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
502 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
503 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
504 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
505 /* The triplet FROM, TO, and MASK is a value-based |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
506 retriction for FIELD[I]. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
507 int from, to; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
508 unsigned mask; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
509 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
510 if (INTEGERP (val)) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
511 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
512 int numeric = XINT (val); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
513 |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
514 if (i + 1 == n) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
515 from = to = XLFD_ENCODING_INDEX, |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
516 mask = XLFD_ENCODING_MASK; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
517 else if (numeric <= 48) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
518 from = to = XLFD_PIXEL_INDEX, |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
519 mask = XLFD_PIXEL_MASK; |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
520 else |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
521 from = XLFD_POINT_INDEX, to = XLFD_AVGWIDTH_MASK, |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
522 mask = XLFD_LARGENUM_MASK; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
523 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
524 else if (EQ (val, null_string)) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
525 from = XLFD_FOUNDRY_INDEX, to = XLFD_ADSTYLE_INDEX, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
526 mask = XLFD_NULL_MASK; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
527 else if (i == 0) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
528 from = to = XLFD_FOUNDRY_INDEX, mask = XLFD_FOUNDRY_MASK; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
529 else if (i + 1 == n) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
530 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
531 Lisp_Object name = SYMBOL_NAME (val); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
532 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
533 if (SDATA (name)[SBYTES (name) - 1] == '*') |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
534 from = XLFD_REGISTRY_INDEX, to = XLFD_ENCODING_INDEX, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
535 mask = XLFD_REGENC_MASK; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
536 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
537 from = to = XLFD_ENCODING_INDEX, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
538 mask = XLFD_ENCODING_MASK; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
539 } |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
540 else if (range_from <= XLFD_WEIGHT_INDEX |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
541 && range_to >= XLFD_WEIGHT_INDEX |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
542 && !NILP (prop_name_to_numeric (FONT_WEIGHT_INDEX, val))) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
543 from = to = XLFD_WEIGHT_INDEX, mask = XLFD_WEIGHT_MASK; |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
544 else if (range_from <= XLFD_SLANT_INDEX |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
545 && range_to >= XLFD_SLANT_INDEX |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
546 && !NILP (prop_name_to_numeric (FONT_SLANT_INDEX, val))) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
547 from = to = XLFD_SLANT_INDEX, mask = XLFD_SLANT_MASK; |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
548 else if (range_from <= XLFD_SWIDTH_INDEX |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
549 && range_to >= XLFD_SWIDTH_INDEX |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
550 && !NILP (prop_name_to_numeric (FONT_WIDTH_INDEX, val))) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
551 from = to = XLFD_SWIDTH_INDEX, mask = XLFD_SWIDTH_MASK; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
552 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
553 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
554 Lisp_Object name = SYMBOL_NAME (val); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
555 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
556 if (SBYTES (name) == 1 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
557 && (SDATA (name)[0] == 'c' |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
558 || SDATA (name)[0] == 'm' |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
559 || SDATA (name)[0] == 'p')) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
560 from = to = XLFD_SPACING_INDEX, mask = XLFD_SPACING_MASK; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
561 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
562 from = XLFD_FOUNDRY_INDEX, to = XLFD_ENCODING_INDEX, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
563 mask = XLFD_SYMBOL_MASK; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
564 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
565 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
566 /* Merge position-based and value-based restrictions. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
567 mask &= range_mask; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
568 while (from < range_from) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
569 mask &= ~(1 << from++); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
570 while (from < 14 && ! (mask & (1 << from))) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
571 from++; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
572 while (to > range_to) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
573 mask &= ~(1 << to--); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
574 while (to >= 0 && ! (mask & (1 << to))) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
575 to--; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
576 if (from > to) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
577 return -1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
578 range[i].from = from; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
579 range[i].to = to; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
580 range[i].mask = mask; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
581 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
582 if (from > range_from || to < range_to) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
583 /* The range is narrowed by value-based restrictions. |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
584 Reflect it to the previous fields. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
585 for (j = i - 1, from--, to--; j >= 0; j--, from--, to--) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
586 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
587 /* Check FROM for non-wildcard field. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
588 if (! NILP (tmp[j]) && range[j].from < from) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
589 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
590 while (range[j].from < from) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
591 range[j].mask &= ~(1 << range[j].from++); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
592 while (from < 14 && ! (range[j].mask & (1 << from))) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
593 from++; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
594 range[j].from = from; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
595 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
596 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
597 from = range[j].from; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
598 if (range[j].to > to) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
599 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
600 while (range[j].to > to) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
601 range[j].mask &= ~(1 << range[j].to--); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
602 while (to >= 0 && ! (range[j].mask & (1 << to))) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
603 to--; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
604 range[j].to = to; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
605 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
606 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
607 to = range[j].to; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
608 if (from > to) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
609 return -1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
610 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
611 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
612 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
613 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
614 /* Decide all fileds from restrictions in RANGE. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
615 for (i = j = 0; i < n ; i++) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
616 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
617 if (j < range[i].from) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
618 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
619 if (i == 0 || ! NILP (tmp[i - 1])) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
620 /* None of TMP[X] corresponds to Jth field. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
621 return -1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
622 for (; j < range[i].from; j++) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
623 field[j] = Qnil; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
624 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
625 field[j++] = tmp[i]; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
626 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
627 if (! NILP (tmp[n - 1]) && j < XLFD_REGISTRY_INDEX) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
628 return -1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
629 for (; j < XLFD_LAST_INDEX; j++) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
630 field[j] = Qnil; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
631 if (INTEGERP (field[XLFD_ENCODING_INDEX])) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
632 field[XLFD_ENCODING_INDEX] |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
633 = Fintern (Fnumber_to_string (field[XLFD_ENCODING_INDEX]), Qnil); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
634 return 0; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
635 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
636 |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
637 /* Parse NAME (null terminated) as XLFD and store information in FONT |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
638 (font-spec or font-entity). See font_parse_name for more |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
639 detail. */ |
90400 | 640 |
641 int | |
642 font_parse_xlfd (name, font, merge) | |
643 char *name; | |
644 Lisp_Object font; | |
645 int merge; | |
646 { | |
647 int len = strlen (name); | |
648 int i, j; | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
649 int pixel_size, resy, avgwidth; |
90400 | 650 double point_size; |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
651 Lisp_Object f[XLFD_LAST_INDEX]; |
90400 | 652 Lisp_Object val; |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
653 char *p; |
90400 | 654 |
655 if (len > 255) | |
656 /* Maximum XLFD name length is 255. */ | |
657 return -1; | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
658 i = (name[0] == '*' && name[1] == '-'); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
659 for (p = name + 1; *p; p++) |
90400 | 660 { |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
661 if (*p == '-') |
90400 | 662 { |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
663 i++; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
664 if (i == XLFD_ENCODING_INDEX) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
665 break; |
90400 | 666 } |
667 } | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
668 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
669 pixel_size = resy = avgwidth = -1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
670 point_size = -1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
671 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
672 if (i == XLFD_ENCODING_INDEX) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
673 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
674 /* Fully specified XLFD. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
675 if (name[0] == '-') |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
676 name++; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
677 for (i = 0, p = name; ; p++) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
678 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
679 if (*p == '-') |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
680 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
681 if (i < XLFD_PIXEL_INDEX) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
682 f[i++] = intern_font_field (name, p - name); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
683 else if (i == XLFD_PIXEL_INDEX) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
684 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
685 if (isdigit (*name)) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
686 pixel_size = atoi (name); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
687 else if (*name == '[') |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
688 pixel_size = parse_matrix (name); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
689 i++; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
690 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
691 else if (i == XLFD_POINT_INDEX) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
692 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
693 if (pixel_size < 0) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
694 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
695 if (isdigit (*name)) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
696 point_size = atoi (name); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
697 else if (*name == '[') |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
698 point_size = parse_matrix (name); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
699 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
700 i++; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
701 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
702 else if (i == XLFD_RESX_INDEX) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
703 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
704 /* Skip this field. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
705 f[i++] = Qnil; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
706 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
707 else if (i == XLFD_RESY_INDEX) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
708 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
709 /* Stuff RESY, SPACING, and AVGWIDTH. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
710 if (pixel_size < 0 && isdigit (*name)) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
711 resy = atoi (name); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
712 for (p++; *p != '-'; p++); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
713 if (isdigit (p[1])) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
714 avgwidth = atoi (p + 1); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
715 else if (p[1] == '~' && isdigit (p[2])) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
716 avgwidth = atoi (p + 2); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
717 for (p++; *p != '-'; p++); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
718 if (FONT_ENTITY_P (font)) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
719 f[i] = intern_font_field (name, p - name); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
720 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
721 f[i] = Qnil; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
722 i = XLFD_REGISTRY_INDEX; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
723 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
724 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
725 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
726 /* Stuff REGISTRY and ENCODING. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
727 for (p++; *p; p++); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
728 f[i++] = intern_font_field (name, p - name); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
729 break; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
730 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
731 name = p + 1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
732 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
733 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
734 xassert (i == XLFD_ENCODING_INDEX); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
735 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
736 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
737 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
738 int wild_card_found = 0; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
739 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
740 if (name[0] == '-') |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
741 name++; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
742 for (i = 0, p = name; ; p++) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
743 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
744 if (*p == '-' || ! *p) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
745 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
746 if (*name == '*') |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
747 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
748 if (name + 1 != p) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
749 return -1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
750 f[i++] = Qnil; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
751 wild_card_found = 1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
752 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
753 else if (isdigit (*name)) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
754 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
755 f[i++] = make_number (atoi (name)); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
756 /* Check if all chars in this field is number. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
757 name++; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
758 while (isdigit (*name)) name++; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
759 if (name != p) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
760 return -1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
761 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
762 else if (p == name) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
763 f[i++] = null_string; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
764 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
765 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
766 f[i++] = intern_downcase (name, p - name); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
767 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
768 if (! *p) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
769 break; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
770 name = p + 1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
771 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
772 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
773 if (! wild_card_found) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
774 return -1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
775 if (font_expand_wildcards (f, i) < 0) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
776 return -1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
777 if (! NILP (f[XLFD_PIXEL_INDEX])) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
778 pixel_size = XINT (f[XLFD_PIXEL_INDEX]); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
779 if (! NILP (f[XLFD_POINT_INDEX])) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
780 point_size = XINT (f[XLFD_POINT_INDEX]); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
781 if (! NILP (f[XLFD_RESY_INDEX])) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
782 resy = XINT (f[XLFD_RESY_INDEX]); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
783 if (! NILP (f[XLFD_AVGWIDTH_INDEX])) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
784 avgwidth = XINT (f[XLFD_AVGWIDTH_INDEX]); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
785 if (NILP (f[XLFD_REGISTRY_INDEX])) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
786 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
787 if (! NILP (f[XLFD_ENCODING_INDEX])) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
788 f[XLFD_REGISTRY_INDEX] |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
789 = Fintern (concat2 (build_string ("*-"), |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
790 SYMBOL_NAME (f[XLFD_ENCODING_INDEX])), Qnil); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
791 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
792 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
793 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
794 if (! NILP (f[XLFD_ENCODING_INDEX])) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
795 f[XLFD_REGISTRY_INDEX] |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
796 = Fintern (concat2 (SYMBOL_NAME (f[XLFD_REGISTRY_INDEX]), |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
797 SYMBOL_NAME (f[XLFD_ENCODING_INDEX])), Qnil); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
798 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
799 } |
90400 | 800 |
801 if (! merge || NILP (AREF (font, FONT_FOUNDRY_INDEX))) | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
802 ASET (font, FONT_FOUNDRY_INDEX, f[XLFD_FOUNDRY_INDEX]); |
90400 | 803 if (! merge || NILP (AREF (font, FONT_FAMILY_INDEX))) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
804 ASET (font, FONT_FAMILY_INDEX, f[XLFD_FAMILY_INDEX]); |
90400 | 805 if (! merge || NILP (AREF (font, FONT_ADSTYLE_INDEX))) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
806 ASET (font, FONT_ADSTYLE_INDEX, f[XLFD_ADSTYLE_INDEX]); |
90400 | 807 if (! merge || NILP (AREF (font, FONT_REGISTRY_INDEX))) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
808 ASET (font, FONT_REGISTRY_INDEX, f[XLFD_REGISTRY_INDEX]); |
90400 | 809 |
810 for (i = FONT_WEIGHT_INDEX, j = XLFD_WEIGHT_INDEX; | |
811 j <= XLFD_SWIDTH_INDEX; i++, j++) | |
812 if (! merge || NILP (AREF (font, i))) | |
813 { | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
814 if (! INTEGERP (f[j])) |
90400 | 815 { |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
816 val = prop_name_to_numeric (i, f[j]); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
817 if (INTEGERP (val)) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
818 f[j] = val; |
90400 | 819 } |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
820 ASET (font, i, f[j]); |
90400 | 821 } |
822 | |
823 if (pixel_size < 0 && FONT_ENTITY_P (font)) | |
824 return -1; | |
825 | |
826 if (! merge || NILP (AREF (font, FONT_SIZE_INDEX))) | |
827 { | |
828 if (pixel_size >= 0) | |
829 ASET (font, FONT_SIZE_INDEX, make_number (pixel_size)); | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
830 else if (point_size >= 0) |
90400 | 831 { |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
832 if (resy > 0) |
90400 | 833 { |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
834 pixel_size = POINT_TO_PIXEL (point_size, resy); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
835 ASET (font, FONT_SIZE_INDEX, make_number (pixel_size)); |
90400 | 836 } |
837 else | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
838 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
839 ASET (font, FONT_SIZE_INDEX, make_float (point_size / 10)); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
840 } |
90400 | 841 } |
842 } | |
843 | |
844 if (FONT_ENTITY_P (font) | |
845 && EQ (AREF (font, FONT_TYPE_INDEX), Qx)) | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
846 ASET (font, FONT_EXTRA_INDEX, f[XLFD_RESY_INDEX]); |
90400 | 847 |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
848 return (avgwidth > 0 ? 2 : resy == 0); |
90400 | 849 } |
850 | |
851 /* Store XLFD name of FONT (font-spec or font-entity) in NAME (NBYTES | |
852 length), and return the name length. If FONT_SIZE_INDEX of FONT is | |
853 0, use PIXEL_SIZE instead. */ | |
854 | |
855 int | |
856 font_unparse_xlfd (font, pixel_size, name, nbytes) | |
857 Lisp_Object font; | |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
858 int pixel_size; |
90400 | 859 char *name; |
860 int nbytes; | |
861 { | |
862 char *f[XLFD_REGISTRY_INDEX + 1], *pixel_point; | |
863 char work[256]; | |
864 Lisp_Object val; | |
865 int i, j, len = 0; | |
866 | |
867 xassert (FONTP (font)); | |
868 | |
869 for (i = FONT_FOUNDRY_INDEX, j = XLFD_FOUNDRY_INDEX; i <= FONT_REGISTRY_INDEX; | |
870 i++, j++) | |
871 { | |
872 if (i == FONT_ADSTYLE_INDEX) | |
873 j = XLFD_ADSTYLE_INDEX; | |
874 else if (i == FONT_REGISTRY_INDEX) | |
875 j = XLFD_REGISTRY_INDEX; | |
876 val = AREF (font, i); | |
877 if (NILP (val)) | |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
878 { |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
879 if (j == XLFD_REGISTRY_INDEX) |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
880 f[j] = "*-*", len += 4; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
881 else |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
882 f[j] = "*", len += 2; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
883 } |
90400 | 884 else |
885 { | |
886 if (SYMBOLP (val)) | |
887 val = SYMBOL_NAME (val); | |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
888 if (j == XLFD_REGISTRY_INDEX |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
889 && ! strchr ((char *) SDATA (val), '-')) |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
890 { |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
891 /* Change "jisx0208*" and "jisx0208" to "jisx0208*-*". */ |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
892 if (SDATA (val)[SBYTES (val) - 1] == '*') |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
893 { |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
894 f[j] = alloca (SBYTES (val) + 3); |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
895 sprintf (f[j], "%s-*", SDATA (val)); |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
896 len += SBYTES (val) + 3; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
897 } |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
898 else |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
899 { |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
900 f[j] = alloca (SBYTES (val) + 4); |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
901 sprintf (f[j], "%s*-*", SDATA (val)); |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
902 len += SBYTES (val) + 4; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
903 } |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
904 } |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
905 else |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
906 f[j] = (char *) SDATA (val), len += SBYTES (val) + 1; |
90400 | 907 } |
908 } | |
909 | |
910 for (i = FONT_WEIGHT_INDEX, j = XLFD_WEIGHT_INDEX; i <= FONT_WIDTH_INDEX; | |
911 i++, j++) | |
912 { | |
913 val = AREF (font, i); | |
914 if (NILP (val)) | |
915 f[j] = "*", len += 2; | |
916 else | |
917 { | |
918 if (INTEGERP (val)) | |
919 val = prop_numeric_to_name (i, XINT (val)); | |
920 if (SYMBOLP (val)) | |
921 val = SYMBOL_NAME (val); | |
922 xassert (STRINGP (val)); | |
923 f[j] = (char *) SDATA (val), len += SBYTES (val) + 1; | |
924 } | |
925 } | |
926 | |
927 val = AREF (font, FONT_SIZE_INDEX); | |
928 xassert (NUMBERP (val) || NILP (val)); | |
929 if (INTEGERP (val)) | |
930 { | |
931 i = XINT (val); | |
932 if (i > 0) | |
933 len += sprintf (work, "%d", i) + 1; | |
934 else /* i == 0 */ | |
935 len += sprintf (work, "%d-*", pixel_size) + 1; | |
936 pixel_point = work; | |
937 } | |
938 else if (FLOATP (val)) | |
939 { | |
940 i = XFLOAT_DATA (val) * 10; | |
941 len += sprintf (work, "*-%d", i) + 1; | |
942 pixel_point = work; | |
943 } | |
944 else | |
945 pixel_point = "*-*", len += 4; | |
946 | |
947 if (FONT_ENTITY_P (font) | |
948 && EQ (AREF (font, FONT_TYPE_INDEX), Qx)) | |
949 { | |
950 /* Setup names for RESY-SPACING-AVWIDTH. */ | |
951 val = AREF (font, FONT_EXTRA_INDEX); | |
952 if (SYMBOLP (val) && ! NILP (val)) | |
953 { | |
954 val = SYMBOL_NAME (val); | |
955 f[XLFD_RESY_INDEX] = (char *) SDATA (val), len += SBYTES (val) + 1; | |
956 } | |
957 else | |
958 f[XLFD_RESY_INDEX] = "*-*-*", len += 6; | |
959 } | |
960 else | |
961 f[XLFD_RESY_INDEX] = "*-*-*", len += 6; | |
962 | |
963 len += 3; /* for "-*" of resx, and terminating '\0'. */ | |
964 if (len >= nbytes) | |
965 return -1; | |
966 return sprintf (name, "-%s-%s-%s-%s-%s-%s-%s-*-%s-%s", | |
967 f[XLFD_FOUNDRY_INDEX], f[XLFD_FAMILY_INDEX], | |
968 f[XLFD_WEIGHT_INDEX], f[XLFD_SLANT_INDEX], | |
969 f[XLFD_SWIDTH_INDEX], | |
970 f[XLFD_ADSTYLE_INDEX], pixel_point, | |
971 f[XLFD_RESY_INDEX], f[XLFD_REGISTRY_INDEX]); | |
972 } | |
973 | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
974 /* Parse NAME (null terminated) as Fonconfig's name format and store |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
975 information in FONT (font-spec or font-entity). See |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
976 font_parse_name for more detail. */ |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
977 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
978 int |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
979 font_parse_fcname (name, font, merge) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
980 char *name; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
981 Lisp_Object font; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
982 int merge; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
983 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
984 char *p0, *p1; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
985 Lisp_Object family = Qnil; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
986 double point_size = 0; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
987 int pixel_size = 0; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
988 Lisp_Object extra = AREF (font, FONT_EXTRA_INDEX); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
989 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
990 /* It is assured that (name[0] && name[0] != '-'). */ |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
991 if (name[0] == ':') |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
992 p0 = name; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
993 else |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
994 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
995 for (p0 = name + 1; *p0 && (*p0 != '-' && *p0 != ':'); p0++); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
996 family = intern_font_field (name, p0 - name); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
997 if (*p0 == '-') |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
998 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
999 point_size = strtod (p0 + 1, &p1); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1000 if (*p1 && *p1 != ':') |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1001 return -1; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1002 p0 = p1; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1003 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1004 if (! merge || NILP (AREF (font, FONT_FAMILY_INDEX))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1005 ASET (font, FONT_FAMILY_INDEX, family); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1006 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1007 while (*p0) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1008 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1009 Lisp_Object key, val; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1010 enum font_property_index prop; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1011 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1012 p1 = index (name, '='); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1013 if (! p1) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1014 return -1; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1015 if (memcmp (p0 + 1, "pixelsize=", 10) == 0) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1016 prop = FONT_SIZE_INDEX; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1017 else |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1018 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1019 key = intern_font_field (p0, p1 - p0); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1020 prop = check_font_prop_name (key); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1021 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1022 p0 = p1 + 1; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1023 for (p1 = p0; *p1 && *p1 != ':'; p1++); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1024 if (prop == FONT_SIZE_INDEX) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1025 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1026 pixel_size = atoi (p0); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1027 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1028 else |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1029 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1030 val = intern_font_field (p0, p1 - p0); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1031 if (prop < FONT_EXTRA_INDEX) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1032 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1033 if (! merge || NILP (AREF (font, prop))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1034 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1035 val = font_property_table[prop].validater (prop, val); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1036 if (! EQ (val, Qerror)) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1037 ASET (font, prop, val); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1038 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1039 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1040 else |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1041 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1042 if (! merge || NILP (Fplist_get (extra, key))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1043 extra = Fplist_put (extra, key, val); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1044 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1045 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1046 p0 = p1; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1047 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1048 ASET (font, FONT_EXTRA_INDEX, extra); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1049 if (! merge || NILP (AREF (font, FONT_SIZE_INDEX))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1050 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1051 if (point_size > 0) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1052 ASET (font, FONT_SIZE_INDEX, make_float (point_size)); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1053 else if (pixel_size > 0) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1054 ASET (font, FONT_SIZE_INDEX, make_number (pixel_size)); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1055 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1056 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1057 return (NILP (AREF (font, FONT_SIZE_INDEX)) ? 1 : 2); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1058 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1059 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1060 /* Store fontconfig's font name of FONT (font-spec or font-entity) in |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1061 NAME (NBYTES length), and return the name length. If |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1062 FONT_SIZE_INDEX of FONT is 0, use PIXEL_SIZE instead. */ |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1063 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1064 int |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1065 font_unparse_fcname (font, pixel_size, name, nbytes) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1066 Lisp_Object font; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1067 int pixel_size; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1068 char *name; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1069 int nbytes; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1070 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1071 Lisp_Object val, size; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1072 int pt = 0; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1073 int i, j, len = 1; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1074 char *p; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1075 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1076 if (SYMBOLP (AREF (font, FONT_FAMILY_INDEX)) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1077 && ! NILP (AREF (font, FONT_FAMILY_INDEX))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1078 len += SBYTES (SYMBOL_NAME (AREF (font, FONT_FAMILY_INDEX))); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1079 size = AREF (font, FONT_SIZE_INDEX); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1080 if (INTEGERP (size)) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1081 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1082 if (XINT (size) > 0) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1083 pixel_size = XINT (size); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1084 if (pixel_size > 0) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1085 len += 21; /* for ":pixelsize=NUM" */ |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1086 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1087 else if (FLOATP (size)) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1088 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1089 pt = (int) XFLOAT_DATA (size); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1090 if (pt > 0) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1091 len += 11; /* for "-NUM" */ |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1092 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1093 if (SYMBOLP (AREF (font, FONT_FOUNDRY_INDEX)) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1094 && ! NILP (AREF (font, FONT_FOUNDRY_INDEX))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1095 /* ":foundry=NAME" */ |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1096 len += 9 + SBYTES (SYMBOL_NAME (AREF (font, FONT_FOUNDRY_INDEX))); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1097 if (INTEGERP (AREF (font, FONT_WEIGHT_INDEX))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1098 len += 18; /* ":weight=NUM" */ |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1099 if (INTEGERP (AREF (font, FONT_SLANT_INDEX))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1100 len += 17; /* ":slant=NUM" */ |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1101 if (INTEGERP (AREF (font, FONT_WIDTH_INDEX))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1102 len += 17; /* ":width=NUM" */ |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1103 if (len > nbytes) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1104 return -1; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1105 p = name; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1106 if (! NILP (AREF (font, FONT_FAMILY_INDEX))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1107 strcpy (p, SDATA (SYMBOL_NAME (AREF (font, FONT_FAMILY_INDEX)))), |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1108 p += SBYTES (SYMBOL_NAME (AREF (font, FONT_FAMILY_INDEX))); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1109 if (pt > 0) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1110 p += sprintf (p, "-%d", pt); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1111 else if (pixel_size > 0) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1112 p += sprintf (p, ":pixelsize=%d", pixel_size); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1113 if (! NILP (AREF (font, FONT_FOUNDRY_INDEX))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1114 p += sprintf (p, ":foundry=%s", SDATA (AREF (font, FONT_FOUNDRY_INDEX))); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1115 if (INTEGERP (AREF (font, FONT_WEIGHT_INDEX))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1116 p += sprintf (p, ":weight=%d", XINT (AREF (font, FONT_WEIGHT_INDEX))); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1117 if (INTEGERP (AREF (font, FONT_SLANT_INDEX))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1118 p += sprintf (p, ":slant=%d", XINT (AREF (font, FONT_SLANT_INDEX))); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1119 if (INTEGERP (AREF (font, FONT_WIDTH_INDEX))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1120 p += sprintf (p, ":width=%d", XINT (AREF (font, FONT_WIDTH_INDEX))); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1121 return (p - name); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1122 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1123 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1124 /* Parse NAME (null terminated) and store information in FONT |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1125 (font-spec or font-entity). If NAME is successfully parsed, return |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1126 2 (size is specified), 1 (size is not specified), or 0 (size is not |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1127 specified but resolution is specified). Otherwise return -1. |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1128 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1129 If NAME is XLFD and FONT is a font-entity, store |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1130 RESY-SPACING-AVWIDTH information as a symbol in FONT_EXTRA_INDEX. |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1131 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1132 If MERGE is nonzero, set a property of FONT only when it's nil. */ |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1133 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1134 static int |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1135 font_parse_name (name, font, merge) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1136 char *name; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1137 Lisp_Object font; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1138 int merge; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1139 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1140 if (name[0] == '-' || index (name, '*')) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1141 return font_parse_xlfd (name, font, merge); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1142 if (name[0]) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1143 return font_parse_fcname (name, font, merge); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1144 return -1; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1145 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1146 |
90400 | 1147 void |
1148 font_merge_old_spec (name, family, registry, spec) | |
1149 Lisp_Object name, family, registry, spec; | |
1150 { | |
1151 if (STRINGP (name)) | |
1152 { | |
1153 if (font_parse_xlfd ((char *) SDATA (name), spec, 1) < 0) | |
1154 { | |
1155 Lisp_Object extra = Fcons (Fcons (QCname, name), Qnil); | |
1156 | |
1157 ASET (spec, FONT_EXTRA_INDEX, extra); | |
1158 } | |
1159 } | |
1160 else | |
1161 { | |
1162 if (! NILP (family)) | |
1163 { | |
1164 int len; | |
1165 char *p0, *p1; | |
1166 | |
1167 xassert (STRINGP (family)); | |
1168 len = SBYTES (family); | |
1169 p0 = (char *) SDATA (family); | |
1170 p1 = index (p0, '-'); | |
1171 if (p1) | |
1172 { | |
1173 if (NILP (AREF (spec, FONT_FOUNDRY_INDEX))) | |
1174 ASET (spec, FONT_FOUNDRY_INDEX, | |
1175 intern_downcase (p0, p1 - p0)); | |
1176 if (NILP (AREF (spec, FONT_FAMILY_INDEX))) | |
1177 ASET (spec, FONT_FAMILY_INDEX, | |
1178 intern_downcase (p1 + 1, len - (p1 + 1 - p0))); | |
1179 } | |
1180 else if (NILP (AREF (spec, FONT_FAMILY_INDEX))) | |
1181 ASET (spec, FONT_FAMILY_INDEX, intern_downcase (p0, len)); | |
1182 } | |
1183 if (! NILP (registry) | |
1184 && NILP (AREF (spec, FONT_REGISTRY_INDEX))) | |
1185 ASET (spec, FONT_REGISTRY_INDEX, | |
1186 intern_downcase ((char *) SDATA (registry), SBYTES (registry))); | |
1187 } | |
1188 } | |
1189 | |
1190 | |
1191 /* OTF handler */ | |
1192 | |
1193 #ifdef HAVE_LIBOTF | |
1194 #include <otf.h> | |
1195 | |
1196 struct otf_list | |
1197 { | |
1198 Lisp_Object entity; | |
1199 OTF *otf; | |
1200 struct otf_list *next; | |
1201 }; | |
1202 | |
1203 static struct otf_list *otf_list; | |
1204 | |
1205 static Lisp_Object | |
1206 otf_tag_symbol (tag) | |
1207 OTF_Tag tag; | |
1208 { | |
1209 char name[5]; | |
1210 | |
1211 OTF_tag_name (tag, name); | |
1212 return Fintern (make_unibyte_string (name, 4), Qnil); | |
1213 } | |
1214 | |
1215 static OTF * | |
1216 otf_open (entity, file) | |
1217 Lisp_Object entity; | |
1218 char *file; | |
1219 { | |
1220 struct otf_list *list = otf_list; | |
1221 | |
1222 while (list && ! EQ (list->entity, entity)) | |
1223 list = list->next; | |
1224 if (! list) | |
1225 { | |
1226 list = malloc (sizeof (struct otf_list)); | |
1227 list->entity = entity; | |
1228 list->otf = file ? OTF_open (file) : NULL; | |
1229 list->next = otf_list; | |
1230 otf_list = list; | |
1231 } | |
1232 return list->otf; | |
1233 } | |
1234 | |
1235 | |
1236 /* Return a list describing which scripts/languages FONT supports by | |
1237 which GSUB/GPOS features of OpenType tables. See the comment of | |
1238 (sturct font_driver).otf_capability. */ | |
1239 | |
1240 Lisp_Object | |
1241 font_otf_capability (font) | |
1242 struct font *font; | |
1243 { | |
1244 OTF *otf; | |
1245 Lisp_Object capability = Fcons (Qnil, Qnil); | |
1246 int i; | |
1247 | |
1248 otf = otf_open (font->entity, font->file_name); | |
1249 if (! otf) | |
1250 return Qnil; | |
1251 for (i = 0; i < 2; i++) | |
1252 { | |
1253 OTF_GSUB_GPOS *gsub_gpos; | |
1254 Lisp_Object script_list = Qnil; | |
1255 int j; | |
1256 | |
1257 if (OTF_get_features (otf, i == 0) < 0) | |
1258 continue; | |
1259 gsub_gpos = i == 0 ? otf->gsub : otf->gpos; | |
1260 for (j = gsub_gpos->ScriptList.ScriptCount - 1; j >= 0; j--) | |
1261 { | |
1262 OTF_Script *script = gsub_gpos->ScriptList.Script + j; | |
1263 Lisp_Object langsys_list = Qnil; | |
1264 Lisp_Object script_tag = otf_tag_symbol (script->ScriptTag); | |
1265 int k; | |
1266 | |
1267 for (k = script->LangSysCount; k >= 0; k--) | |
1268 { | |
1269 OTF_LangSys *langsys; | |
1270 Lisp_Object feature_list = Qnil; | |
1271 Lisp_Object langsys_tag; | |
1272 int l; | |
1273 | |
1274 if (j == script->LangSysCount) | |
1275 { | |
1276 langsys = &script->DefaultLangSys; | |
1277 langsys_tag = Qnil; | |
1278 } | |
1279 else | |
1280 { | |
1281 langsys = script->LangSys + k; | |
1282 langsys_tag | |
1283 = otf_tag_symbol (script->LangSysRecord[k].LangSysTag); | |
1284 } | |
1285 for (l = langsys->FeatureCount -1; l >= 0; l--) | |
1286 { | |
1287 OTF_Feature *feature | |
1288 = gsub_gpos->FeatureList.Feature + langsys->FeatureIndex[l]; | |
1289 Lisp_Object feature_tag | |
1290 = otf_tag_symbol (feature->FeatureTag); | |
1291 | |
1292 feature_list = Fcons (feature_tag, feature_list); | |
1293 } | |
1294 langsys_list = Fcons (Fcons (langsys_tag, feature_list), | |
1295 langsys_list); | |
1296 } | |
1297 script_list = Fcons (Fcons (script_tag, langsys_list), | |
1298 script_list); | |
1299 } | |
1300 | |
1301 if (i == 0) | |
1302 XSETCAR (capability, script_list); | |
1303 else | |
1304 XSETCDR (capability, script_list); | |
1305 } | |
1306 | |
1307 return capability; | |
1308 } | |
1309 | |
1310 static int | |
1311 parse_gsub_gpos_spec (spec, script, langsys, features) | |
1312 Lisp_Object spec; | |
1313 char **script, **langsys, **features; | |
1314 { | |
1315 Lisp_Object val; | |
1316 int len; | |
1317 char *p; | |
1318 int asterisk; | |
1319 | |
1320 val = XCAR (spec); | |
1321 *script = (char *) SDATA (SYMBOL_NAME (val)); | |
1322 spec = XCDR (spec); | |
1323 val = XCAR (spec); | |
1324 *langsys = NILP (val) ? NULL : (char *) SDATA (SYMBOL_NAME (val)); | |
1325 spec = XCDR (spec); | |
1326 len = XINT (Flength (spec)); | |
1327 *features = p = malloc (6 * len); | |
1328 if (! p) | |
1329 return -1; | |
1330 | |
1331 for (asterisk = 0; CONSP (spec); spec = XCDR (spec)) | |
1332 { | |
1333 val = XCAR (spec); | |
1334 if (SREF (SYMBOL_NAME (val), 0) == '*') | |
1335 { | |
1336 asterisk = 1; | |
1337 p += sprintf (p, ",*"); | |
1338 } | |
1339 else if (! asterisk) | |
1340 p += sprintf (p, ",%s", SDATA (SYMBOL_NAME (val))); | |
1341 else | |
1342 p += sprintf (p, ",~%s", SDATA (SYMBOL_NAME (val))); | |
1343 } | |
1344 return 0; | |
1345 } | |
1346 | |
1347 #define DEVICE_DELTA(table, size) \ | |
1348 (((size) >= (table).StartSize && (size) <= (table).EndSize) \ | |
1349 ? (table).DeltaValue[(size) >= (table).StartSize] \ | |
1350 : 0) | |
1351 | |
1352 void | |
1353 adjust_anchor (struct font *font, OTF_Anchor *anchor, | |
1354 unsigned code, int size, int *x, int *y) | |
1355 { | |
1356 if (anchor->AnchorFormat == 2) | |
1357 { | |
1358 int x0, y0; | |
1359 | |
1360 if (font->driver->anchor_point (font, code, anchor->f.f1.AnchorPoint, | |
1361 &x0, &y0) >= 0) | |
1362 *x = x0, *y = y0; | |
1363 } | |
1364 else if (anchor->AnchorFormat == 3) | |
1365 { | |
1366 if (anchor->f.f2.XDeviceTable.offset) | |
1367 *x += DEVICE_DELTA (anchor->f.f2.XDeviceTable, size); | |
1368 if (anchor->f.f2.YDeviceTable.offset) | |
1369 *y += DEVICE_DELTA (anchor->f.f2.YDeviceTable, size); | |
1370 } | |
1371 } | |
1372 | |
1373 | |
1374 /* Drive FONT's OTF GSUB features according to GSUB_SPEC. See the | |
1375 comment of (sturct font_driver).otf_gsub. */ | |
1376 | |
1377 int | |
1378 font_otf_gsub (font, gsub_spec, gstring_in, from, to, gstring_out, idx) | |
1379 struct font *font; | |
1380 Lisp_Object gsub_spec; | |
1381 Lisp_Object gstring_in; | |
1382 int from, to; | |
1383 Lisp_Object gstring_out; | |
1384 int idx; | |
1385 { | |
1386 int len; | |
1387 int i; | |
1388 OTF *otf; | |
1389 OTF_GlyphString otf_gstring; | |
1390 OTF_Glyph *g; | |
1391 char *script, *langsys, *features; | |
1392 | |
1393 otf = otf_open (font->entity, font->file_name); | |
1394 if (! otf) | |
1395 return 0; | |
1396 if (OTF_get_table (otf, "head") < 0) | |
1397 return 0; | |
1398 if (OTF_check_table (otf, "GSUB") < 0) | |
1399 return 0; | |
1400 if (parse_gsub_gpos_spec (gsub_spec, &script, &langsys, &features) < 0) | |
1401 return 0; | |
1402 len = to - from; | |
1403 otf_gstring.size = otf_gstring.used = len; | |
1404 otf_gstring.glyphs = (OTF_Glyph *) malloc (sizeof (OTF_Glyph) * len); | |
1405 memset (otf_gstring.glyphs, 0, sizeof (OTF_Glyph) * len); | |
1406 for (i = 0; i < len; i++) | |
1407 { | |
1408 Lisp_Object g = LGSTRING_GLYPH (gstring_in, from + i); | |
1409 | |
1410 otf_gstring.glyphs[i].c = XINT (LGLYPH_CHAR (g)); | |
1411 otf_gstring.glyphs[i].glyph_id = XINT (LGLYPH_CODE (g)); | |
1412 } | |
1413 | |
1414 OTF_drive_gdef (otf, &otf_gstring); | |
1415 if (OTF_drive_gsub (otf, &otf_gstring, script, langsys, features) < 0) | |
1416 { | |
1417 free (otf_gstring.glyphs); | |
1418 return 0; | |
1419 } | |
1420 if (ASIZE (gstring_out) < idx + otf_gstring.used) | |
1421 { | |
1422 free (otf_gstring.glyphs); | |
1423 return -1; | |
1424 } | |
1425 | |
1426 for (i = 0, g = otf_gstring.glyphs; i < otf_gstring.used;) | |
1427 { | |
1428 int i0 = g->f.index.from, i1 = g->f.index.to; | |
1429 Lisp_Object glyph = LGSTRING_GLYPH (gstring_in, from + i0); | |
1430 Lisp_Object min_idx = AREF (glyph, 0); | |
1431 Lisp_Object max_idx = AREF (glyph, 1); | |
1432 | |
1433 if (i0 < i1) | |
1434 { | |
1435 int min_idx_i = XINT (min_idx), max_idx_i = XINT (max_idx); | |
1436 | |
1437 for (i0++; i0 <= i1; i0++) | |
1438 { | |
1439 glyph = LGSTRING_GLYPH (gstring_in, from + i0); | |
1440 if (min_idx_i > XINT (AREF (glyph, 0))) | |
1441 min_idx_i = XINT (AREF (glyph, 0)); | |
1442 if (max_idx_i < XINT (AREF (glyph, 1))) | |
1443 max_idx_i = XINT (AREF (glyph, 1)); | |
1444 } | |
1445 min_idx = make_number (min_idx_i); | |
1446 max_idx = make_number (max_idx_i); | |
1447 i0 = g->f.index.from; | |
1448 } | |
1449 for (; i < otf_gstring.used && g->f.index.from == i0; i++, g++) | |
1450 { | |
1451 glyph = LGSTRING_GLYPH (gstring_out, idx + i); | |
1452 ASET (glyph, 0, min_idx); | |
1453 ASET (glyph, 1, max_idx); | |
1454 LGLYPH_SET_CHAR (glyph, make_number (g->c)); | |
1455 LGLYPH_SET_CODE (glyph, make_number (g->glyph_id)); | |
1456 } | |
1457 } | |
1458 | |
1459 free (otf_gstring.glyphs); | |
1460 return i; | |
1461 } | |
1462 | |
1463 /* Drive FONT's OTF GPOS features according to GPOS_SPEC. See the | |
1464 comment of (sturct font_driver).otf_gpos. */ | |
1465 | |
1466 int | |
1467 font_otf_gpos (font, gpos_spec, gstring, from, to) | |
1468 struct font *font; | |
1469 Lisp_Object gpos_spec; | |
1470 Lisp_Object gstring; | |
1471 int from, to; | |
1472 { | |
1473 int len; | |
1474 int i; | |
1475 OTF *otf; | |
1476 OTF_GlyphString otf_gstring; | |
1477 OTF_Glyph *g; | |
1478 char *script, *langsys, *features; | |
1479 Lisp_Object glyph; | |
1480 int u, size; | |
1481 Lisp_Object base, mark; | |
1482 | |
1483 otf = otf_open (font->entity, font->file_name); | |
1484 if (! otf) | |
1485 return 0; | |
1486 if (OTF_get_table (otf, "head") < 0) | |
1487 return 0; | |
1488 if (OTF_check_table (otf, "GPOS") < 0) | |
1489 return 0; | |
1490 if (parse_gsub_gpos_spec (gpos_spec, &script, &langsys, &features) < 0) | |
1491 return 0; | |
1492 len = to - from; | |
1493 otf_gstring.size = otf_gstring.used = len; | |
1494 otf_gstring.glyphs = (OTF_Glyph *) malloc (sizeof (OTF_Glyph) * len); | |
1495 memset (otf_gstring.glyphs, 0, sizeof (OTF_Glyph) * len); | |
1496 for (i = 0; i < len; i++) | |
1497 { | |
1498 glyph = LGSTRING_GLYPH (gstring, from + i); | |
1499 otf_gstring.glyphs[i].glyph_id = XINT (LGLYPH_CODE (glyph)); | |
1500 } | |
1501 | |
1502 OTF_drive_gdef (otf, &otf_gstring); | |
1503 | |
1504 if (OTF_drive_gpos (otf, &otf_gstring, script, langsys, features) < 0) | |
1505 { | |
1506 free (otf_gstring.glyphs); | |
1507 return 0; | |
1508 } | |
1509 | |
1510 u = otf->head->unitsPerEm; | |
1511 size = font->pixel_size; | |
1512 base = mark = Qnil; | |
1513 for (i = 0, g = otf_gstring.glyphs; i < otf_gstring.used; i++, g++) | |
1514 { | |
1515 Lisp_Object prev; | |
1516 int xoff = 0, yoff = 0, width_adjust = 0; | |
1517 | |
1518 if (! g->glyph_id) | |
1519 continue; | |
1520 | |
1521 glyph = LGSTRING_GLYPH (gstring, from + i); | |
1522 switch (g->positioning_type) | |
1523 { | |
1524 case 0: | |
1525 break; | |
1526 case 1: case 2: | |
1527 { | |
1528 int format = g->f.f1.format; | |
1529 | |
1530 if (format & OTF_XPlacement) | |
1531 xoff = g->f.f1.value->XPlacement * size / u; | |
1532 if (format & OTF_XPlaDevice) | |
1533 xoff += DEVICE_DELTA (g->f.f1.value->XPlaDevice, size); | |
1534 if (format & OTF_YPlacement) | |
1535 yoff = - (g->f.f1.value->YPlacement * size / u); | |
1536 if (format & OTF_YPlaDevice) | |
1537 yoff -= DEVICE_DELTA (g->f.f1.value->YPlaDevice, size); | |
1538 if (format & OTF_XAdvance) | |
1539 width_adjust += g->f.f1.value->XAdvance * size / u; | |
1540 if (format & OTF_XAdvDevice) | |
1541 width_adjust += DEVICE_DELTA (g->f.f1.value->XAdvDevice, size); | |
1542 } | |
1543 break; | |
1544 case 3: | |
1545 /* Not yet supported. */ | |
1546 break; | |
1547 case 4: case 5: | |
1548 if (NILP (base)) | |
1549 break; | |
1550 prev = base; | |
1551 goto label_adjust_anchor; | |
1552 default: /* i.e. case 6 */ | |
1553 if (NILP (mark)) | |
1554 break; | |
1555 prev = mark; | |
1556 | |
1557 label_adjust_anchor: | |
1558 { | |
1559 int base_x, base_y, mark_x, mark_y, width; | |
1560 unsigned code; | |
1561 | |
1562 base_x = g->f.f4.base_anchor->XCoordinate * size / u; | |
1563 base_y = g->f.f4.base_anchor->YCoordinate * size / u; | |
1564 mark_x = g->f.f4.mark_anchor->XCoordinate * size / u; | |
1565 mark_y = g->f.f4.mark_anchor->YCoordinate * size / u; | |
1566 | |
1567 code = XINT (LGLYPH_CODE (prev)); | |
1568 if (g->f.f4.base_anchor->AnchorFormat != 1) | |
1569 adjust_anchor (font, g->f.f4.base_anchor, | |
1570 code, size, &base_x, &base_y); | |
1571 if (g->f.f4.mark_anchor->AnchorFormat != 1) | |
1572 adjust_anchor (font, g->f.f4.mark_anchor, | |
1573 code, size, &mark_x, &mark_y); | |
1574 | |
1575 if (NILP (LGLYPH_WIDTH (prev))) | |
1576 { | |
1577 width = font->driver->text_extents (font, &code, 1, NULL); | |
1578 LGLYPH_SET_WIDTH (prev, make_number (width)); | |
1579 } | |
1580 xoff = XINT (LGLYPH_XOFF (prev)) + (base_x - width) - mark_x; | |
1581 yoff = XINT (LGLYPH_YOFF (prev)) + mark_y - base_y; | |
1582 } | |
1583 } | |
1584 if (g->GlyphClass == OTF_GlyphClass0) | |
1585 base = mark = glyph; | |
1586 else if (g->GlyphClass == OTF_GlyphClassMark) | |
1587 mark = glyph; | |
1588 else | |
1589 base = glyph; | |
1590 | |
1591 LGLYPH_SET_XOFF (glyph, make_number (xoff)); | |
1592 LGLYPH_SET_YOFF (glyph, make_number (yoff)); | |
1593 LGLYPH_SET_WADJUST (glyph, make_number (width_adjust)); | |
1594 } | |
1595 | |
1596 free (otf_gstring.glyphs); | |
1597 return 0; | |
1598 } | |
1599 | |
1600 #endif /* HAVE_LIBOTF */ | |
1601 | |
1602 | |
1603 /* glyph-string handler */ | |
1604 | |
1605 /* GSTRING is a vector of this form: | |
1606 [ [FONT-OBJECT LBEARING RBEARING WITH ASCENT DESCENT] GLYPH ... ] | |
1607 and GLYPH is a vector of this form: | |
1608 [ FROM-IDX TO-IDX C CODE X-OFF Y-OFF WIDTH WADJUST ] | |
1609 where | |
1610 FROM-IDX and TO-IDX are used internally and should not be touched. | |
1611 C is a character of the glyph. | |
1612 CODE is a glyph-code of C in FONT-OBJECT. | |
1613 X-OFF and Y-OFF are offests to the base position for the glyph. | |
1614 WIDTH is a normal width of the glyph. | |
1615 WADJUST is an adjustment to the normal width of the glyph. */ | |
1616 | |
1617 struct font * | |
1618 font_prepare_composition (cmp) | |
1619 struct composition *cmp; | |
1620 { | |
1621 Lisp_Object gstring | |
1622 = AREF (XHASH_TABLE (composition_hash_table)->key_and_value, | |
1623 cmp->hash_index * 2); | |
1624 struct font *font = XSAVE_VALUE (LGSTRING_FONT (gstring))->pointer; | |
1625 int len = LGSTRING_LENGTH (gstring); | |
1626 int i; | |
1627 | |
1628 cmp->font = font; | |
1629 cmp->lbearing = cmp->rbearing = cmp->pixel_width = 0; | |
1630 cmp->ascent = font->ascent; | |
1631 cmp->descent = font->descent; | |
1632 | |
1633 for (i = 0; i < len; i++) | |
1634 { | |
1635 Lisp_Object g = LGSTRING_GLYPH (gstring, i); | |
1636 unsigned code = XINT (LGLYPH_CODE (g)); | |
1637 struct font_metrics metrics; | |
1638 | |
1639 font->driver->text_extents (font, &code, 1, &metrics); | |
1640 LGLYPH_SET_WIDTH (g, make_number (metrics.width)); | |
1641 metrics.lbearing += XINT (LGLYPH_XOFF (g)); | |
1642 metrics.rbearing += XINT (LGLYPH_XOFF (g)); | |
1643 metrics.ascent += XINT (LGLYPH_YOFF (g)); | |
1644 metrics.descent += XINT (LGLYPH_YOFF (g)); | |
1645 | |
1646 if (cmp->lbearing > cmp->pixel_width + metrics.lbearing) | |
1647 cmp->lbearing = cmp->pixel_width + metrics.lbearing; | |
1648 if (cmp->rbearing < cmp->pixel_width + metrics.rbearing) | |
1649 cmp->rbearing = cmp->pixel_width + metrics.rbearing; | |
1650 if (cmp->ascent < metrics.ascent) | |
1651 cmp->ascent = metrics.ascent; | |
1652 if (cmp->descent < metrics.descent) | |
1653 cmp->descent = metrics.descent; | |
1654 cmp->pixel_width += metrics.width + XINT (LGLYPH_WADJUST (g)); | |
1655 } | |
1656 LGSTRING_SET_LBEARING (gstring, make_number (cmp->lbearing)); | |
1657 LGSTRING_SET_RBEARING (gstring, make_number (cmp->rbearing)); | |
1658 LGSTRING_SET_WIDTH (gstring, make_number (cmp->pixel_width)); | |
1659 LGSTRING_SET_ASCENT (gstring, make_number (cmp->ascent)); | |
1660 LGSTRING_SET_DESCENT (gstring, make_number (cmp->descent)); | |
1661 | |
1662 return font; | |
1663 } | |
1664 | |
1665 int | |
1666 font_gstring_produce (old, from, to, new, idx, code, n) | |
1667 Lisp_Object old; | |
1668 int from, to; | |
1669 Lisp_Object new; | |
1670 int idx; | |
1671 unsigned *code; | |
1672 int n; | |
1673 { | |
1674 Lisp_Object min_idx, max_idx; | |
1675 int i; | |
1676 | |
1677 if (idx + n > ASIZE (new)) | |
1678 return -1; | |
1679 if (from == to) | |
1680 { | |
1681 if (from == 0) | |
1682 { | |
1683 min_idx = make_number (0); | |
1684 max_idx = make_number (1); | |
1685 } | |
1686 else | |
1687 { | |
1688 min_idx = AREF (AREF (old, from - 1), 0); | |
1689 max_idx = AREF (AREF (old, from - 1), 1); | |
1690 } | |
1691 } | |
1692 else if (from + 1 == to) | |
1693 { | |
1694 min_idx = AREF (AREF (old, from), 0); | |
1695 max_idx = AREF (AREF (old, from), 1); | |
1696 } | |
1697 else | |
1698 { | |
1699 int min_idx_i = XINT (AREF (AREF (old, from), 0)); | |
1700 int max_idx_i = XINT (AREF (AREF (old, from), 1)); | |
1701 | |
1702 for (i = from + 1; i < to; i++) | |
1703 { | |
1704 if (min_idx_i > XINT (AREF (AREF (old, i), 0))) | |
1705 min_idx_i = XINT (AREF (AREF (old, i), 0)); | |
1706 if (max_idx_i < XINT (AREF (AREF (old, i), 1))) | |
1707 max_idx_i = XINT (AREF (AREF (old, i), 1)); | |
1708 } | |
1709 min_idx = make_number (min_idx_i); | |
1710 max_idx = make_number (max_idx_i); | |
1711 } | |
1712 | |
1713 for (i = 0; i < n; i++) | |
1714 { | |
1715 ASET (AREF (new, idx + i), 0, min_idx); | |
1716 ASET (AREF (new, idx + i), 1, max_idx); | |
1717 ASET (AREF (new, idx + i), 2, make_number (code[i])); | |
1718 } | |
1719 | |
1720 return 0; | |
1721 } | |
1722 | |
1723 /* Font sorting */ | |
1724 | |
1725 static unsigned font_score P_ ((Lisp_Object, Lisp_Object)); | |
1726 static int font_compare P_ ((const void *, const void *)); | |
1727 static Lisp_Object font_sort_entites P_ ((Lisp_Object, Lisp_Object, | |
1728 Lisp_Object, Lisp_Object)); | |
1729 | |
1730 /* We sort fonts by scoring each of them against a specified | |
1731 font-spec. The score value is 32 bit (`unsigned'), and the smaller | |
1732 the value is, the closer the font is to the font-spec. | |
1733 | |
1734 Each 1-bit in the highest 4 bits of the score is used for atomic | |
1735 properties FOUNDRY, FAMILY, ADSTYLE, and REGISTRY. | |
1736 | |
1737 Each 7-bit in the lowest 28 bits are used for numeric properties | |
1738 WEIGHT, SLANT, WIDTH, and SIZE. */ | |
1739 | |
1740 /* How many bits to shift to store the difference value of each font | |
1741 property in a score. */ | |
1742 static int sort_shift_bits[FONT_SIZE_INDEX + 1]; | |
1743 | |
1744 /* Score font-entity ENTITY against font-spec SPEC. The return value | |
1745 indicates how different ENTITY is compared with SPEC. */ | |
1746 | |
1747 static unsigned | |
1748 font_score (entity, spec) | |
1749 Lisp_Object entity, spec; | |
1750 { | |
1751 unsigned score = 0; | |
1752 int i; | |
1753 /* Score atomic fields. Maximum difference is 1. */ | |
1754 for (i = FONT_FOUNDRY_INDEX; i <= FONT_REGISTRY_INDEX; i++) | |
1755 { | |
1756 Lisp_Object val = AREF (spec, i); | |
1757 | |
1758 if (! NILP (val) | |
1759 && ! EQ (val, AREF (entity, i))) | |
1760 score |= 1 << sort_shift_bits[i]; | |
1761 } | |
1762 | |
1763 /* Score numeric fields. Maximum difference is 127. */ | |
1764 for (i = FONT_WEIGHT_INDEX; i <= FONT_SIZE_INDEX; i++) | |
1765 { | |
1766 Lisp_Object spec_val = AREF (spec, i); | |
1767 Lisp_Object entity_val = AREF (entity, i); | |
1768 | |
1769 if (! NILP (spec_val) && ! EQ (spec_val, entity_val)) | |
1770 { | |
1771 if (! INTEGERP (entity_val)) | |
1772 score |= 127 << sort_shift_bits[i]; | |
1773 else if (i < FONT_SIZE_INDEX | |
1774 || XINT (entity_val) != 0) | |
1775 { | |
1776 int diff = XINT (entity_val) - XINT (spec_val); | |
1777 | |
1778 if (diff < 0) | |
1779 diff = - diff; | |
1780 score |= min (diff, 127) << sort_shift_bits[i]; | |
1781 } | |
1782 } | |
1783 } | |
1784 | |
1785 return score; | |
1786 } | |
1787 | |
1788 | |
1789 /* The comparison function for qsort. */ | |
1790 | |
1791 static int | |
1792 font_compare (d1, d2) | |
1793 const void *d1, *d2; | |
1794 { | |
1795 return (*(unsigned *) d1 < *(unsigned *) d2 | |
1796 ? -1 : *(unsigned *) d1 > *(unsigned *) d2); | |
1797 } | |
1798 | |
1799 | |
1800 /* The structure for elements being sorted by qsort. */ | |
1801 struct font_sort_data | |
1802 { | |
1803 unsigned score; | |
1804 Lisp_Object entity; | |
1805 }; | |
1806 | |
1807 | |
1808 /* Sort font-entities in vector VEC by closeness to font-spec PREFER. | |
1809 If PREFER specifies a point-size, calculate the corresponding | |
1810 pixel-size from the Y-resolution of FRAME before sorting. If SPEC | |
1811 is not nil, it is a font-spec to get the font-entities in VEC. */ | |
1812 | |
1813 static Lisp_Object | |
1814 font_sort_entites (vec, prefer, frame, spec) | |
1815 Lisp_Object vec, prefer, frame, spec; | |
1816 { | |
1817 Lisp_Object size; | |
1818 int len, i; | |
1819 struct font_sort_data *data; | |
1820 int prefer_is_copy = 0; | |
1821 USE_SAFE_ALLOCA; | |
1822 | |
1823 len = ASIZE (vec); | |
1824 if (len <= 1) | |
1825 return vec; | |
1826 | |
1827 size = AREF (spec, FONT_SIZE_INDEX); | |
1828 if (FLOATP (size)) | |
1829 { | |
1830 double point_size = XFLOAT_DATA (size) * 10; | |
1831 int pixel_size = POINT_TO_PIXEL (point_size, XFRAME (frame)->resy); | |
1832 | |
1833 prefer = Fcopy_sequence (prefer); | |
1834 ASET (prefer, FONT_SIZE_INDEX, make_number (pixel_size)); | |
1835 prefer_is_copy = 1; | |
1836 } | |
1837 | |
1838 if (! NILP (spec)) | |
1839 { | |
1840 /* As it is assured that all fonts in VEC match with SPEC, we | |
1841 should ignore properties specified in SPEC. So, set the | |
1842 corresponding properties in PREFER nil. */ | |
1843 for (i = FONT_WEIGHT_INDEX; i <= FONT_SIZE_INDEX; i++) | |
1844 if (! NILP (AREF (spec, i)) && ! NILP (AREF (prefer, i))) | |
1845 break; | |
1846 if (i <= FONT_SIZE_INDEX) | |
1847 { | |
1848 if (! prefer_is_copy) | |
1849 prefer = Fcopy_sequence (prefer); | |
1850 for (; i <= FONT_SIZE_INDEX; i++) | |
1851 if (! NILP (AREF (spec, i)) && ! NILP (AREF (prefer, i))) | |
1852 ASET (prefer, i, Qnil); | |
1853 } | |
1854 } | |
1855 | |
1856 /* Scoring and sorting. */ | |
1857 SAFE_ALLOCA (data, struct font_sort_data *, (sizeof *data) * len); | |
1858 for (i = 0; i < len; i++) | |
1859 { | |
1860 data[i].entity = AREF (vec, i); | |
1861 data[i].score = font_score (data[i].entity, prefer); | |
1862 } | |
1863 qsort (data, len, sizeof *data, font_compare); | |
1864 for (i = 0; i < len; i++) | |
1865 ASET (vec, i, data[i].entity); | |
1866 SAFE_FREE (); | |
1867 | |
1868 return vec; | |
1869 } | |
1870 | |
1871 | |
1872 /* API of Font Service Layer. */ | |
1873 | |
1874 void | |
1875 font_update_sort_order (order) | |
1876 int *order; | |
1877 { | |
1878 int i, shift_bits = 21; | |
1879 | |
1880 for (i = 0; i < 4; i++, shift_bits -= 7) | |
1881 { | |
1882 int xlfd_idx = order[i]; | |
1883 | |
1884 if (xlfd_idx == XLFD_WEIGHT_INDEX) | |
1885 sort_shift_bits[FONT_WEIGHT_INDEX] = shift_bits; | |
1886 else if (xlfd_idx == XLFD_SLANT_INDEX) | |
1887 sort_shift_bits[FONT_SLANT_INDEX] = shift_bits; | |
1888 else if (xlfd_idx == XLFD_SWIDTH_INDEX) | |
1889 sort_shift_bits[FONT_WIDTH_INDEX] = shift_bits; | |
1890 else | |
1891 sort_shift_bits[FONT_SIZE_INDEX] = shift_bits; | |
1892 } | |
1893 } | |
1894 | |
1895 Lisp_Object | |
1896 font_symbolic_weight (font) | |
1897 Lisp_Object font; | |
1898 { | |
1899 Lisp_Object weight = AREF (font, FONT_WEIGHT_INDEX); | |
1900 | |
1901 if (INTEGERP (weight)) | |
1902 weight = prop_numeric_to_name (FONT_WEIGHT_INDEX, XINT (weight)); | |
1903 return weight; | |
1904 } | |
1905 | |
1906 Lisp_Object | |
1907 font_symbolic_slant (font) | |
1908 Lisp_Object font; | |
1909 { | |
1910 Lisp_Object slant = AREF (font, FONT_SLANT_INDEX); | |
1911 | |
1912 if (INTEGERP (slant)) | |
1913 slant = prop_numeric_to_name (FONT_SLANT_INDEX, XINT (slant)); | |
1914 return slant; | |
1915 } | |
1916 | |
1917 Lisp_Object | |
1918 font_symbolic_width (font) | |
1919 Lisp_Object font; | |
1920 { | |
1921 Lisp_Object width = AREF (font, FONT_WIDTH_INDEX); | |
1922 | |
1923 if (INTEGERP (width)) | |
1924 width = prop_numeric_to_name (FONT_WIDTH_INDEX, XINT (width)); | |
1925 return width; | |
1926 } | |
1927 | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1928 int |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1929 font_match_p (spec, entity) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1930 Lisp_Object spec, entity; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1931 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1932 int i; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1933 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1934 for (i = FONT_FOUNDRY_INDEX; i < FONT_SIZE_INDEX; i++) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1935 if (! NILP (AREF (spec, i)) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1936 && ! EQ (AREF (spec, i), AREF (entity, i))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1937 return 0; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1938 if (INTEGERP (AREF (spec, FONT_SIZE_INDEX)) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1939 && XINT (AREF (entity, FONT_SIZE_INDEX)) > 0 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1940 && (XINT (AREF (spec, FONT_SIZE_INDEX)) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1941 != XINT (AREF (entity, FONT_SIZE_INDEX)))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1942 return 0; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1943 return 1; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1944 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1945 |
90400 | 1946 Lisp_Object |
1947 font_find_object (font) | |
1948 struct font *font; | |
1949 { | |
1950 Lisp_Object tail, elt; | |
1951 | |
1952 for (tail = AREF (font->entity, FONT_OBJLIST_INDEX); CONSP (tail); | |
1953 tail = XCDR (tail)) | |
1954 { | |
1955 elt = XCAR (tail); | |
1956 if (font == XSAVE_VALUE (elt)->pointer | |
1957 && XSAVE_VALUE (elt)->integer > 0) | |
1958 return elt; | |
1959 } | |
1960 abort (); | |
1961 return Qnil; | |
1962 } | |
1963 | |
1964 static Lisp_Object scratch_font_spec, scratch_font_prefer; | |
1965 | |
1966 /* Return a vector of font-entities matching with SPEC on frame F. */ | |
1967 | |
1968 static Lisp_Object | |
1969 font_list_entities (frame, spec) | |
1970 Lisp_Object frame, spec; | |
1971 { | |
1972 FRAME_PTR f = XFRAME (frame); | |
1973 struct font_driver_list *driver_list = f->font_driver_list; | |
1974 Lisp_Object ftype, family, alternate_familes; | |
1975 Lisp_Object *vec = alloca (sizeof (Lisp_Object) * num_font_drivers); | |
1976 int i; | |
1977 | |
1978 if (! vec) | |
1979 return null_vector; | |
1980 | |
1981 family = AREF (spec, FONT_FAMILY_INDEX); | |
1982 if (NILP (family)) | |
1983 alternate_familes = Qnil; | |
1984 else | |
1985 { | |
1986 if (NILP (font_family_alist) | |
1987 && !NILP (Vface_alternative_font_family_alist)) | |
1988 build_font_family_alist (); | |
1989 alternate_familes = assq_no_quit (family, font_family_alist); | |
1990 if (! NILP (alternate_familes)) | |
1991 alternate_familes = XCDR (alternate_familes); | |
1992 } | |
1993 xassert (ASIZE (spec) == FONT_SPEC_MAX); | |
1994 ftype = AREF (spec, FONT_TYPE_INDEX); | |
1995 | |
1996 for (i = 0; driver_list; driver_list = driver_list->next) | |
1997 if (NILP (ftype) || EQ (driver_list->driver->type, ftype)) | |
1998 { | |
1999 Lisp_Object cache = driver_list->driver->get_cache (frame); | |
2000 Lisp_Object tail = alternate_familes; | |
2001 Lisp_Object val; | |
2002 | |
2003 xassert (CONSP (cache)); | |
2004 ASET (spec, FONT_TYPE_INDEX, driver_list->driver->type); | |
2005 ASET (spec, FONT_FAMILY_INDEX, family); | |
2006 | |
2007 while (1) | |
2008 { | |
2009 val = assoc_no_quit (spec, XCDR (cache)); | |
2010 if (CONSP (val)) | |
2011 val = XCDR (val); | |
2012 else | |
2013 { | |
2014 val = driver_list->driver->list (frame, spec); | |
2015 if (VECTORP (val)) | |
2016 XSETCDR (cache, Fcons (Fcons (Fcopy_sequence (spec), val), | |
2017 XCDR (cache))); | |
2018 } | |
2019 if (VECTORP (val) && ASIZE (val) > 0) | |
2020 { | |
2021 vec[i++] = val; | |
2022 break; | |
2023 } | |
2024 if (NILP (tail)) | |
2025 break; | |
2026 ASET (spec, FONT_FAMILY_INDEX, XCAR (tail)); | |
2027 tail = XCDR (tail); | |
2028 } | |
2029 } | |
2030 ASET (spec, FONT_TYPE_INDEX, ftype); | |
2031 ASET (spec, FONT_FAMILY_INDEX, family); | |
2032 return (i > 0 ? Fvconcat (i, vec) : null_vector); | |
2033 } | |
2034 | |
2035 static int num_fonts; | |
2036 | |
2037 static Lisp_Object | |
2038 font_open_entity (f, entity, pixel_size) | |
2039 FRAME_PTR f; | |
2040 Lisp_Object entity; | |
2041 int pixel_size; | |
2042 { | |
2043 struct font_driver_list *driver_list; | |
2044 Lisp_Object objlist, size, val; | |
2045 struct font *font; | |
2046 | |
2047 size = AREF (entity, FONT_SIZE_INDEX); | |
2048 xassert (NATNUMP (size)); | |
2049 if (XINT (size) != 0) | |
2050 pixel_size = XINT (size); | |
2051 | |
2052 for (objlist = AREF (entity, FONT_OBJLIST_INDEX); CONSP (objlist); | |
2053 objlist = XCDR (objlist)) | |
2054 { | |
2055 font = XSAVE_VALUE (XCAR (objlist))->pointer; | |
2056 if (font->pixel_size == pixel_size) | |
2057 { | |
2058 XSAVE_VALUE (XCAR (objlist))->integer++; | |
2059 return XCAR (objlist); | |
2060 } | |
2061 } | |
2062 | |
2063 xassert (FONT_ENTITY_P (entity)); | |
2064 val = AREF (entity, FONT_TYPE_INDEX); | |
2065 for (driver_list = f->font_driver_list; | |
2066 driver_list && ! EQ (driver_list->driver->type, val); | |
2067 driver_list = driver_list->next); | |
2068 if (! driver_list) | |
2069 return Qnil; | |
2070 | |
2071 font = driver_list->driver->open (f, entity, pixel_size); | |
2072 if (! font) | |
2073 return Qnil; | |
2074 val = make_save_value (font, 1); | |
2075 ASET (entity, FONT_OBJLIST_INDEX, | |
2076 Fcons (val, AREF (entity, FONT_OBJLIST_INDEX))); | |
2077 num_fonts++; | |
2078 return val; | |
2079 } | |
2080 | |
2081 void | |
2082 font_close_object (f, font_object) | |
2083 FRAME_PTR f; | |
2084 Lisp_Object font_object; | |
2085 { | |
2086 struct font *font; | |
2087 Lisp_Object objlist = AREF (font->entity, FONT_OBJLIST_INDEX); | |
2088 Lisp_Object tail, prev = Qnil; | |
2089 | |
2090 for (prev = Qnil, tail = objlist; CONSP (tail); | |
2091 prev = tail, tail = XCDR (tail)) | |
2092 if (EQ (font_object, XCAR (tail))) | |
2093 { | |
2094 struct Lisp_Save_Value *p = XSAVE_VALUE (font_object); | |
2095 | |
2096 xassert (p->integer > 0); | |
2097 p->integer--; | |
2098 if (p->integer == 0) | |
2099 { | |
2100 if (font->driver->close) | |
2101 font->driver->close (f, p->pointer); | |
2102 p->pointer = NULL; | |
2103 if (NILP (prev)) | |
2104 ASET (font->entity, FONT_OBJLIST_INDEX, XCDR (objlist)); | |
2105 else | |
2106 XSETCDR (prev, XCDR (objlist)); | |
2107 } | |
2108 break; | |
2109 } | |
2110 } | |
2111 | |
2112 int | |
2113 font_has_char (f, font_entity, c) | |
2114 FRAME_PTR f; | |
2115 Lisp_Object font_entity; | |
2116 int c; | |
2117 { | |
2118 Lisp_Object type = AREF (font_entity, FONT_TYPE_INDEX); | |
2119 struct font_driver_list *driver_list; | |
2120 | |
2121 for (driver_list = f->font_driver_list; | |
2122 driver_list && ! EQ (driver_list->driver->type, type); | |
2123 driver_list = driver_list->next); | |
2124 if (! driver_list) | |
2125 return -1; | |
2126 return driver_list->driver->has_char (font_entity, c); | |
2127 } | |
2128 | |
2129 unsigned | |
2130 font_encode_char (font_object, c) | |
2131 Lisp_Object font_object; | |
2132 int c; | |
2133 { | |
2134 struct font *font = XSAVE_VALUE (font_object)->pointer; | |
2135 | |
2136 return font->driver->encode_char (font, c); | |
2137 } | |
2138 | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2139 Lisp_Object |
90400 | 2140 font_get_name (font_object) |
2141 Lisp_Object font_object; | |
2142 { | |
2143 struct font *font = XSAVE_VALUE (font_object)->pointer; | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2144 char *name = (font->font.full_name ? font->font.full_name |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2145 : font->font.name ? font->font.name |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2146 : NULL); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2147 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2148 return (name ? make_unibyte_string (name, strlen (name)) : null_string); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2149 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2150 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2151 Lisp_Object |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2152 font_get_spec (font_object) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2153 Lisp_Object font_object; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2154 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2155 struct font *font = XSAVE_VALUE (font_object)->pointer; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2156 Lisp_Object spec = Ffont_spec (0, NULL); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2157 int i; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2158 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2159 for (i = 0; i < FONT_SIZE_INDEX; i++) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2160 ASET (spec, i, AREF (font->entity, i)); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2161 ASET (spec, FONT_SIZE_INDEX, make_number (font->pixel_size)); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2162 return spec; |
90400 | 2163 } |
2164 | |
2165 Lisp_Object | |
2166 font_get_frame (font) | |
2167 Lisp_Object font; | |
2168 { | |
2169 if (FONT_OBJECT_P (font)) | |
2170 font = ((struct font *) XSAVE_VALUE (font)->pointer)->entity; | |
2171 xassert (FONT_ENTITY_P (font)); | |
2172 return AREF (font, FONT_FRAME_INDEX); | |
2173 } | |
2174 | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2175 /* Find a font entity best matching with LFACE. If SPEC is non-nil, |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2176 the font must exactly match with it. */ |
90400 | 2177 |
2178 Lisp_Object | |
2179 font_find_for_lface (f, lface, spec) | |
2180 FRAME_PTR f; | |
2181 Lisp_Object *lface; | |
2182 Lisp_Object spec; | |
2183 { | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2184 Lisp_Object frame, entities; |
90400 | 2185 int i; |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2186 |
90400 | 2187 if (NILP (spec)) |
2188 for (i = 0; i < FONT_SPEC_MAX; i++) | |
2189 ASET (scratch_font_spec, i, Qnil); | |
2190 else | |
2191 for (i = 0; i < FONT_SPEC_MAX; i++) | |
2192 ASET (scratch_font_spec, i, AREF (spec, i)); | |
2193 | |
2194 if (NILP (AREF (scratch_font_spec, FONT_FAMILY_INDEX)) | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2195 && ! NILP (lface[LFACE_FAMILY_INDEX])) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2196 font_merge_old_spec (Qnil, lface[LFACE_FAMILY_INDEX], Qnil, |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2197 scratch_font_spec); |
90400 | 2198 if (NILP (AREF (scratch_font_spec, FONT_REGISTRY_INDEX))) |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2199 ASET (scratch_font_spec, FONT_REGISTRY_INDEX, intern ("iso8859-1")); |
90400 | 2200 |
2201 XSETFRAME (frame, f); | |
2202 entities = font_list_entities (frame, scratch_font_spec); | |
2203 while (ASIZE (entities) == 0) | |
2204 { | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2205 if (! NILP (AREF (scratch_font_spec, FONT_FOUNDRY_INDEX)) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2206 && (NILP (spec) || NILP (AREF (spec, FONT_FOUNDRY_INDEX)))) |
90400 | 2207 { |
2208 ASET (scratch_font_spec, FONT_FOUNDRY_INDEX, Qnil); | |
2209 entities = font_list_entities (frame, scratch_font_spec); | |
2210 } | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2211 else if (! NILP (AREF (scratch_font_spec, FONT_FAMILY_INDEX)) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2212 && (NILP (spec) || NILP (AREF (spec, FONT_FAMILY_INDEX)))) |
90400 | 2213 { |
2214 ASET (scratch_font_spec, FONT_FAMILY_INDEX, Qnil); | |
2215 entities = font_list_entities (frame, scratch_font_spec); | |
2216 } | |
2217 else | |
2218 return Qnil; | |
2219 } | |
2220 | |
2221 if (ASIZE (entities) > 1) | |
2222 { | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2223 Lisp_Object prefer = scratch_font_prefer, val; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2224 int size; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2225 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2226 ASET (prefer, FONT_WEIGHT_INDEX, |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2227 font_prop_validate_style (FONT_WEIGHT_INDEX, |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2228 lface[LFACE_WEIGHT_INDEX])); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2229 ASET (prefer, FONT_SLANT_INDEX, |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2230 font_prop_validate_style (FONT_SLANT_INDEX, |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2231 lface[LFACE_SLANT_INDEX])); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2232 ASET (prefer, FONT_WIDTH_INDEX, |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2233 font_prop_validate_style (FONT_WIDTH_INDEX, |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2234 lface[LFACE_SWIDTH_INDEX])); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2235 val = lface[LFACE_HEIGHT_INDEX]; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2236 size = POINT_TO_PIXEL (XINT (val), f->resy); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2237 ASET (prefer, FONT_SIZE_INDEX, make_number (size)); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2238 |
90400 | 2239 font_sort_entites (entities, prefer, frame, spec); |
2240 } | |
2241 | |
2242 return AREF (entities, 0); | |
2243 } | |
2244 | |
2245 Lisp_Object | |
2246 font_open_for_lface (f, lface, entity) | |
2247 FRAME_PTR f; | |
2248 Lisp_Object *lface; | |
2249 Lisp_Object entity; | |
2250 { | |
2251 int pt = XINT (lface[LFACE_HEIGHT_INDEX]); | |
2252 int size = POINT_TO_PIXEL (pt, f->resy); | |
2253 | |
2254 return font_open_entity (f, entity, size); | |
2255 } | |
2256 | |
2257 void | |
2258 font_load_for_face (f, face) | |
2259 FRAME_PTR f; | |
2260 struct face *face; | |
2261 { | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2262 Lisp_Object font_object = face->lface[LFACE_FONT_INDEX]; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2263 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2264 if (NILP (font_object)) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2265 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2266 Lisp_Object entity = font_find_for_lface (f, face->lface, Qnil); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2267 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2268 if (! NILP (entity)) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2269 font_object = font_open_for_lface (f, face->lface, entity); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2270 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2271 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2272 if (! NILP (font_object)) |
90400 | 2273 { |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2274 struct font *font = XSAVE_VALUE (font_object)->pointer; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2275 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2276 face->font = font->font.font; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2277 face->font_info = (struct font_info *) font; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2278 face->font_info_id = 0; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2279 face->font_name = font->font.full_name; |
90400 | 2280 } |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2281 else |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2282 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2283 face->font = NULL; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2284 face->font_info = NULL; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2285 face->font_info_id = -1; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2286 face->font_name = NULL; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2287 add_to_log ("Unable to load font for a face%s", null_string, Qnil); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2288 } |
90400 | 2289 } |
2290 | |
2291 void | |
2292 font_prepare_for_face (f, face) | |
2293 FRAME_PTR f; | |
2294 struct face *face; | |
2295 { | |
2296 struct font *font = (struct font *) face->font_info; | |
2297 | |
2298 if (font->driver->prepare_face) | |
2299 font->driver->prepare_face (f, face); | |
2300 } | |
2301 | |
2302 void | |
2303 font_done_for_face (f, face) | |
2304 FRAME_PTR f; | |
2305 struct face *face; | |
2306 { | |
2307 struct font *font = (struct font *) face->font_info; | |
2308 | |
2309 if (font->driver->done_face) | |
2310 font->driver->done_face (f, face); | |
2311 face->extra = NULL; | |
2312 } | |
2313 | |
2314 Lisp_Object | |
2315 font_open_by_name (f, name) | |
2316 FRAME_PTR f; | |
2317 char *name; | |
2318 { | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2319 Lisp_Object args[2]; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2320 Lisp_Object spec; |
90400 | 2321 Lisp_Object frame; |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
2322 struct font_driver_list *dlist; |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2323 int pixel_size; |
90400 | 2324 |
2325 XSETFRAME (frame, f); | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2326 args[0] = QCname; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2327 args[1] = make_unibyte_string (name, strlen (name)); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2328 spec = Ffont_spec (2, args); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2329 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2330 if (INTEGERP (AREF (spec, FONT_SIZE_INDEX))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2331 pixel_size = XINT (AREF (spec, FONT_SIZE_INDEX)); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2332 else if (FLOATP (AREF (spec, FONT_SIZE_INDEX))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2333 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2334 double pt = XFLOAT_DATA (AREF (spec, FONT_SIZE_INDEX)); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2335 pixel_size = POINT_TO_PIXEL (pt * 10, f->resy); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2336 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2337 else |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2338 pixel_size = 12; |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
2339 for (dlist = f->font_driver_list; dlist; dlist = dlist->next) |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2340 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2341 Lisp_Object entities = font_list_entities (frame, spec); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2342 Lisp_Object font_object; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2343 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2344 if (ASIZE (entities) == 0) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2345 continue; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2346 font_object = font_open_entity (f, AREF (entities, 0), pixel_size); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2347 if (! NILP (font_object)) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2348 return font_object; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2349 } |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
2350 return Qnil; |
90400 | 2351 } |
2352 | |
2353 | |
2354 /* Register font-driver DRIVER. This function is used in two ways. | |
2355 | |
2356 The first is with frame F non-NULL. In this case, DRIVER is | |
2357 registered to be used for drawing characters on F. All frame | |
2358 creaters (e.g. Fx_create_frame) must call this function at least | |
2359 once with an available font-driver. | |
2360 | |
2361 The second is with frame F NULL. In this case, DRIVER is globally | |
2362 registered in the variable `font_driver_list'. All font-driver | |
2363 implementations must call this function in its syms_of_XXXX | |
2364 (e.g. syms_of_xfont). */ | |
2365 | |
2366 void | |
2367 register_font_driver (driver, f) | |
2368 struct font_driver *driver; | |
2369 FRAME_PTR f; | |
2370 { | |
2371 struct font_driver_list *root = f ? f->font_driver_list : font_driver_list; | |
2372 struct font_driver_list *prev, *list; | |
2373 | |
2374 if (f && ! driver->draw) | |
2375 error ("Unsable font driver for a frame: %s", | |
2376 SDATA (SYMBOL_NAME (driver->type))); | |
2377 | |
2378 for (prev = NULL, list = root; list; prev = list, list = list->next) | |
2379 if (list->driver->type == driver->type) | |
2380 error ("Duplicated font driver: %s", SDATA (SYMBOL_NAME (driver->type))); | |
2381 | |
2382 list = malloc (sizeof (struct font_driver_list)); | |
2383 list->driver = driver; | |
2384 list->next = NULL; | |
2385 if (prev) | |
2386 prev->next = list; | |
2387 else if (f) | |
2388 f->font_driver_list = list; | |
2389 else | |
2390 font_driver_list = list; | |
2391 num_font_drivers++; | |
2392 } | |
2393 | |
2394 /* Free font-driver list on frame F. It doesn't free font-drivers | |
2395 themselves. */ | |
2396 | |
2397 void | |
2398 free_font_driver_list (f) | |
2399 FRAME_PTR f; | |
2400 { | |
2401 while (f->font_driver_list) | |
2402 { | |
2403 struct font_driver_list *next = f->font_driver_list->next; | |
2404 | |
2405 free (f->font_driver_list); | |
2406 f->font_driver_list = next; | |
2407 } | |
2408 } | |
2409 | |
2410 | |
2411 /* Lisp API */ | |
2412 | |
2413 DEFUN ("fontp", Ffontp, Sfontp, 1, 1, 0, | |
2414 doc: /* Return t if object is a font-spec or font-entity. */) | |
2415 (object) | |
2416 Lisp_Object object; | |
2417 { | |
2418 return (FONTP (object) ? Qt : Qnil); | |
2419 } | |
2420 | |
2421 DEFUN ("font-spec", Ffont_spec, Sfont_spec, 0, MANY, 0, | |
2422 doc: /* Return a newly created font-spec with specified arguments as properties. | |
2423 usage: (font-spec &rest properties) */) | |
2424 (nargs, args) | |
2425 int nargs; | |
2426 Lisp_Object *args; | |
2427 { | |
2428 Lisp_Object spec = Fmake_vector (make_number (FONT_SPEC_MAX), Qnil); | |
2429 Lisp_Object extra = Qnil; | |
2430 int i; | |
2431 | |
2432 for (i = 0; i < nargs; i += 2) | |
2433 { | |
2434 enum font_property_index prop; | |
2435 Lisp_Object key = args[i], val = args[i + 1]; | |
2436 | |
2437 prop = check_font_prop_name (key); | |
2438 if (prop < FONT_EXTRA_INDEX) | |
2439 ASET (spec, prop, (font_property_table[prop].validater) (prop, val)); | |
2440 else | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
2441 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
2442 if (EQ (key, QCname)) |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2443 font_parse_name ((char *) SDATA (val), spec, 0); |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
2444 extra = Fcons (Fcons (key, val), extra); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
2445 } |
90400 | 2446 } |
2447 ASET (spec, FONT_EXTRA_INDEX, extra); | |
2448 return spec; | |
2449 } | |
2450 | |
2451 | |
2452 DEFUN ("font-get", Ffont_get, Sfont_get, 2, 2, 0, | |
2453 doc: /* Return the value of FONT's PROP property. | |
2454 FONT may be a font-spec or font-entity. | |
2455 If FONT is font-entity and PROP is :extra, always nil is returned. */) | |
2456 (font, prop) | |
2457 Lisp_Object font, prop; | |
2458 { | |
2459 enum font_property_index idx; | |
2460 | |
2461 CHECK_FONT (font); | |
2462 idx = check_font_prop_name (prop); | |
2463 if (idx < FONT_EXTRA_INDEX) | |
2464 return AREF (font, idx); | |
2465 if (FONT_ENTITY_P (font)) | |
2466 return Qnil; | |
2467 return Fcdr (Fassoc (AREF (font, FONT_EXTRA_INDEX), prop)); | |
2468 } | |
2469 | |
2470 | |
2471 DEFUN ("font-put", Ffont_put, Sfont_put, 3, 3, 0, | |
2472 doc: /* Set one property of FONT-SPEC: give property PROP value VALUE. */) | |
2473 (font_spec, prop, val) | |
2474 Lisp_Object font_spec, prop, val; | |
2475 { | |
2476 enum font_property_index idx; | |
2477 Lisp_Object extra, slot; | |
2478 | |
2479 CHECK_FONT_SPEC (font_spec); | |
2480 idx = check_font_prop_name (prop); | |
2481 if (idx < FONT_EXTRA_INDEX) | |
2482 return ASET (font_spec, idx, val); | |
2483 extra = AREF (font_spec, FONT_EXTRA_INDEX); | |
2484 slot = Fassoc (extra, prop); | |
2485 if (NILP (slot)) | |
2486 extra = Fcons (Fcons (prop, val), extra); | |
2487 else | |
2488 Fsetcdr (slot, val); | |
2489 return val; | |
2490 } | |
2491 | |
2492 DEFUN ("list-fonts", Flist_fonts, Slist_fonts, 1, 4, 0, | |
2493 doc: /* List available fonts matching FONT-SPEC on the current frame. | |
2494 Optional 2nd argument FRAME specifies the target frame. | |
2495 Optional 3rd argument NUM, if non-nil, limits the number of returned fonts. | |
2496 Optional 4th argument PREFER, if non-nil, is a font-spec to sort fonts | |
2497 by closeness to PREFER. */) | |
2498 (font_spec, frame, num, prefer) | |
2499 Lisp_Object font_spec, frame, num, prefer; | |
2500 { | |
2501 Lisp_Object vec, list, tail; | |
2502 int n = 0, i, len; | |
2503 | |
2504 if (NILP (frame)) | |
2505 frame = selected_frame; | |
2506 CHECK_LIVE_FRAME (frame); | |
2507 CHECK_VALIDATE_FONT_SPEC (font_spec); | |
2508 if (! NILP (num)) | |
2509 { | |
2510 CHECK_NUMBER (num); | |
2511 n = XINT (num); | |
2512 if (n <= 0) | |
2513 return Qnil; | |
2514 } | |
2515 if (! NILP (prefer)) | |
2516 CHECK_FONT (prefer); | |
2517 | |
2518 vec = font_list_entities (frame, font_spec); | |
2519 len = ASIZE (vec); | |
2520 if (len == 0) | |
2521 return Qnil; | |
2522 if (len == 1) | |
2523 return Fcons (AREF (vec, 0), Qnil); | |
2524 | |
2525 if (! NILP (prefer)) | |
2526 vec = font_sort_entites (vec, prefer, frame, font_spec); | |
2527 | |
2528 list = tail = Fcons (AREF (vec, 0), Qnil); | |
2529 if (n == 0 || n > len) | |
2530 n = len; | |
2531 for (i = 1; i < n; i++) | |
2532 { | |
2533 Lisp_Object val = Fcons (AREF (vec, i), Qnil); | |
2534 | |
2535 XSETCDR (tail, val); | |
2536 tail = val; | |
2537 } | |
2538 return list; | |
2539 } | |
2540 | |
2541 DEFUN ("list-families", Flist_families, Slist_families, 0, 1, 0, | |
2542 doc: /* List available font families on the current frame. | |
2543 Optional 2nd argument FRAME specifies the target frame. */) | |
2544 (frame) | |
2545 Lisp_Object frame; | |
2546 { | |
2547 FRAME_PTR f; | |
2548 struct font_driver_list *driver_list; | |
2549 Lisp_Object list; | |
2550 | |
2551 if (NILP (frame)) | |
2552 frame = selected_frame; | |
2553 CHECK_LIVE_FRAME (frame); | |
2554 f = XFRAME (frame); | |
2555 list = Qnil; | |
2556 for (driver_list = f->font_driver_list; driver_list; | |
2557 driver_list = driver_list->next) | |
2558 if (driver_list->driver->list_family) | |
2559 { | |
2560 Lisp_Object val = driver_list->driver->list_family (frame); | |
2561 | |
2562 if (NILP (list)) | |
2563 list = val; | |
2564 else | |
2565 { | |
2566 Lisp_Object tail = list; | |
2567 | |
2568 for (; CONSP (val); val = XCDR (val)) | |
2569 if (NILP (Fmemq (XCAR (val), tail))) | |
2570 list = Fcons (XCAR (val), list); | |
2571 } | |
2572 } | |
2573 return list; | |
2574 } | |
2575 | |
2576 DEFUN ("find-font", Ffind_font, Sfind_font, 1, 2, 0, | |
2577 doc: /* Return a font-entity matching with FONT-SPEC on the current frame. | |
2578 Optional 2nd argument FRAME, if non-nil, specifies the target frame. */) | |
2579 (font_spec, frame) | |
2580 Lisp_Object font_spec, frame; | |
2581 { | |
2582 Lisp_Object val = Flist_fonts (font_spec, frame, make_number (1), Qnil); | |
2583 | |
2584 if (CONSP (val)) | |
2585 val = XCAR (val); | |
2586 return val; | |
2587 } | |
2588 | |
2589 DEFUN ("font-xlfd-name", Ffont_xlfd_name, Sfont_xlfd_name, 1, 1, 0, | |
2590 doc: /* Return XLFD name of FONT. | |
2591 FONT is a font-spec, font-entity, or font-object. | |
2592 If the name is too long for XLFD (maximum 255 chars), return nil. */) | |
2593 (font) | |
2594 Lisp_Object font; | |
2595 { | |
2596 char name[256]; | |
2597 int pixel_size = 0; | |
2598 | |
2599 if (FONT_SPEC_P (font)) | |
2600 CHECK_VALIDATE_FONT_SPEC (font); | |
2601 else if (FONT_ENTITY_P (font)) | |
2602 CHECK_FONT (font); | |
2603 else | |
2604 { | |
2605 struct font *fontp; | |
2606 | |
2607 CHECK_FONT_GET_OBJECT (font, fontp); | |
2608 font = fontp->entity; | |
2609 pixel_size = fontp->pixel_size; | |
2610 } | |
2611 | |
2612 if (font_unparse_xlfd (font, pixel_size, name, 256) < 0) | |
2613 return Qnil; | |
2614 return build_string (name); | |
2615 } | |
2616 | |
2617 DEFUN ("clear-font-cache", Fclear_font_cache, Sclear_font_cache, 0, 0, 0, | |
2618 doc: /* Clear font cache. */) | |
2619 () | |
2620 { | |
2621 Lisp_Object list, frame; | |
2622 | |
2623 FOR_EACH_FRAME (list, frame) | |
2624 { | |
2625 FRAME_PTR f = XFRAME (frame); | |
2626 struct font_driver_list *driver_list = f->font_driver_list; | |
2627 | |
2628 for (; driver_list; driver_list = driver_list->next) | |
2629 { | |
2630 Lisp_Object cache = driver_list->driver->get_cache (frame); | |
2631 Lisp_Object tail, elt; | |
2632 | |
2633 for (tail = XCDR (cache); CONSP (tail); tail = XCDR (tail)) | |
2634 { | |
2635 elt = XCAR (tail); | |
2636 if (CONSP (elt) && FONT_SPEC_P (XCAR (elt))) | |
2637 { | |
2638 Lisp_Object vec = XCDR (elt); | |
2639 int i; | |
2640 | |
2641 for (i = 0; i < ASIZE (vec); i++) | |
2642 { | |
2643 Lisp_Object entity = AREF (vec, i); | |
2644 Lisp_Object objlist = AREF (entity, FONT_OBJLIST_INDEX); | |
2645 | |
2646 for (; CONSP (objlist); objlist = XCDR (objlist)) | |
2647 { | |
2648 Lisp_Object val = XCAR (objlist); | |
2649 struct Lisp_Save_Value *p = XSAVE_VALUE (val); | |
2650 struct font *font = p->pointer; | |
2651 | |
2652 xassert (font | |
2653 && driver_list->driver == font->driver); | |
2654 driver_list->driver->close (f, font); | |
2655 p->pointer = NULL; | |
2656 p->integer = 0; | |
2657 } | |
2658 if (driver_list->driver->free_entity) | |
2659 driver_list->driver->free_entity (entity); | |
2660 } | |
2661 } | |
2662 } | |
2663 XSETCDR (cache, Qnil); | |
2664 } | |
2665 } | |
2666 | |
2667 return Qnil; | |
2668 } | |
2669 | |
2670 DEFUN ("internal-set-font-style-table", Finternal_set_font_style_table, | |
2671 Sinternal_set_font_style_table, 2, 2, 0, | |
2672 doc: /* Set font style table for PROP to TABLE. | |
2673 PROP must be `:weight', `:slant', or `:width'. | |
2674 TABLE must be an alist of symbols vs the corresponding numeric values | |
2675 sorted by numeric values. */) | |
2676 (prop, table) | |
2677 Lisp_Object prop, table; | |
2678 { | |
2679 int table_index; | |
2680 int numeric; | |
2681 Lisp_Object tail, val; | |
2682 | |
2683 CHECK_SYMBOL (prop); | |
2684 table_index = (EQ (prop, QCweight) ? 0 | |
2685 : EQ (prop, QCslant) ? 1 | |
2686 : EQ (prop, QCwidth) ? 2 | |
2687 : 3); | |
2688 if (table_index >= ASIZE (font_style_table)) | |
2689 error ("Invalid font style property: %s", SDATA (SYMBOL_NAME (prop))); | |
2690 table = Fcopy_sequence (table); | |
2691 numeric = -1; | |
2692 for (tail = table; ! NILP (tail); tail = Fcdr (tail)) | |
2693 { | |
2694 prop = Fcar (Fcar (tail)); | |
2695 val = Fcdr (Fcar (tail)); | |
2696 CHECK_SYMBOL (prop); | |
2697 CHECK_NATNUM (val); | |
2698 if (numeric > XINT (val)) | |
2699 error ("Numeric values not sorted for %s", SDATA (SYMBOL_NAME (prop))); | |
2700 numeric = XINT (val); | |
2701 XSETCAR (tail, Fcons (prop, val)); | |
2702 } | |
2703 ASET (font_style_table, table_index, table); | |
2704 return Qnil; | |
2705 } | |
2706 | |
2707 DEFUN ("font-make-gstring", Ffont_make_gstring, Sfont_make_gstring, 2, 2, 0, | |
2708 doc: /* Return a newly created glyph-string for FONT-OBJECT with NUM glyphs. | |
2709 FONT-OBJECT may be nil if it is not yet known. */) | |
2710 (font_object, num) | |
2711 Lisp_Object font_object, num; | |
2712 { | |
2713 Lisp_Object gstring, g; | |
2714 int len; | |
2715 int i; | |
2716 | |
2717 if (! NILP (font_object)) | |
2718 CHECK_FONT_OBJECT (font_object); | |
2719 CHECK_NATNUM (num); | |
2720 | |
2721 len = XINT (num) + 1; | |
2722 gstring = Fmake_vector (make_number (len), Qnil); | |
2723 g = Fmake_vector (make_number (6), Qnil); | |
2724 ASET (g, 0, font_object); | |
2725 ASET (gstring, 0, g); | |
2726 for (i = 1; i < len; i++) | |
2727 ASET (gstring, i, Fmake_vector (make_number (8), make_number (0))); | |
2728 return gstring; | |
2729 } | |
2730 | |
2731 DEFUN ("font-fill-gstring", Ffont_fill_gstring, Sfont_fill_gstring, 4, 5, 0, | |
2732 doc: /* Fillin glyph-string GSTRING by characters for FONT-OBJECT. | |
2733 START and END specifies the region to extract characters. | |
2734 If optional 3rd argument OBJECT is non-nil, it is a buffer or a string from | |
2735 where to extract characters. | |
2736 FONT-OBJECT may be nil if GSTRING already already contains one. */) | |
2737 (gstring, font_object, start, end, object) | |
2738 Lisp_Object gstring, font_object, start, end, object; | |
2739 { | |
2740 int len, i, c; | |
2741 unsigned code; | |
2742 struct font *font; | |
2743 | |
2744 CHECK_VECTOR (gstring); | |
2745 if (NILP (font_object)) | |
2746 font_object = Faref (Faref (gstring, make_number (0)), make_number (0)); | |
2747 CHECK_FONT_GET_OBJECT (font_object, font); | |
2748 | |
2749 if (STRINGP (object)) | |
2750 { | |
2751 const unsigned char *p; | |
2752 | |
2753 CHECK_NATNUM (start); | |
2754 CHECK_NATNUM (end); | |
2755 if (XINT (start) > XINT (end) | |
2756 || XINT (end) > ASIZE (object) | |
2757 || XINT (end) - XINT (start) >= XINT (Flength (gstring))) | |
2758 args_out_of_range (start, end); | |
2759 | |
2760 len = XINT (end) - XINT (start); | |
2761 p = SDATA (object) + string_char_to_byte (object, XINT (start)); | |
2762 for (i = 0; i < len; i++) | |
2763 { | |
2764 Lisp_Object g = LGSTRING_GLYPH (gstring, i); | |
2765 | |
2766 c = STRING_CHAR_ADVANCE (p); | |
2767 code = font->driver->encode_char (font, c); | |
2768 if (code > MOST_POSITIVE_FIXNUM) | |
2769 error ("Glyph code 0x%X is too large", code); | |
2770 ASET (g, 0, make_number (i)); | |
2771 ASET (g, 1, make_number (i + 1)); | |
2772 LGLYPH_SET_CHAR (g, make_number (c)); | |
2773 LGLYPH_SET_CODE (g, make_number (code)); | |
2774 } | |
2775 } | |
2776 else | |
2777 { | |
2778 int pos, pos_byte; | |
2779 | |
2780 if (! NILP (object)) | |
2781 Fset_buffer (object); | |
2782 validate_region (&start, &end); | |
2783 if (XINT (end) - XINT (start) > len) | |
2784 args_out_of_range (start, end); | |
2785 len = XINT (end) - XINT (start); | |
2786 pos = XINT (start); | |
2787 pos_byte = CHAR_TO_BYTE (pos); | |
2788 for (i = 0; i < len; i++) | |
2789 { | |
2790 Lisp_Object g = LGSTRING_GLYPH (gstring, i); | |
2791 | |
2792 FETCH_CHAR_ADVANCE (c, pos, pos_byte); | |
2793 code = font->driver->encode_char (font, c); | |
2794 if (code > MOST_POSITIVE_FIXNUM) | |
2795 error ("Glyph code 0x%X is too large", code); | |
2796 ASET (g, 0, make_number (i)); | |
2797 ASET (g, 1, make_number (i + 1)); | |
2798 LGLYPH_SET_CHAR (g, make_number (c)); | |
2799 LGLYPH_SET_CODE (g, make_number (code)); | |
2800 } | |
2801 } | |
2802 return Qnil; | |
2803 } | |
2804 | |
2805 | |
2806 #ifdef FONT_DEBUG | |
2807 | |
2808 DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0, | |
2809 doc: /* Open FONT-ENTITY. */) | |
2810 (font_entity, size, frame) | |
2811 Lisp_Object font_entity; | |
2812 Lisp_Object size; | |
2813 Lisp_Object frame; | |
2814 { | |
2815 int isize; | |
2816 | |
2817 CHECK_FONT_ENTITY (font_entity); | |
2818 if (NILP (size)) | |
2819 size = AREF (font_entity, FONT_SIZE_INDEX); | |
2820 CHECK_NUMBER (size); | |
2821 if (NILP (frame)) | |
2822 frame = selected_frame; | |
2823 CHECK_LIVE_FRAME (frame); | |
2824 | |
2825 isize = XINT (size); | |
2826 if (isize < 0) | |
2827 isize = POINT_TO_PIXEL (- isize, XFRAME (frame)->resy); | |
2828 | |
2829 return font_open_entity (XFRAME (frame), font_entity, isize); | |
2830 } | |
2831 | |
2832 DEFUN ("close-font", Fclose_font, Sclose_font, 1, 2, 0, | |
2833 doc: /* Close FONT-OBJECT. */) | |
2834 (font_object, frame) | |
2835 Lisp_Object font_object, frame; | |
2836 { | |
2837 CHECK_FONT_OBJECT (font_object); | |
2838 if (NILP (frame)) | |
2839 frame = selected_frame; | |
2840 CHECK_LIVE_FRAME (frame); | |
2841 font_close_object (XFRAME (frame), font_object); | |
2842 return Qnil; | |
2843 } | |
2844 | |
2845 DEFUN ("query-font", Fquery_font, Squery_font, 1, 1, 0, | |
2846 doc: /* Return information about FONT-OBJECT. */) | |
2847 (font_object) | |
2848 Lisp_Object font_object; | |
2849 { | |
2850 struct font *font; | |
2851 Lisp_Object val; | |
2852 | |
2853 CHECK_FONT_GET_OBJECT (font_object, font); | |
2854 | |
2855 val = Fmake_vector (make_number (9), Qnil); | |
2856 ASET (val, 0, Ffont_xlfd_name (font_object)); | |
2857 if (font->file_name) | |
2858 ASET (val, 1, make_unibyte_string (font->file_name, | |
2859 strlen (font->file_name))); | |
2860 ASET (val, 2, make_number (font->pixel_size)); | |
2861 ASET (val, 3, make_number (font->font.size)); | |
2862 ASET (val, 4, make_number (font->ascent)); | |
2863 ASET (val, 5, make_number (font->descent)); | |
2864 ASET (val, 6, make_number (font->font.space_width)); | |
2865 ASET (val, 7, make_number (font->font.average_width)); | |
2866 if (font->driver->otf_capability) | |
2867 ASET (val, 8, font->driver->otf_capability (font)); | |
2868 return val; | |
2869 } | |
2870 | |
2871 DEFUN ("get-font-glyphs", Fget_font_glyphs, Sget_font_glyphs, 2, 2, 0, | |
2872 doc: /* Return a vector of glyphs of FONT-OBJECT for drawing STRING. | |
2873 Each element is a vector [GLYPH-CODE LBEARING RBEARING WIDTH ASCENT DESCENT]. */) | |
2874 (font_object, string) | |
2875 Lisp_Object font_object, string; | |
2876 { | |
2877 struct font *font; | |
2878 int i, len; | |
2879 Lisp_Object vec; | |
2880 | |
2881 CHECK_FONT_GET_OBJECT (font_object, font); | |
2882 CHECK_STRING (string); | |
2883 len = SCHARS (string); | |
2884 vec = Fmake_vector (make_number (len), Qnil); | |
2885 for (i = 0; i < len; i++) | |
2886 { | |
2887 Lisp_Object ch = Faref (string, make_number (i)); | |
2888 Lisp_Object val; | |
2889 int c = XINT (ch); | |
2890 unsigned code; | |
2891 struct font_metrics metrics; | |
2892 | |
2893 code = font->driver->encode_char (font, c); | |
2894 if (code == FONT_INVALID_CODE) | |
2895 continue; | |
2896 val = Fmake_vector (make_number (6), Qnil); | |
2897 if (code <= MOST_POSITIVE_FIXNUM) | |
2898 ASET (val, 0, make_number (code)); | |
2899 else | |
2900 ASET (val, 0, Fcons (make_number (code >> 16), | |
2901 make_number (code & 0xFFFF))); | |
2902 font->driver->text_extents (font, &code, 1, &metrics); | |
2903 ASET (val, 1, make_number (metrics.lbearing)); | |
2904 ASET (val, 2, make_number (metrics.rbearing)); | |
2905 ASET (val, 3, make_number (metrics.width)); | |
2906 ASET (val, 4, make_number (metrics.ascent)); | |
2907 ASET (val, 5, make_number (metrics.descent)); | |
2908 ASET (vec, i, val); | |
2909 } | |
2910 return vec; | |
2911 } | |
2912 | |
2913 #if 0 | |
2914 DEFUN ("draw-string", Fdraw_string, Sdraw_string, 2, 2, 0, | |
2915 doc: /* Draw STRING by FONT-OBJECT on the top left corner of the current frame. | |
2916 The value is a number of glyphs drawn. | |
2917 Type C-l to recover what previously shown. */) | |
2918 (font_object, string) | |
2919 Lisp_Object font_object, string; | |
2920 { | |
2921 Lisp_Object frame = selected_frame; | |
2922 FRAME_PTR f = XFRAME (frame); | |
2923 struct font *font; | |
2924 struct face *face; | |
2925 int i, len, width; | |
2926 unsigned *code; | |
2927 | |
2928 CHECK_FONT_GET_OBJECT (font_object, font); | |
2929 CHECK_STRING (string); | |
2930 len = SCHARS (string); | |
2931 code = alloca (sizeof (unsigned) * len); | |
2932 for (i = 0; i < len; i++) | |
2933 { | |
2934 Lisp_Object ch = Faref (string, make_number (i)); | |
2935 Lisp_Object val; | |
2936 int c = XINT (ch); | |
2937 | |
2938 code[i] = font->driver->encode_char (font, c); | |
2939 if (code[i] == FONT_INVALID_CODE) | |
2940 break; | |
2941 } | |
2942 face = FACE_FROM_ID (f, DEFAULT_FACE_ID); | |
2943 face->fontp = font; | |
2944 if (font->driver->prepare_face) | |
2945 font->driver->prepare_face (f, face); | |
2946 width = font->driver->text_extents (font, code, i, NULL); | |
2947 len = font->driver->draw_text (f, face, 0, font->ascent, code, i, width); | |
2948 if (font->driver->done_face) | |
2949 font->driver->done_face (f, face); | |
2950 face->fontp = NULL; | |
2951 return make_number (len); | |
2952 } | |
2953 #endif | |
2954 | |
2955 #endif /* FONT_DEBUG */ | |
2956 | |
2957 | |
2958 extern void syms_of_ftfont P_ (()); | |
2959 extern void syms_of_xfont P_ (()); | |
2960 extern void syms_of_xftfont P_ (()); | |
2961 extern void syms_of_ftxfont P_ (()); | |
2962 extern void syms_of_bdffont P_ (()); | |
2963 extern void syms_of_w32font P_ (()); | |
2964 extern void syms_of_atmfont P_ (()); | |
2965 | |
2966 void | |
2967 syms_of_font () | |
2968 { | |
2969 sort_shift_bits[FONT_SLANT_INDEX] = 0; | |
2970 sort_shift_bits[FONT_WEIGHT_INDEX] = 7; | |
2971 sort_shift_bits[FONT_SIZE_INDEX] = 14; | |
2972 sort_shift_bits[FONT_WIDTH_INDEX] = 21; | |
2973 sort_shift_bits[FONT_ADSTYLE_INDEX] = 28; | |
2974 sort_shift_bits[FONT_FOUNDRY_INDEX] = 29; | |
2975 sort_shift_bits[FONT_FAMILY_INDEX] = 30; | |
2976 sort_shift_bits[FONT_REGISTRY_INDEX] = 31; | |
2977 /* Note that sort_shift_bits[FONT_SLANT_TYPE] is never used. */ | |
2978 | |
2979 staticpro (&font_style_table); | |
2980 font_style_table = Fmake_vector (make_number (3), Qnil); | |
2981 | |
2982 staticpro (&font_family_alist); | |
2983 font_family_alist = Qnil; | |
2984 | |
2985 DEFSYM (Qfontp, "fontp"); | |
2986 | |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
2987 DEFSYM (Qiso8859_1, "iso8859-1"); |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
2988 DEFSYM (Qiso10646_1, "iso10646-1"); |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
2989 DEFSYM (Qunicode_bmp, "unicode-bmp"); |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
2990 |
90400 | 2991 DEFSYM (QCotf, ":otf"); |
2992 DEFSYM (QClanguage, ":language"); | |
2993 DEFSYM (QCscript, ":script"); | |
2994 | |
2995 DEFSYM (QCfoundry, ":foundry"); | |
2996 DEFSYM (QCadstyle, ":adstyle"); | |
2997 DEFSYM (QCregistry, ":registry"); | |
2998 DEFSYM (QCextra, ":extra"); | |
2999 | |
3000 staticpro (&null_string); | |
3001 null_string = build_string (""); | |
3002 staticpro (&null_vector); | |
3003 null_vector = Fmake_vector (make_number (0), Qnil); | |
3004 | |
3005 staticpro (&scratch_font_spec); | |
3006 scratch_font_spec = Ffont_spec (0, NULL); | |
3007 staticpro (&scratch_font_prefer); | |
3008 scratch_font_prefer = Ffont_spec (0, NULL); | |
3009 | |
3010 defsubr (&Sfontp); | |
3011 defsubr (&Sfont_spec); | |
3012 defsubr (&Sfont_get); | |
3013 defsubr (&Sfont_put); | |
3014 defsubr (&Slist_fonts); | |
3015 defsubr (&Slist_families); | |
3016 defsubr (&Sfind_font); | |
3017 defsubr (&Sfont_xlfd_name); | |
3018 defsubr (&Sclear_font_cache); | |
3019 defsubr (&Sinternal_set_font_style_table); | |
3020 defsubr (&Sfont_make_gstring); | |
3021 defsubr (&Sfont_fill_gstring); | |
3022 | |
3023 #ifdef FONT_DEBUG | |
3024 defsubr (&Sopen_font); | |
3025 defsubr (&Sclose_font); | |
3026 defsubr (&Squery_font); | |
3027 defsubr (&Sget_font_glyphs); | |
3028 #if 0 | |
3029 defsubr (&Sdraw_string); | |
3030 #endif | |
3031 #endif /* FONT_DEBUG */ | |
3032 | |
3033 #ifdef HAVE_FREETYPE | |
3034 syms_of_ftfont (); | |
3035 #ifdef HAVE_X_WINDOWS | |
3036 syms_of_xfont (); | |
3037 syms_of_ftxfont (); | |
3038 #ifdef HAVE_XFT | |
3039 syms_of_xftfont (); | |
3040 #endif /* HAVE_XFT */ | |
3041 #endif /* HAVE_X_WINDOWS */ | |
3042 #else /* not HAVE_FREETYPE */ | |
3043 #ifdef HAVE_X_WINDOWS | |
3044 syms_of_xfont (); | |
3045 #endif /* HAVE_X_WINDOWS */ | |
3046 #endif /* not HAVE_FREETYPE */ | |
3047 #ifdef HAVE_BDFFONT | |
3048 syms_of_bdffont (); | |
3049 #endif /* HAVE_BDFFONT */ | |
3050 #ifdef WINDOWSNT | |
3051 syms_of_w32font (); | |
3052 #endif /* WINDOWSNT */ | |
3053 #ifdef MAC_OS | |
3054 syms_of_atmfont (); | |
3055 #endif /* MAC_OS */ | |
3056 } | |
90427 | 3057 |
3058 /* arch-tag: 74c9475d-5976-4c93-a327-942ae3072846 | |
3059 (do not change this comment) */ |