Mercurial > emacs
annotate src/font.c @ 90450:5c96354daf9e
(ftfont_pattern_entity): Fix typo.
(ftfont_list): Enforce FC_LANG in PATTERN to cancel the effect of
locale.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 14 Jun 2006 00:38:48 +0000 |
parents | 15dda5f83c27 |
children | 6ffc9b378367 |
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, | |
361 XLFD_PIXEL_SIZE_INDEX, | |
362 XLFD_POINT_SIZE_INDEX, | |
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 | |
372 /* Return a symbol interned by string at STR and bytes LEN. | |
373 If LEN == 0, return a null string. | |
374 If the string is "*", return Qnil. | |
375 It is assured that LEN < 256. */ | |
376 | |
377 static Lisp_Object | |
378 intern_font_field (f, xlfd) | |
379 char *f[XLFD_LAST_INDEX + 1]; | |
380 int xlfd; | |
381 { | |
382 char *str = f[xlfd] + 1; | |
383 int len; | |
384 | |
385 if (xlfd != XLFD_RESY_INDEX) | |
386 len = f[xlfd + 1] - f[xlfd] - 1; | |
387 else | |
388 len = f[XLFD_REGISTRY_INDEX] - f[xlfd] - 1; | |
389 | |
390 if (len == 0) | |
391 return null_string; | |
392 if (*str == '*' && len == 1) | |
393 return Qnil; | |
394 return intern_downcase (str, len); | |
395 } | |
396 | |
397 /* Parse P pointing the pixel/point size field of the form | |
398 `[A B C D]' which specifies a transformation matrix: | |
399 | |
400 A B 0 | |
401 C D 0 | |
402 0 0 1 | |
403 | |
404 by which all glyphs of the font are transformed. The spec says | |
405 that scalar value N for the pixel/point size is equivalent to: | |
406 A = N * resx/resy, B = C = 0, D = N. | |
407 | |
408 Return the scalar value N if the form is valid. Otherwise return | |
409 -1. */ | |
410 | |
411 static int | |
412 parse_matrix (p) | |
413 char *p; | |
414 { | |
415 double matrix[4]; | |
416 char *end; | |
417 int i; | |
418 | |
419 for (i = 0, p++; i < 4 && *p && *p != ']'; i++) | |
420 { | |
421 if (*p == '~') | |
422 matrix[i] = - strtod (p + 1, &end); | |
423 else | |
424 matrix[i] = strtod (p, &end); | |
425 p = end; | |
426 } | |
427 return (i == 4 ? (int) matrix[3] : -1); | |
428 } | |
429 | |
430 /* Parse NAME (null terminated) as XLFD format, and store information | |
431 in FONT (font-spec or font-entity). If NAME is successfully | |
432 parsed, return 2 (non-scalable font), 1 (scalable vector font), or | |
433 0 (auto-scaled font). Otherwise return -1. | |
434 | |
435 If FONT is a font-entity, store RESY-SPACING-AVWIDTH information as | |
436 a symbol in FONT_EXTRA_INDEX. | |
437 | |
438 If MERGE is nonzero, set a property of FONT only when it's nil. */ | |
439 | |
440 int | |
441 font_parse_xlfd (name, font, merge) | |
442 char *name; | |
443 Lisp_Object font; | |
444 int merge; | |
445 { | |
446 int len = strlen (name); | |
447 int i, j; | |
448 int pixel_size, resy, avwidth; | |
449 double point_size; | |
450 char *f[XLFD_LAST_INDEX + 1]; | |
451 Lisp_Object val; | |
452 int first_wildcard_field = -1, last_wildcard_field = XLFD_LAST_INDEX; | |
453 | |
454 if (len > 255) | |
455 /* Maximum XLFD name length is 255. */ | |
456 return -1; | |
457 for (i = 0; *name; name++) | |
458 if (*name == '-' | |
459 && i < XLFD_LAST_INDEX) | |
460 { | |
461 f[i] = name; | |
462 if (name[1] == '*' && (! name[2] || name[2] == '-')) | |
463 { | |
464 if (first_wildcard_field < 0) | |
465 first_wildcard_field = i; | |
466 last_wildcard_field = i; | |
467 } | |
468 i++; | |
469 } | |
470 | |
471 f[XLFD_LAST_INDEX] = name; | |
472 if (i < XLFD_LAST_INDEX) | |
473 { | |
474 /* Not a fully specified XLFD. */ | |
475 if (first_wildcard_field < 0 ) | |
476 /* No wild card. */ | |
477 return -1; | |
478 i--; | |
479 if (last_wildcard_field < i) | |
480 { | |
481 /* Shift fields after the last wildcard field. */ | |
482 for (j = XLFD_LAST_INDEX - 1; j > last_wildcard_field; j--, i--) | |
483 f[j] = f[i]; | |
484 /* Make all fields between the first and last wildcard fieled | |
485 also wildcard fields. */ | |
486 for (j--; j > first_wildcard_field; j--) | |
487 f[j] = "-*"; | |
488 } | |
489 } | |
490 f[XLFD_ENCODING_INDEX] = f[XLFD_LAST_INDEX]; | |
491 | |
492 if (! merge || NILP (AREF (font, FONT_FOUNDRY_INDEX))) | |
493 ASET (font, FONT_FOUNDRY_INDEX, intern_font_field (f, XLFD_FOUNDRY_INDEX)); | |
494 if (! merge || NILP (AREF (font, FONT_FAMILY_INDEX))) | |
495 ASET (font, FONT_FAMILY_INDEX, intern_font_field (f, XLFD_FAMILY_INDEX)); | |
496 if (! merge || NILP (AREF (font, FONT_ADSTYLE_INDEX))) | |
497 ASET (font, FONT_ADSTYLE_INDEX, intern_font_field (f, XLFD_ADSTYLE_INDEX)); | |
498 if (! merge || NILP (AREF (font, FONT_REGISTRY_INDEX))) | |
499 ASET (font, FONT_REGISTRY_INDEX, intern_font_field (f, XLFD_REGISTRY_INDEX)); | |
500 | |
501 for (i = FONT_WEIGHT_INDEX, j = XLFD_WEIGHT_INDEX; | |
502 j <= XLFD_SWIDTH_INDEX; i++, j++) | |
503 if (! merge || NILP (AREF (font, i))) | |
504 { | |
505 if (isdigit(f[j][1])) | |
506 val = make_number (atoi (f[j] + 1)); | |
507 else | |
508 { | |
509 Lisp_Object sym = intern_font_field (f, j); | |
510 | |
511 val = prop_name_to_numeric (i, sym); | |
512 if (NILP (val)) | |
513 val = sym; | |
514 } | |
515 ASET (font, i, val); | |
516 } | |
517 | |
518 if (f[XLFD_PIXEL_SIZE_INDEX][1] == '*') | |
519 pixel_size = -1; /* indicates "unspecified" */ | |
520 else if (f[XLFD_PIXEL_SIZE_INDEX][1] == '[') | |
521 pixel_size = parse_matrix (f[XLFD_PIXEL_SIZE_INDEX] + 1); | |
522 else if (isdigit (f[XLFD_PIXEL_SIZE_INDEX][1])) | |
523 pixel_size = strtod (f[XLFD_PIXEL_SIZE_INDEX] + 1, NULL); | |
524 else | |
525 pixel_size = -1; | |
526 | |
527 if (pixel_size < 0 && FONT_ENTITY_P (font)) | |
528 return -1; | |
529 | |
530 if (f[XLFD_POINT_SIZE_INDEX][1] == '*') | |
531 point_size = -1; /* indicates "unspecified" */ | |
532 else if (f[XLFD_POINT_SIZE_INDEX][1] == '[') | |
533 point_size = parse_matrix (f[XLFD_POINT_SIZE_INDEX] + 1); | |
534 else if (isdigit (f[XLFD_POINT_SIZE_INDEX][1])) | |
535 point_size = strtod (f[XLFD_POINT_SIZE_INDEX] + 1, NULL); | |
536 else | |
537 point_size = -1; | |
538 | |
539 if (f[XLFD_RESY_INDEX][1] == '*') | |
540 resy = -1; /* indicates "unspecified" */ | |
541 else | |
542 resy = strtod (f[XLFD_RESY_INDEX] + 1, NULL); | |
543 | |
544 if (f[XLFD_AVGWIDTH_INDEX][1] == '*') | |
545 avwidth = -1; /* indicates "unspecified" */ | |
546 else if (f[XLFD_AVGWIDTH_INDEX][1] == '~') | |
547 avwidth = - strtod (f[XLFD_AVGWIDTH_INDEX] + 2, NULL); | |
548 else | |
549 avwidth = strtod (f[XLFD_AVGWIDTH_INDEX] + 1, NULL); | |
550 | |
551 if (! merge || NILP (AREF (font, FONT_SIZE_INDEX))) | |
552 { | |
553 if (pixel_size >= 0) | |
554 ASET (font, FONT_SIZE_INDEX, make_number (pixel_size)); | |
555 else | |
556 { | |
557 if (point_size >= 0) | |
558 { | |
559 if (resy > 0) | |
560 { | |
561 pixel_size = POINT_TO_PIXEL (point_size, resy); | |
562 ASET (font, FONT_SIZE_INDEX, make_number (pixel_size)); | |
563 } | |
564 else | |
565 { | |
566 ASET (font, FONT_SIZE_INDEX, make_float (point_size / 10)); | |
567 } | |
568 } | |
569 else | |
570 ASET (font, FONT_SIZE_INDEX, Qnil); | |
571 } | |
572 } | |
573 | |
574 if (FONT_ENTITY_P (font) | |
575 && EQ (AREF (font, FONT_TYPE_INDEX), Qx)) | |
576 ASET (font, FONT_EXTRA_INDEX, intern_font_field (f, XLFD_RESY_INDEX)); | |
577 | |
578 return (avwidth > 0 ? 2 : resy == 0); | |
579 } | |
580 | |
581 /* Store XLFD name of FONT (font-spec or font-entity) in NAME (NBYTES | |
582 length), and return the name length. If FONT_SIZE_INDEX of FONT is | |
583 0, use PIXEL_SIZE instead. */ | |
584 | |
585 int | |
586 font_unparse_xlfd (font, pixel_size, name, nbytes) | |
587 Lisp_Object font; | |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
588 int pixel_size; |
90400 | 589 char *name; |
590 int nbytes; | |
591 { | |
592 char *f[XLFD_REGISTRY_INDEX + 1], *pixel_point; | |
593 char work[256]; | |
594 Lisp_Object val; | |
595 int i, j, len = 0; | |
596 | |
597 xassert (FONTP (font)); | |
598 | |
599 for (i = FONT_FOUNDRY_INDEX, j = XLFD_FOUNDRY_INDEX; i <= FONT_REGISTRY_INDEX; | |
600 i++, j++) | |
601 { | |
602 if (i == FONT_ADSTYLE_INDEX) | |
603 j = XLFD_ADSTYLE_INDEX; | |
604 else if (i == FONT_REGISTRY_INDEX) | |
605 j = XLFD_REGISTRY_INDEX; | |
606 val = AREF (font, i); | |
607 if (NILP (val)) | |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
608 { |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
609 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
|
610 f[j] = "*-*", len += 4; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
611 else |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
612 f[j] = "*", len += 2; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
613 } |
90400 | 614 else |
615 { | |
616 if (SYMBOLP (val)) | |
617 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
|
618 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
|
619 && ! strchr ((char *) SDATA (val), '-')) |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
620 { |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
621 /* 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
|
622 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
|
623 { |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
624 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
|
625 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
|
626 len += SBYTES (val) + 3; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
627 } |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
628 else |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
629 { |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
630 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
|
631 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
|
632 len += SBYTES (val) + 4; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
633 } |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
634 } |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
635 else |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
636 f[j] = (char *) SDATA (val), len += SBYTES (val) + 1; |
90400 | 637 } |
638 } | |
639 | |
640 for (i = FONT_WEIGHT_INDEX, j = XLFD_WEIGHT_INDEX; i <= FONT_WIDTH_INDEX; | |
641 i++, j++) | |
642 { | |
643 val = AREF (font, i); | |
644 if (NILP (val)) | |
645 f[j] = "*", len += 2; | |
646 else | |
647 { | |
648 if (INTEGERP (val)) | |
649 val = prop_numeric_to_name (i, XINT (val)); | |
650 if (SYMBOLP (val)) | |
651 val = SYMBOL_NAME (val); | |
652 xassert (STRINGP (val)); | |
653 f[j] = (char *) SDATA (val), len += SBYTES (val) + 1; | |
654 } | |
655 } | |
656 | |
657 val = AREF (font, FONT_SIZE_INDEX); | |
658 xassert (NUMBERP (val) || NILP (val)); | |
659 if (INTEGERP (val)) | |
660 { | |
661 i = XINT (val); | |
662 if (i > 0) | |
663 len += sprintf (work, "%d", i) + 1; | |
664 else /* i == 0 */ | |
665 len += sprintf (work, "%d-*", pixel_size) + 1; | |
666 pixel_point = work; | |
667 } | |
668 else if (FLOATP (val)) | |
669 { | |
670 i = XFLOAT_DATA (val) * 10; | |
671 len += sprintf (work, "*-%d", i) + 1; | |
672 pixel_point = work; | |
673 } | |
674 else | |
675 pixel_point = "*-*", len += 4; | |
676 | |
677 if (FONT_ENTITY_P (font) | |
678 && EQ (AREF (font, FONT_TYPE_INDEX), Qx)) | |
679 { | |
680 /* Setup names for RESY-SPACING-AVWIDTH. */ | |
681 val = AREF (font, FONT_EXTRA_INDEX); | |
682 if (SYMBOLP (val) && ! NILP (val)) | |
683 { | |
684 val = SYMBOL_NAME (val); | |
685 f[XLFD_RESY_INDEX] = (char *) SDATA (val), len += SBYTES (val) + 1; | |
686 } | |
687 else | |
688 f[XLFD_RESY_INDEX] = "*-*-*", len += 6; | |
689 } | |
690 else | |
691 f[XLFD_RESY_INDEX] = "*-*-*", len += 6; | |
692 | |
693 len += 3; /* for "-*" of resx, and terminating '\0'. */ | |
694 if (len >= nbytes) | |
695 return -1; | |
696 return sprintf (name, "-%s-%s-%s-%s-%s-%s-%s-*-%s-%s", | |
697 f[XLFD_FOUNDRY_INDEX], f[XLFD_FAMILY_INDEX], | |
698 f[XLFD_WEIGHT_INDEX], f[XLFD_SLANT_INDEX], | |
699 f[XLFD_SWIDTH_INDEX], | |
700 f[XLFD_ADSTYLE_INDEX], pixel_point, | |
701 f[XLFD_RESY_INDEX], f[XLFD_REGISTRY_INDEX]); | |
702 } | |
703 | |
704 void | |
705 font_merge_old_spec (name, family, registry, spec) | |
706 Lisp_Object name, family, registry, spec; | |
707 { | |
708 if (STRINGP (name)) | |
709 { | |
710 if (font_parse_xlfd ((char *) SDATA (name), spec, 1) < 0) | |
711 { | |
712 Lisp_Object extra = Fcons (Fcons (QCname, name), Qnil); | |
713 | |
714 ASET (spec, FONT_EXTRA_INDEX, extra); | |
715 } | |
716 } | |
717 else | |
718 { | |
719 if (! NILP (family)) | |
720 { | |
721 int len; | |
722 char *p0, *p1; | |
723 | |
724 xassert (STRINGP (family)); | |
725 len = SBYTES (family); | |
726 p0 = (char *) SDATA (family); | |
727 p1 = index (p0, '-'); | |
728 if (p1) | |
729 { | |
730 if (NILP (AREF (spec, FONT_FOUNDRY_INDEX))) | |
731 ASET (spec, FONT_FOUNDRY_INDEX, | |
732 intern_downcase (p0, p1 - p0)); | |
733 if (NILP (AREF (spec, FONT_FAMILY_INDEX))) | |
734 ASET (spec, FONT_FAMILY_INDEX, | |
735 intern_downcase (p1 + 1, len - (p1 + 1 - p0))); | |
736 } | |
737 else if (NILP (AREF (spec, FONT_FAMILY_INDEX))) | |
738 ASET (spec, FONT_FAMILY_INDEX, intern_downcase (p0, len)); | |
739 } | |
740 if (! NILP (registry) | |
741 && NILP (AREF (spec, FONT_REGISTRY_INDEX))) | |
742 ASET (spec, FONT_REGISTRY_INDEX, | |
743 intern_downcase ((char *) SDATA (registry), SBYTES (registry))); | |
744 } | |
745 } | |
746 | |
747 | |
748 /* OTF handler */ | |
749 | |
750 #ifdef HAVE_LIBOTF | |
751 #include <otf.h> | |
752 | |
753 struct otf_list | |
754 { | |
755 Lisp_Object entity; | |
756 OTF *otf; | |
757 struct otf_list *next; | |
758 }; | |
759 | |
760 static struct otf_list *otf_list; | |
761 | |
762 static Lisp_Object | |
763 otf_tag_symbol (tag) | |
764 OTF_Tag tag; | |
765 { | |
766 char name[5]; | |
767 | |
768 OTF_tag_name (tag, name); | |
769 return Fintern (make_unibyte_string (name, 4), Qnil); | |
770 } | |
771 | |
772 static OTF * | |
773 otf_open (entity, file) | |
774 Lisp_Object entity; | |
775 char *file; | |
776 { | |
777 struct otf_list *list = otf_list; | |
778 | |
779 while (list && ! EQ (list->entity, entity)) | |
780 list = list->next; | |
781 if (! list) | |
782 { | |
783 list = malloc (sizeof (struct otf_list)); | |
784 list->entity = entity; | |
785 list->otf = file ? OTF_open (file) : NULL; | |
786 list->next = otf_list; | |
787 otf_list = list; | |
788 } | |
789 return list->otf; | |
790 } | |
791 | |
792 | |
793 /* Return a list describing which scripts/languages FONT supports by | |
794 which GSUB/GPOS features of OpenType tables. See the comment of | |
795 (sturct font_driver).otf_capability. */ | |
796 | |
797 Lisp_Object | |
798 font_otf_capability (font) | |
799 struct font *font; | |
800 { | |
801 OTF *otf; | |
802 Lisp_Object capability = Fcons (Qnil, Qnil); | |
803 int i; | |
804 | |
805 otf = otf_open (font->entity, font->file_name); | |
806 if (! otf) | |
807 return Qnil; | |
808 for (i = 0; i < 2; i++) | |
809 { | |
810 OTF_GSUB_GPOS *gsub_gpos; | |
811 Lisp_Object script_list = Qnil; | |
812 int j; | |
813 | |
814 if (OTF_get_features (otf, i == 0) < 0) | |
815 continue; | |
816 gsub_gpos = i == 0 ? otf->gsub : otf->gpos; | |
817 for (j = gsub_gpos->ScriptList.ScriptCount - 1; j >= 0; j--) | |
818 { | |
819 OTF_Script *script = gsub_gpos->ScriptList.Script + j; | |
820 Lisp_Object langsys_list = Qnil; | |
821 Lisp_Object script_tag = otf_tag_symbol (script->ScriptTag); | |
822 int k; | |
823 | |
824 for (k = script->LangSysCount; k >= 0; k--) | |
825 { | |
826 OTF_LangSys *langsys; | |
827 Lisp_Object feature_list = Qnil; | |
828 Lisp_Object langsys_tag; | |
829 int l; | |
830 | |
831 if (j == script->LangSysCount) | |
832 { | |
833 langsys = &script->DefaultLangSys; | |
834 langsys_tag = Qnil; | |
835 } | |
836 else | |
837 { | |
838 langsys = script->LangSys + k; | |
839 langsys_tag | |
840 = otf_tag_symbol (script->LangSysRecord[k].LangSysTag); | |
841 } | |
842 for (l = langsys->FeatureCount -1; l >= 0; l--) | |
843 { | |
844 OTF_Feature *feature | |
845 = gsub_gpos->FeatureList.Feature + langsys->FeatureIndex[l]; | |
846 Lisp_Object feature_tag | |
847 = otf_tag_symbol (feature->FeatureTag); | |
848 | |
849 feature_list = Fcons (feature_tag, feature_list); | |
850 } | |
851 langsys_list = Fcons (Fcons (langsys_tag, feature_list), | |
852 langsys_list); | |
853 } | |
854 script_list = Fcons (Fcons (script_tag, langsys_list), | |
855 script_list); | |
856 } | |
857 | |
858 if (i == 0) | |
859 XSETCAR (capability, script_list); | |
860 else | |
861 XSETCDR (capability, script_list); | |
862 } | |
863 | |
864 return capability; | |
865 } | |
866 | |
867 static int | |
868 parse_gsub_gpos_spec (spec, script, langsys, features) | |
869 Lisp_Object spec; | |
870 char **script, **langsys, **features; | |
871 { | |
872 Lisp_Object val; | |
873 int len; | |
874 char *p; | |
875 int asterisk; | |
876 | |
877 val = XCAR (spec); | |
878 *script = (char *) SDATA (SYMBOL_NAME (val)); | |
879 spec = XCDR (spec); | |
880 val = XCAR (spec); | |
881 *langsys = NILP (val) ? NULL : (char *) SDATA (SYMBOL_NAME (val)); | |
882 spec = XCDR (spec); | |
883 len = XINT (Flength (spec)); | |
884 *features = p = malloc (6 * len); | |
885 if (! p) | |
886 return -1; | |
887 | |
888 for (asterisk = 0; CONSP (spec); spec = XCDR (spec)) | |
889 { | |
890 val = XCAR (spec); | |
891 if (SREF (SYMBOL_NAME (val), 0) == '*') | |
892 { | |
893 asterisk = 1; | |
894 p += sprintf (p, ",*"); | |
895 } | |
896 else if (! asterisk) | |
897 p += sprintf (p, ",%s", SDATA (SYMBOL_NAME (val))); | |
898 else | |
899 p += sprintf (p, ",~%s", SDATA (SYMBOL_NAME (val))); | |
900 } | |
901 return 0; | |
902 } | |
903 | |
904 #define DEVICE_DELTA(table, size) \ | |
905 (((size) >= (table).StartSize && (size) <= (table).EndSize) \ | |
906 ? (table).DeltaValue[(size) >= (table).StartSize] \ | |
907 : 0) | |
908 | |
909 void | |
910 adjust_anchor (struct font *font, OTF_Anchor *anchor, | |
911 unsigned code, int size, int *x, int *y) | |
912 { | |
913 if (anchor->AnchorFormat == 2) | |
914 { | |
915 int x0, y0; | |
916 | |
917 if (font->driver->anchor_point (font, code, anchor->f.f1.AnchorPoint, | |
918 &x0, &y0) >= 0) | |
919 *x = x0, *y = y0; | |
920 } | |
921 else if (anchor->AnchorFormat == 3) | |
922 { | |
923 if (anchor->f.f2.XDeviceTable.offset) | |
924 *x += DEVICE_DELTA (anchor->f.f2.XDeviceTable, size); | |
925 if (anchor->f.f2.YDeviceTable.offset) | |
926 *y += DEVICE_DELTA (anchor->f.f2.YDeviceTable, size); | |
927 } | |
928 } | |
929 | |
930 | |
931 /* Drive FONT's OTF GSUB features according to GSUB_SPEC. See the | |
932 comment of (sturct font_driver).otf_gsub. */ | |
933 | |
934 int | |
935 font_otf_gsub (font, gsub_spec, gstring_in, from, to, gstring_out, idx) | |
936 struct font *font; | |
937 Lisp_Object gsub_spec; | |
938 Lisp_Object gstring_in; | |
939 int from, to; | |
940 Lisp_Object gstring_out; | |
941 int idx; | |
942 { | |
943 int len; | |
944 int i; | |
945 OTF *otf; | |
946 OTF_GlyphString otf_gstring; | |
947 OTF_Glyph *g; | |
948 char *script, *langsys, *features; | |
949 | |
950 otf = otf_open (font->entity, font->file_name); | |
951 if (! otf) | |
952 return 0; | |
953 if (OTF_get_table (otf, "head") < 0) | |
954 return 0; | |
955 if (OTF_check_table (otf, "GSUB") < 0) | |
956 return 0; | |
957 if (parse_gsub_gpos_spec (gsub_spec, &script, &langsys, &features) < 0) | |
958 return 0; | |
959 len = to - from; | |
960 otf_gstring.size = otf_gstring.used = len; | |
961 otf_gstring.glyphs = (OTF_Glyph *) malloc (sizeof (OTF_Glyph) * len); | |
962 memset (otf_gstring.glyphs, 0, sizeof (OTF_Glyph) * len); | |
963 for (i = 0; i < len; i++) | |
964 { | |
965 Lisp_Object g = LGSTRING_GLYPH (gstring_in, from + i); | |
966 | |
967 otf_gstring.glyphs[i].c = XINT (LGLYPH_CHAR (g)); | |
968 otf_gstring.glyphs[i].glyph_id = XINT (LGLYPH_CODE (g)); | |
969 } | |
970 | |
971 OTF_drive_gdef (otf, &otf_gstring); | |
972 if (OTF_drive_gsub (otf, &otf_gstring, script, langsys, features) < 0) | |
973 { | |
974 free (otf_gstring.glyphs); | |
975 return 0; | |
976 } | |
977 if (ASIZE (gstring_out) < idx + otf_gstring.used) | |
978 { | |
979 free (otf_gstring.glyphs); | |
980 return -1; | |
981 } | |
982 | |
983 for (i = 0, g = otf_gstring.glyphs; i < otf_gstring.used;) | |
984 { | |
985 int i0 = g->f.index.from, i1 = g->f.index.to; | |
986 Lisp_Object glyph = LGSTRING_GLYPH (gstring_in, from + i0); | |
987 Lisp_Object min_idx = AREF (glyph, 0); | |
988 Lisp_Object max_idx = AREF (glyph, 1); | |
989 | |
990 if (i0 < i1) | |
991 { | |
992 int min_idx_i = XINT (min_idx), max_idx_i = XINT (max_idx); | |
993 | |
994 for (i0++; i0 <= i1; i0++) | |
995 { | |
996 glyph = LGSTRING_GLYPH (gstring_in, from + i0); | |
997 if (min_idx_i > XINT (AREF (glyph, 0))) | |
998 min_idx_i = XINT (AREF (glyph, 0)); | |
999 if (max_idx_i < XINT (AREF (glyph, 1))) | |
1000 max_idx_i = XINT (AREF (glyph, 1)); | |
1001 } | |
1002 min_idx = make_number (min_idx_i); | |
1003 max_idx = make_number (max_idx_i); | |
1004 i0 = g->f.index.from; | |
1005 } | |
1006 for (; i < otf_gstring.used && g->f.index.from == i0; i++, g++) | |
1007 { | |
1008 glyph = LGSTRING_GLYPH (gstring_out, idx + i); | |
1009 ASET (glyph, 0, min_idx); | |
1010 ASET (glyph, 1, max_idx); | |
1011 LGLYPH_SET_CHAR (glyph, make_number (g->c)); | |
1012 LGLYPH_SET_CODE (glyph, make_number (g->glyph_id)); | |
1013 } | |
1014 } | |
1015 | |
1016 free (otf_gstring.glyphs); | |
1017 return i; | |
1018 } | |
1019 | |
1020 /* Drive FONT's OTF GPOS features according to GPOS_SPEC. See the | |
1021 comment of (sturct font_driver).otf_gpos. */ | |
1022 | |
1023 int | |
1024 font_otf_gpos (font, gpos_spec, gstring, from, to) | |
1025 struct font *font; | |
1026 Lisp_Object gpos_spec; | |
1027 Lisp_Object gstring; | |
1028 int from, to; | |
1029 { | |
1030 int len; | |
1031 int i; | |
1032 OTF *otf; | |
1033 OTF_GlyphString otf_gstring; | |
1034 OTF_Glyph *g; | |
1035 char *script, *langsys, *features; | |
1036 Lisp_Object glyph; | |
1037 int u, size; | |
1038 Lisp_Object base, mark; | |
1039 | |
1040 otf = otf_open (font->entity, font->file_name); | |
1041 if (! otf) | |
1042 return 0; | |
1043 if (OTF_get_table (otf, "head") < 0) | |
1044 return 0; | |
1045 if (OTF_check_table (otf, "GPOS") < 0) | |
1046 return 0; | |
1047 if (parse_gsub_gpos_spec (gpos_spec, &script, &langsys, &features) < 0) | |
1048 return 0; | |
1049 len = to - from; | |
1050 otf_gstring.size = otf_gstring.used = len; | |
1051 otf_gstring.glyphs = (OTF_Glyph *) malloc (sizeof (OTF_Glyph) * len); | |
1052 memset (otf_gstring.glyphs, 0, sizeof (OTF_Glyph) * len); | |
1053 for (i = 0; i < len; i++) | |
1054 { | |
1055 glyph = LGSTRING_GLYPH (gstring, from + i); | |
1056 otf_gstring.glyphs[i].glyph_id = XINT (LGLYPH_CODE (glyph)); | |
1057 } | |
1058 | |
1059 OTF_drive_gdef (otf, &otf_gstring); | |
1060 | |
1061 if (OTF_drive_gpos (otf, &otf_gstring, script, langsys, features) < 0) | |
1062 { | |
1063 free (otf_gstring.glyphs); | |
1064 return 0; | |
1065 } | |
1066 | |
1067 u = otf->head->unitsPerEm; | |
1068 size = font->pixel_size; | |
1069 base = mark = Qnil; | |
1070 for (i = 0, g = otf_gstring.glyphs; i < otf_gstring.used; i++, g++) | |
1071 { | |
1072 Lisp_Object prev; | |
1073 int xoff = 0, yoff = 0, width_adjust = 0; | |
1074 | |
1075 if (! g->glyph_id) | |
1076 continue; | |
1077 | |
1078 glyph = LGSTRING_GLYPH (gstring, from + i); | |
1079 switch (g->positioning_type) | |
1080 { | |
1081 case 0: | |
1082 break; | |
1083 case 1: case 2: | |
1084 { | |
1085 int format = g->f.f1.format; | |
1086 | |
1087 if (format & OTF_XPlacement) | |
1088 xoff = g->f.f1.value->XPlacement * size / u; | |
1089 if (format & OTF_XPlaDevice) | |
1090 xoff += DEVICE_DELTA (g->f.f1.value->XPlaDevice, size); | |
1091 if (format & OTF_YPlacement) | |
1092 yoff = - (g->f.f1.value->YPlacement * size / u); | |
1093 if (format & OTF_YPlaDevice) | |
1094 yoff -= DEVICE_DELTA (g->f.f1.value->YPlaDevice, size); | |
1095 if (format & OTF_XAdvance) | |
1096 width_adjust += g->f.f1.value->XAdvance * size / u; | |
1097 if (format & OTF_XAdvDevice) | |
1098 width_adjust += DEVICE_DELTA (g->f.f1.value->XAdvDevice, size); | |
1099 } | |
1100 break; | |
1101 case 3: | |
1102 /* Not yet supported. */ | |
1103 break; | |
1104 case 4: case 5: | |
1105 if (NILP (base)) | |
1106 break; | |
1107 prev = base; | |
1108 goto label_adjust_anchor; | |
1109 default: /* i.e. case 6 */ | |
1110 if (NILP (mark)) | |
1111 break; | |
1112 prev = mark; | |
1113 | |
1114 label_adjust_anchor: | |
1115 { | |
1116 int base_x, base_y, mark_x, mark_y, width; | |
1117 unsigned code; | |
1118 | |
1119 base_x = g->f.f4.base_anchor->XCoordinate * size / u; | |
1120 base_y = g->f.f4.base_anchor->YCoordinate * size / u; | |
1121 mark_x = g->f.f4.mark_anchor->XCoordinate * size / u; | |
1122 mark_y = g->f.f4.mark_anchor->YCoordinate * size / u; | |
1123 | |
1124 code = XINT (LGLYPH_CODE (prev)); | |
1125 if (g->f.f4.base_anchor->AnchorFormat != 1) | |
1126 adjust_anchor (font, g->f.f4.base_anchor, | |
1127 code, size, &base_x, &base_y); | |
1128 if (g->f.f4.mark_anchor->AnchorFormat != 1) | |
1129 adjust_anchor (font, g->f.f4.mark_anchor, | |
1130 code, size, &mark_x, &mark_y); | |
1131 | |
1132 if (NILP (LGLYPH_WIDTH (prev))) | |
1133 { | |
1134 width = font->driver->text_extents (font, &code, 1, NULL); | |
1135 LGLYPH_SET_WIDTH (prev, make_number (width)); | |
1136 } | |
1137 xoff = XINT (LGLYPH_XOFF (prev)) + (base_x - width) - mark_x; | |
1138 yoff = XINT (LGLYPH_YOFF (prev)) + mark_y - base_y; | |
1139 } | |
1140 } | |
1141 if (g->GlyphClass == OTF_GlyphClass0) | |
1142 base = mark = glyph; | |
1143 else if (g->GlyphClass == OTF_GlyphClassMark) | |
1144 mark = glyph; | |
1145 else | |
1146 base = glyph; | |
1147 | |
1148 LGLYPH_SET_XOFF (glyph, make_number (xoff)); | |
1149 LGLYPH_SET_YOFF (glyph, make_number (yoff)); | |
1150 LGLYPH_SET_WADJUST (glyph, make_number (width_adjust)); | |
1151 } | |
1152 | |
1153 free (otf_gstring.glyphs); | |
1154 return 0; | |
1155 } | |
1156 | |
1157 #endif /* HAVE_LIBOTF */ | |
1158 | |
1159 | |
1160 /* glyph-string handler */ | |
1161 | |
1162 /* GSTRING is a vector of this form: | |
1163 [ [FONT-OBJECT LBEARING RBEARING WITH ASCENT DESCENT] GLYPH ... ] | |
1164 and GLYPH is a vector of this form: | |
1165 [ FROM-IDX TO-IDX C CODE X-OFF Y-OFF WIDTH WADJUST ] | |
1166 where | |
1167 FROM-IDX and TO-IDX are used internally and should not be touched. | |
1168 C is a character of the glyph. | |
1169 CODE is a glyph-code of C in FONT-OBJECT. | |
1170 X-OFF and Y-OFF are offests to the base position for the glyph. | |
1171 WIDTH is a normal width of the glyph. | |
1172 WADJUST is an adjustment to the normal width of the glyph. */ | |
1173 | |
1174 struct font * | |
1175 font_prepare_composition (cmp) | |
1176 struct composition *cmp; | |
1177 { | |
1178 Lisp_Object gstring | |
1179 = AREF (XHASH_TABLE (composition_hash_table)->key_and_value, | |
1180 cmp->hash_index * 2); | |
1181 struct font *font = XSAVE_VALUE (LGSTRING_FONT (gstring))->pointer; | |
1182 int len = LGSTRING_LENGTH (gstring); | |
1183 int i; | |
1184 | |
1185 cmp->font = font; | |
1186 cmp->lbearing = cmp->rbearing = cmp->pixel_width = 0; | |
1187 cmp->ascent = font->ascent; | |
1188 cmp->descent = font->descent; | |
1189 | |
1190 for (i = 0; i < len; i++) | |
1191 { | |
1192 Lisp_Object g = LGSTRING_GLYPH (gstring, i); | |
1193 unsigned code = XINT (LGLYPH_CODE (g)); | |
1194 struct font_metrics metrics; | |
1195 | |
1196 font->driver->text_extents (font, &code, 1, &metrics); | |
1197 LGLYPH_SET_WIDTH (g, make_number (metrics.width)); | |
1198 metrics.lbearing += XINT (LGLYPH_XOFF (g)); | |
1199 metrics.rbearing += XINT (LGLYPH_XOFF (g)); | |
1200 metrics.ascent += XINT (LGLYPH_YOFF (g)); | |
1201 metrics.descent += XINT (LGLYPH_YOFF (g)); | |
1202 | |
1203 if (cmp->lbearing > cmp->pixel_width + metrics.lbearing) | |
1204 cmp->lbearing = cmp->pixel_width + metrics.lbearing; | |
1205 if (cmp->rbearing < cmp->pixel_width + metrics.rbearing) | |
1206 cmp->rbearing = cmp->pixel_width + metrics.rbearing; | |
1207 if (cmp->ascent < metrics.ascent) | |
1208 cmp->ascent = metrics.ascent; | |
1209 if (cmp->descent < metrics.descent) | |
1210 cmp->descent = metrics.descent; | |
1211 cmp->pixel_width += metrics.width + XINT (LGLYPH_WADJUST (g)); | |
1212 } | |
1213 LGSTRING_SET_LBEARING (gstring, make_number (cmp->lbearing)); | |
1214 LGSTRING_SET_RBEARING (gstring, make_number (cmp->rbearing)); | |
1215 LGSTRING_SET_WIDTH (gstring, make_number (cmp->pixel_width)); | |
1216 LGSTRING_SET_ASCENT (gstring, make_number (cmp->ascent)); | |
1217 LGSTRING_SET_DESCENT (gstring, make_number (cmp->descent)); | |
1218 | |
1219 return font; | |
1220 } | |
1221 | |
1222 int | |
1223 font_gstring_produce (old, from, to, new, idx, code, n) | |
1224 Lisp_Object old; | |
1225 int from, to; | |
1226 Lisp_Object new; | |
1227 int idx; | |
1228 unsigned *code; | |
1229 int n; | |
1230 { | |
1231 Lisp_Object min_idx, max_idx; | |
1232 int i; | |
1233 | |
1234 if (idx + n > ASIZE (new)) | |
1235 return -1; | |
1236 if (from == to) | |
1237 { | |
1238 if (from == 0) | |
1239 { | |
1240 min_idx = make_number (0); | |
1241 max_idx = make_number (1); | |
1242 } | |
1243 else | |
1244 { | |
1245 min_idx = AREF (AREF (old, from - 1), 0); | |
1246 max_idx = AREF (AREF (old, from - 1), 1); | |
1247 } | |
1248 } | |
1249 else if (from + 1 == to) | |
1250 { | |
1251 min_idx = AREF (AREF (old, from), 0); | |
1252 max_idx = AREF (AREF (old, from), 1); | |
1253 } | |
1254 else | |
1255 { | |
1256 int min_idx_i = XINT (AREF (AREF (old, from), 0)); | |
1257 int max_idx_i = XINT (AREF (AREF (old, from), 1)); | |
1258 | |
1259 for (i = from + 1; i < to; i++) | |
1260 { | |
1261 if (min_idx_i > XINT (AREF (AREF (old, i), 0))) | |
1262 min_idx_i = XINT (AREF (AREF (old, i), 0)); | |
1263 if (max_idx_i < XINT (AREF (AREF (old, i), 1))) | |
1264 max_idx_i = XINT (AREF (AREF (old, i), 1)); | |
1265 } | |
1266 min_idx = make_number (min_idx_i); | |
1267 max_idx = make_number (max_idx_i); | |
1268 } | |
1269 | |
1270 for (i = 0; i < n; i++) | |
1271 { | |
1272 ASET (AREF (new, idx + i), 0, min_idx); | |
1273 ASET (AREF (new, idx + i), 1, max_idx); | |
1274 ASET (AREF (new, idx + i), 2, make_number (code[i])); | |
1275 } | |
1276 | |
1277 return 0; | |
1278 } | |
1279 | |
1280 /* Font sorting */ | |
1281 | |
1282 static unsigned font_score P_ ((Lisp_Object, Lisp_Object)); | |
1283 static int font_compare P_ ((const void *, const void *)); | |
1284 static Lisp_Object font_sort_entites P_ ((Lisp_Object, Lisp_Object, | |
1285 Lisp_Object, Lisp_Object)); | |
1286 | |
1287 /* We sort fonts by scoring each of them against a specified | |
1288 font-spec. The score value is 32 bit (`unsigned'), and the smaller | |
1289 the value is, the closer the font is to the font-spec. | |
1290 | |
1291 Each 1-bit in the highest 4 bits of the score is used for atomic | |
1292 properties FOUNDRY, FAMILY, ADSTYLE, and REGISTRY. | |
1293 | |
1294 Each 7-bit in the lowest 28 bits are used for numeric properties | |
1295 WEIGHT, SLANT, WIDTH, and SIZE. */ | |
1296 | |
1297 /* How many bits to shift to store the difference value of each font | |
1298 property in a score. */ | |
1299 static int sort_shift_bits[FONT_SIZE_INDEX + 1]; | |
1300 | |
1301 /* Score font-entity ENTITY against font-spec SPEC. The return value | |
1302 indicates how different ENTITY is compared with SPEC. */ | |
1303 | |
1304 static unsigned | |
1305 font_score (entity, spec) | |
1306 Lisp_Object entity, spec; | |
1307 { | |
1308 unsigned score = 0; | |
1309 int i; | |
1310 /* Score atomic fields. Maximum difference is 1. */ | |
1311 for (i = FONT_FOUNDRY_INDEX; i <= FONT_REGISTRY_INDEX; i++) | |
1312 { | |
1313 Lisp_Object val = AREF (spec, i); | |
1314 | |
1315 if (! NILP (val) | |
1316 && ! EQ (val, AREF (entity, i))) | |
1317 score |= 1 << sort_shift_bits[i]; | |
1318 } | |
1319 | |
1320 /* Score numeric fields. Maximum difference is 127. */ | |
1321 for (i = FONT_WEIGHT_INDEX; i <= FONT_SIZE_INDEX; i++) | |
1322 { | |
1323 Lisp_Object spec_val = AREF (spec, i); | |
1324 Lisp_Object entity_val = AREF (entity, i); | |
1325 | |
1326 if (! NILP (spec_val) && ! EQ (spec_val, entity_val)) | |
1327 { | |
1328 if (! INTEGERP (entity_val)) | |
1329 score |= 127 << sort_shift_bits[i]; | |
1330 else if (i < FONT_SIZE_INDEX | |
1331 || XINT (entity_val) != 0) | |
1332 { | |
1333 int diff = XINT (entity_val) - XINT (spec_val); | |
1334 | |
1335 if (diff < 0) | |
1336 diff = - diff; | |
1337 score |= min (diff, 127) << sort_shift_bits[i]; | |
1338 } | |
1339 } | |
1340 } | |
1341 | |
1342 return score; | |
1343 } | |
1344 | |
1345 | |
1346 /* The comparison function for qsort. */ | |
1347 | |
1348 static int | |
1349 font_compare (d1, d2) | |
1350 const void *d1, *d2; | |
1351 { | |
1352 return (*(unsigned *) d1 < *(unsigned *) d2 | |
1353 ? -1 : *(unsigned *) d1 > *(unsigned *) d2); | |
1354 } | |
1355 | |
1356 | |
1357 /* The structure for elements being sorted by qsort. */ | |
1358 struct font_sort_data | |
1359 { | |
1360 unsigned score; | |
1361 Lisp_Object entity; | |
1362 }; | |
1363 | |
1364 | |
1365 /* Sort font-entities in vector VEC by closeness to font-spec PREFER. | |
1366 If PREFER specifies a point-size, calculate the corresponding | |
1367 pixel-size from the Y-resolution of FRAME before sorting. If SPEC | |
1368 is not nil, it is a font-spec to get the font-entities in VEC. */ | |
1369 | |
1370 static Lisp_Object | |
1371 font_sort_entites (vec, prefer, frame, spec) | |
1372 Lisp_Object vec, prefer, frame, spec; | |
1373 { | |
1374 Lisp_Object size; | |
1375 int len, i; | |
1376 struct font_sort_data *data; | |
1377 int prefer_is_copy = 0; | |
1378 USE_SAFE_ALLOCA; | |
1379 | |
1380 len = ASIZE (vec); | |
1381 if (len <= 1) | |
1382 return vec; | |
1383 | |
1384 size = AREF (spec, FONT_SIZE_INDEX); | |
1385 if (FLOATP (size)) | |
1386 { | |
1387 double point_size = XFLOAT_DATA (size) * 10; | |
1388 int pixel_size = POINT_TO_PIXEL (point_size, XFRAME (frame)->resy); | |
1389 | |
1390 prefer = Fcopy_sequence (prefer); | |
1391 ASET (prefer, FONT_SIZE_INDEX, make_number (pixel_size)); | |
1392 prefer_is_copy = 1; | |
1393 } | |
1394 | |
1395 if (! NILP (spec)) | |
1396 { | |
1397 /* As it is assured that all fonts in VEC match with SPEC, we | |
1398 should ignore properties specified in SPEC. So, set the | |
1399 corresponding properties in PREFER nil. */ | |
1400 for (i = FONT_WEIGHT_INDEX; i <= FONT_SIZE_INDEX; i++) | |
1401 if (! NILP (AREF (spec, i)) && ! NILP (AREF (prefer, i))) | |
1402 break; | |
1403 if (i <= FONT_SIZE_INDEX) | |
1404 { | |
1405 if (! prefer_is_copy) | |
1406 prefer = Fcopy_sequence (prefer); | |
1407 for (; i <= FONT_SIZE_INDEX; i++) | |
1408 if (! NILP (AREF (spec, i)) && ! NILP (AREF (prefer, i))) | |
1409 ASET (prefer, i, Qnil); | |
1410 } | |
1411 } | |
1412 | |
1413 /* Scoring and sorting. */ | |
1414 SAFE_ALLOCA (data, struct font_sort_data *, (sizeof *data) * len); | |
1415 for (i = 0; i < len; i++) | |
1416 { | |
1417 data[i].entity = AREF (vec, i); | |
1418 data[i].score = font_score (data[i].entity, prefer); | |
1419 } | |
1420 qsort (data, len, sizeof *data, font_compare); | |
1421 for (i = 0; i < len; i++) | |
1422 ASET (vec, i, data[i].entity); | |
1423 SAFE_FREE (); | |
1424 | |
1425 return vec; | |
1426 } | |
1427 | |
1428 | |
1429 /* API of Font Service Layer. */ | |
1430 | |
1431 void | |
1432 font_update_sort_order (order) | |
1433 int *order; | |
1434 { | |
1435 int i, shift_bits = 21; | |
1436 | |
1437 for (i = 0; i < 4; i++, shift_bits -= 7) | |
1438 { | |
1439 int xlfd_idx = order[i]; | |
1440 | |
1441 if (xlfd_idx == XLFD_WEIGHT_INDEX) | |
1442 sort_shift_bits[FONT_WEIGHT_INDEX] = shift_bits; | |
1443 else if (xlfd_idx == XLFD_SLANT_INDEX) | |
1444 sort_shift_bits[FONT_SLANT_INDEX] = shift_bits; | |
1445 else if (xlfd_idx == XLFD_SWIDTH_INDEX) | |
1446 sort_shift_bits[FONT_WIDTH_INDEX] = shift_bits; | |
1447 else | |
1448 sort_shift_bits[FONT_SIZE_INDEX] = shift_bits; | |
1449 } | |
1450 } | |
1451 | |
1452 Lisp_Object | |
1453 font_symbolic_weight (font) | |
1454 Lisp_Object font; | |
1455 { | |
1456 Lisp_Object weight = AREF (font, FONT_WEIGHT_INDEX); | |
1457 | |
1458 if (INTEGERP (weight)) | |
1459 weight = prop_numeric_to_name (FONT_WEIGHT_INDEX, XINT (weight)); | |
1460 return weight; | |
1461 } | |
1462 | |
1463 Lisp_Object | |
1464 font_symbolic_slant (font) | |
1465 Lisp_Object font; | |
1466 { | |
1467 Lisp_Object slant = AREF (font, FONT_SLANT_INDEX); | |
1468 | |
1469 if (INTEGERP (slant)) | |
1470 slant = prop_numeric_to_name (FONT_SLANT_INDEX, XINT (slant)); | |
1471 return slant; | |
1472 } | |
1473 | |
1474 Lisp_Object | |
1475 font_symbolic_width (font) | |
1476 Lisp_Object font; | |
1477 { | |
1478 Lisp_Object width = AREF (font, FONT_WIDTH_INDEX); | |
1479 | |
1480 if (INTEGERP (width)) | |
1481 width = prop_numeric_to_name (FONT_WIDTH_INDEX, XINT (width)); | |
1482 return width; | |
1483 } | |
1484 | |
1485 Lisp_Object | |
1486 font_find_object (font) | |
1487 struct font *font; | |
1488 { | |
1489 Lisp_Object tail, elt; | |
1490 | |
1491 for (tail = AREF (font->entity, FONT_OBJLIST_INDEX); CONSP (tail); | |
1492 tail = XCDR (tail)) | |
1493 { | |
1494 elt = XCAR (tail); | |
1495 if (font == XSAVE_VALUE (elt)->pointer | |
1496 && XSAVE_VALUE (elt)->integer > 0) | |
1497 return elt; | |
1498 } | |
1499 abort (); | |
1500 return Qnil; | |
1501 } | |
1502 | |
1503 static Lisp_Object scratch_font_spec, scratch_font_prefer; | |
1504 | |
1505 /* Return a vector of font-entities matching with SPEC on frame F. */ | |
1506 | |
1507 static Lisp_Object | |
1508 font_list_entities (frame, spec) | |
1509 Lisp_Object frame, spec; | |
1510 { | |
1511 FRAME_PTR f = XFRAME (frame); | |
1512 struct font_driver_list *driver_list = f->font_driver_list; | |
1513 Lisp_Object ftype, family, alternate_familes; | |
1514 Lisp_Object *vec = alloca (sizeof (Lisp_Object) * num_font_drivers); | |
1515 int i; | |
1516 | |
1517 if (! vec) | |
1518 return null_vector; | |
1519 | |
1520 family = AREF (spec, FONT_FAMILY_INDEX); | |
1521 if (NILP (family)) | |
1522 alternate_familes = Qnil; | |
1523 else | |
1524 { | |
1525 if (NILP (font_family_alist) | |
1526 && !NILP (Vface_alternative_font_family_alist)) | |
1527 build_font_family_alist (); | |
1528 alternate_familes = assq_no_quit (family, font_family_alist); | |
1529 if (! NILP (alternate_familes)) | |
1530 alternate_familes = XCDR (alternate_familes); | |
1531 } | |
1532 xassert (ASIZE (spec) == FONT_SPEC_MAX); | |
1533 ftype = AREF (spec, FONT_TYPE_INDEX); | |
1534 | |
1535 for (i = 0; driver_list; driver_list = driver_list->next) | |
1536 if (NILP (ftype) || EQ (driver_list->driver->type, ftype)) | |
1537 { | |
1538 Lisp_Object cache = driver_list->driver->get_cache (frame); | |
1539 Lisp_Object tail = alternate_familes; | |
1540 Lisp_Object val; | |
1541 | |
1542 xassert (CONSP (cache)); | |
1543 ASET (spec, FONT_TYPE_INDEX, driver_list->driver->type); | |
1544 ASET (spec, FONT_FAMILY_INDEX, family); | |
1545 | |
1546 while (1) | |
1547 { | |
1548 val = assoc_no_quit (spec, XCDR (cache)); | |
1549 if (CONSP (val)) | |
1550 val = XCDR (val); | |
1551 else | |
1552 { | |
1553 val = driver_list->driver->list (frame, spec); | |
1554 if (VECTORP (val)) | |
1555 XSETCDR (cache, Fcons (Fcons (Fcopy_sequence (spec), val), | |
1556 XCDR (cache))); | |
1557 } | |
1558 if (VECTORP (val) && ASIZE (val) > 0) | |
1559 { | |
1560 vec[i++] = val; | |
1561 break; | |
1562 } | |
1563 if (NILP (tail)) | |
1564 break; | |
1565 ASET (spec, FONT_FAMILY_INDEX, XCAR (tail)); | |
1566 tail = XCDR (tail); | |
1567 } | |
1568 } | |
1569 ASET (spec, FONT_TYPE_INDEX, ftype); | |
1570 ASET (spec, FONT_FAMILY_INDEX, family); | |
1571 return (i > 0 ? Fvconcat (i, vec) : null_vector); | |
1572 } | |
1573 | |
1574 static int num_fonts; | |
1575 | |
1576 static Lisp_Object | |
1577 font_open_entity (f, entity, pixel_size) | |
1578 FRAME_PTR f; | |
1579 Lisp_Object entity; | |
1580 int pixel_size; | |
1581 { | |
1582 struct font_driver_list *driver_list; | |
1583 Lisp_Object objlist, size, val; | |
1584 struct font *font; | |
1585 | |
1586 size = AREF (entity, FONT_SIZE_INDEX); | |
1587 xassert (NATNUMP (size)); | |
1588 if (XINT (size) != 0) | |
1589 pixel_size = XINT (size); | |
1590 | |
1591 for (objlist = AREF (entity, FONT_OBJLIST_INDEX); CONSP (objlist); | |
1592 objlist = XCDR (objlist)) | |
1593 { | |
1594 font = XSAVE_VALUE (XCAR (objlist))->pointer; | |
1595 if (font->pixel_size == pixel_size) | |
1596 { | |
1597 XSAVE_VALUE (XCAR (objlist))->integer++; | |
1598 return XCAR (objlist); | |
1599 } | |
1600 } | |
1601 | |
1602 xassert (FONT_ENTITY_P (entity)); | |
1603 val = AREF (entity, FONT_TYPE_INDEX); | |
1604 for (driver_list = f->font_driver_list; | |
1605 driver_list && ! EQ (driver_list->driver->type, val); | |
1606 driver_list = driver_list->next); | |
1607 if (! driver_list) | |
1608 return Qnil; | |
1609 | |
1610 font = driver_list->driver->open (f, entity, pixel_size); | |
1611 if (! font) | |
1612 return Qnil; | |
1613 val = make_save_value (font, 1); | |
1614 ASET (entity, FONT_OBJLIST_INDEX, | |
1615 Fcons (val, AREF (entity, FONT_OBJLIST_INDEX))); | |
1616 num_fonts++; | |
1617 return val; | |
1618 } | |
1619 | |
1620 void | |
1621 font_close_object (f, font_object) | |
1622 FRAME_PTR f; | |
1623 Lisp_Object font_object; | |
1624 { | |
1625 struct font *font; | |
1626 Lisp_Object objlist = AREF (font->entity, FONT_OBJLIST_INDEX); | |
1627 Lisp_Object tail, prev = Qnil; | |
1628 | |
1629 for (prev = Qnil, tail = objlist; CONSP (tail); | |
1630 prev = tail, tail = XCDR (tail)) | |
1631 if (EQ (font_object, XCAR (tail))) | |
1632 { | |
1633 struct Lisp_Save_Value *p = XSAVE_VALUE (font_object); | |
1634 | |
1635 xassert (p->integer > 0); | |
1636 p->integer--; | |
1637 if (p->integer == 0) | |
1638 { | |
1639 if (font->driver->close) | |
1640 font->driver->close (f, p->pointer); | |
1641 p->pointer = NULL; | |
1642 if (NILP (prev)) | |
1643 ASET (font->entity, FONT_OBJLIST_INDEX, XCDR (objlist)); | |
1644 else | |
1645 XSETCDR (prev, XCDR (objlist)); | |
1646 } | |
1647 break; | |
1648 } | |
1649 } | |
1650 | |
1651 int | |
1652 font_has_char (f, font_entity, c) | |
1653 FRAME_PTR f; | |
1654 Lisp_Object font_entity; | |
1655 int c; | |
1656 { | |
1657 Lisp_Object type = AREF (font_entity, FONT_TYPE_INDEX); | |
1658 struct font_driver_list *driver_list; | |
1659 | |
1660 for (driver_list = f->font_driver_list; | |
1661 driver_list && ! EQ (driver_list->driver->type, type); | |
1662 driver_list = driver_list->next); | |
1663 if (! driver_list) | |
1664 return -1; | |
1665 return driver_list->driver->has_char (font_entity, c); | |
1666 } | |
1667 | |
1668 unsigned | |
1669 font_encode_char (font_object, c) | |
1670 Lisp_Object font_object; | |
1671 int c; | |
1672 { | |
1673 struct font *font = XSAVE_VALUE (font_object)->pointer; | |
1674 | |
1675 return font->driver->encode_char (font, c); | |
1676 } | |
1677 | |
1678 char * | |
1679 font_get_name (font_object) | |
1680 Lisp_Object font_object; | |
1681 { | |
1682 struct font *font = XSAVE_VALUE (font_object)->pointer; | |
1683 | |
1684 return (font->font.full_name ? font->font.full_name | |
1685 : font->file_name ? font->file_name | |
1686 : ""); | |
1687 } | |
1688 | |
1689 Lisp_Object | |
1690 font_get_frame (font) | |
1691 Lisp_Object font; | |
1692 { | |
1693 if (FONT_OBJECT_P (font)) | |
1694 font = ((struct font *) XSAVE_VALUE (font)->pointer)->entity; | |
1695 xassert (FONT_ENTITY_P (font)); | |
1696 return AREF (font, FONT_FRAME_INDEX); | |
1697 } | |
1698 | |
1699 extern Lisp_Object Qunspecified, Qignore_defface; | |
1700 | |
1701 Lisp_Object | |
1702 font_find_for_lface (f, lface, spec) | |
1703 FRAME_PTR f; | |
1704 Lisp_Object *lface; | |
1705 Lisp_Object spec; | |
1706 { | |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1707 Lisp_Object attrs[LFACE_FONT_INDEX + 1]; |
90400 | 1708 Lisp_Object frame, val, entities; |
1709 int i; | |
1710 unsigned char try_unspecified[FONT_SPEC_MAX]; | |
1711 | |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1712 for (i = 0; i <= LFACE_FONT_INDEX; i++) |
90400 | 1713 { |
1714 val = lface[i]; | |
1715 if (EQ (val, Qunspecified) || EQ (val, Qignore_defface)) | |
1716 val = Qnil; | |
1717 attrs[i] = val; | |
1718 } | |
1719 if (NILP (spec)) | |
1720 for (i = 0; i < FONT_SPEC_MAX; i++) | |
1721 ASET (scratch_font_spec, i, Qnil); | |
1722 else | |
1723 for (i = 0; i < FONT_SPEC_MAX; i++) | |
1724 ASET (scratch_font_spec, i, AREF (spec, i)); | |
1725 | |
1726 /* If SPEC doesn't specify a specific property, it can be tried with | |
1727 nil even if FACE specifies it. */ | |
1728 for (i = FONT_FOUNDRY_INDEX; i <= FONT_SIZE_INDEX; i++) | |
1729 try_unspecified[i] = NILP (AREF (scratch_font_spec, i)); | |
1730 | |
90448
15dda5f83c27
(font_find_for_lface): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
90439
diff
changeset
|
1731 if (NILP (spec) && STRINGP (attrs[LFACE_FONT_INDEX])) |
90400 | 1732 font_merge_old_spec (attrs[LFACE_FONT_INDEX], Qnil, Qnil, |
1733 scratch_font_spec); | |
1734 if (NILP (AREF (scratch_font_spec, FONT_FAMILY_INDEX)) | |
1735 && ! NILP (attrs[LFACE_FAMILY_INDEX])) | |
1736 font_merge_old_spec (Qnil, attrs[LFACE_FAMILY_INDEX], Qnil, | |
1737 scratch_font_spec); | |
1738 if (NILP (AREF (scratch_font_spec, FONT_REGISTRY_INDEX))) | |
1739 { | |
1740 ASET (scratch_font_spec, FONT_REGISTRY_INDEX, intern ("iso8859-1")); | |
1741 try_unspecified[FONT_REGISTRY_INDEX] = 0; | |
1742 } | |
1743 | |
1744 for (i = FONT_FAMILY_INDEX; i <= FONT_SIZE_INDEX; i++) | |
1745 if (try_unspecified[i] | |
1746 && NILP (AREF (scratch_font_spec, i))) | |
1747 try_unspecified[i] = 0; | |
1748 | |
1749 XSETFRAME (frame, f); | |
1750 entities = font_list_entities (frame, scratch_font_spec); | |
1751 while (ASIZE (entities) == 0) | |
1752 { | |
1753 if (try_unspecified[FONT_WEIGHT_INDEX] | |
1754 || try_unspecified[FONT_SLANT_INDEX] | |
1755 || try_unspecified[FONT_WIDTH_INDEX] | |
1756 || try_unspecified[FONT_SIZE_INDEX]) | |
1757 { | |
1758 for (i = FONT_WEIGHT_INDEX; i <= FONT_SIZE_INDEX; i++) | |
1759 { | |
1760 try_unspecified[i] = 0; | |
1761 ASET (scratch_font_spec, i, Qnil); | |
1762 } | |
1763 entities = font_list_entities (frame, scratch_font_spec); | |
1764 } | |
1765 else if (try_unspecified[FONT_FOUNDRY_INDEX]) | |
1766 { | |
1767 try_unspecified[FONT_FOUNDRY_INDEX] = 0; | |
1768 ASET (scratch_font_spec, FONT_FOUNDRY_INDEX, Qnil); | |
1769 entities = font_list_entities (frame, scratch_font_spec); | |
1770 } | |
1771 else if (try_unspecified[FONT_FAMILY_INDEX]) | |
1772 { | |
1773 try_unspecified[FONT_FAMILY_INDEX] = 0; | |
1774 ASET (scratch_font_spec, FONT_FAMILY_INDEX, Qnil); | |
1775 entities = font_list_entities (frame, scratch_font_spec); | |
1776 } | |
1777 else | |
1778 return Qnil; | |
1779 } | |
1780 | |
1781 if (ASIZE (entities) > 1) | |
1782 { | |
1783 Lisp_Object prefer = scratch_font_prefer; | |
1784 | |
1785 for (i = 0; i < FONT_WEIGHT_INDEX; i++) | |
1786 ASET (prefer, i, Qnil); | |
1787 if (! NILP (attrs[LFACE_WEIGHT_INDEX])) | |
1788 ASET (prefer, FONT_WEIGHT_INDEX, | |
1789 font_prop_validate_style (FONT_WEIGHT_INDEX, | |
1790 attrs[LFACE_WEIGHT_INDEX])); | |
1791 if (! NILP (attrs[LFACE_SLANT_INDEX])) | |
1792 ASET (prefer, FONT_SLANT_INDEX, | |
1793 font_prop_validate_style (FONT_SLANT_INDEX, | |
1794 attrs[LFACE_SLANT_INDEX])); | |
1795 if (! NILP (attrs[LFACE_SWIDTH_INDEX])) | |
1796 ASET (prefer, FONT_WIDTH_INDEX, | |
1797 font_prop_validate_style (FONT_WIDTH_INDEX, | |
1798 attrs[LFACE_SWIDTH_INDEX])); | |
1799 if (! NILP (attrs[LFACE_HEIGHT_INDEX])) | |
1800 { | |
1801 int size; | |
1802 | |
1803 val = attrs[LFACE_HEIGHT_INDEX]; | |
1804 size = POINT_TO_PIXEL (XINT (val), f->resy); | |
1805 ASET (prefer, FONT_SIZE_INDEX, make_number (size)); | |
1806 } | |
1807 font_sort_entites (entities, prefer, frame, spec); | |
1808 } | |
1809 | |
1810 return AREF (entities, 0); | |
1811 } | |
1812 | |
1813 Lisp_Object | |
1814 font_open_for_lface (f, lface, entity) | |
1815 FRAME_PTR f; | |
1816 Lisp_Object *lface; | |
1817 Lisp_Object entity; | |
1818 { | |
1819 int pt = XINT (lface[LFACE_HEIGHT_INDEX]); | |
1820 int size = POINT_TO_PIXEL (pt, f->resy); | |
1821 | |
1822 return font_open_entity (f, entity, size); | |
1823 } | |
1824 | |
1825 void | |
1826 font_load_for_face (f, face) | |
1827 FRAME_PTR f; | |
1828 struct face *face; | |
1829 { | |
1830 Lisp_Object entity; | |
1831 | |
1832 face->font_info_id = -1; | |
1833 face->font_info = NULL; | |
1834 face->font = NULL; | |
1835 face->font_name = NULL; | |
1836 | |
1837 entity = font_find_for_lface (f, face->lface, Qnil); | |
1838 if (! NILP (entity)) | |
1839 { | |
1840 Lisp_Object font_object = font_open_for_lface (f, face->lface, entity); | |
1841 | |
1842 if (! NILP (font_object)) | |
1843 { | |
1844 struct font *font = XSAVE_VALUE (font_object)->pointer; | |
1845 | |
1846 face->font = font->font.font; | |
1847 face->font_info = (struct font_info *) font; | |
1848 face->font_info_id = 0; | |
1849 face->font_name = font->font.full_name; | |
1850 } | |
1851 } | |
1852 if (! face->font) | |
1853 add_to_log ("Unable to load font for a face%s", null_string, Qnil); | |
1854 } | |
1855 | |
1856 void | |
1857 font_prepare_for_face (f, face) | |
1858 FRAME_PTR f; | |
1859 struct face *face; | |
1860 { | |
1861 struct font *font = (struct font *) face->font_info; | |
1862 | |
1863 if (font->driver->prepare_face) | |
1864 font->driver->prepare_face (f, face); | |
1865 } | |
1866 | |
1867 void | |
1868 font_done_for_face (f, face) | |
1869 FRAME_PTR f; | |
1870 struct face *face; | |
1871 { | |
1872 struct font *font = (struct font *) face->font_info; | |
1873 | |
1874 if (font->driver->done_face) | |
1875 font->driver->done_face (f, face); | |
1876 face->extra = NULL; | |
1877 } | |
1878 | |
1879 Lisp_Object | |
1880 font_open_by_name (f, name) | |
1881 FRAME_PTR f; | |
1882 char *name; | |
1883 { | |
1884 Lisp_Object spec = Ffont_spec (0, NULL); | |
1885 Lisp_Object frame; | |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1886 struct font_driver_list *dlist; |
90400 | 1887 |
1888 XSETFRAME (frame, f); | |
1889 ASET (spec, FONT_EXTRA_INDEX, | |
1890 Fcons (Fcons (QCname, make_unibyte_string (name, strlen (name))), | |
1891 Qnil)); | |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1892 |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1893 for (dlist = f->font_driver_list; dlist; dlist = dlist->next) |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1894 if (dlist->driver->parse_name |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1895 && dlist->driver->parse_name (f, name, spec) >= 0) |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1896 { |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1897 Lisp_Object entities = font_list_entities (frame, spec); |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1898 Lisp_Object font_object; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1899 int pixel_size; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1900 |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1901 if (ASIZE (entities) == 0) |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1902 continue; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1903 pixel_size = XINT (AREF (AREF (entities, 0), FONT_SIZE_INDEX)); |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1904 if (pixel_size == 0 && INTEGERP (AREF (spec, FONT_SIZE_INDEX))) |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1905 pixel_size = XINT (AREF (spec, FONT_SIZE_INDEX)); |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1906 font_object = font_open_entity (f, AREF (entities, 0), pixel_size); |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1907 if (! NILP (font_object)) |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1908 return font_object; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1909 } |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1910 return Qnil; |
90400 | 1911 } |
1912 | |
1913 | |
1914 /* Register font-driver DRIVER. This function is used in two ways. | |
1915 | |
1916 The first is with frame F non-NULL. In this case, DRIVER is | |
1917 registered to be used for drawing characters on F. All frame | |
1918 creaters (e.g. Fx_create_frame) must call this function at least | |
1919 once with an available font-driver. | |
1920 | |
1921 The second is with frame F NULL. In this case, DRIVER is globally | |
1922 registered in the variable `font_driver_list'. All font-driver | |
1923 implementations must call this function in its syms_of_XXXX | |
1924 (e.g. syms_of_xfont). */ | |
1925 | |
1926 void | |
1927 register_font_driver (driver, f) | |
1928 struct font_driver *driver; | |
1929 FRAME_PTR f; | |
1930 { | |
1931 struct font_driver_list *root = f ? f->font_driver_list : font_driver_list; | |
1932 struct font_driver_list *prev, *list; | |
1933 | |
1934 if (f && ! driver->draw) | |
1935 error ("Unsable font driver for a frame: %s", | |
1936 SDATA (SYMBOL_NAME (driver->type))); | |
1937 | |
1938 for (prev = NULL, list = root; list; prev = list, list = list->next) | |
1939 if (list->driver->type == driver->type) | |
1940 error ("Duplicated font driver: %s", SDATA (SYMBOL_NAME (driver->type))); | |
1941 | |
1942 list = malloc (sizeof (struct font_driver_list)); | |
1943 list->driver = driver; | |
1944 list->next = NULL; | |
1945 if (prev) | |
1946 prev->next = list; | |
1947 else if (f) | |
1948 f->font_driver_list = list; | |
1949 else | |
1950 font_driver_list = list; | |
1951 num_font_drivers++; | |
1952 } | |
1953 | |
1954 /* Free font-driver list on frame F. It doesn't free font-drivers | |
1955 themselves. */ | |
1956 | |
1957 void | |
1958 free_font_driver_list (f) | |
1959 FRAME_PTR f; | |
1960 { | |
1961 while (f->font_driver_list) | |
1962 { | |
1963 struct font_driver_list *next = f->font_driver_list->next; | |
1964 | |
1965 free (f->font_driver_list); | |
1966 f->font_driver_list = next; | |
1967 } | |
1968 } | |
1969 | |
1970 | |
1971 /* Lisp API */ | |
1972 | |
1973 DEFUN ("fontp", Ffontp, Sfontp, 1, 1, 0, | |
1974 doc: /* Return t if object is a font-spec or font-entity. */) | |
1975 (object) | |
1976 Lisp_Object object; | |
1977 { | |
1978 return (FONTP (object) ? Qt : Qnil); | |
1979 } | |
1980 | |
1981 DEFUN ("font-spec", Ffont_spec, Sfont_spec, 0, MANY, 0, | |
1982 doc: /* Return a newly created font-spec with specified arguments as properties. | |
1983 usage: (font-spec &rest properties) */) | |
1984 (nargs, args) | |
1985 int nargs; | |
1986 Lisp_Object *args; | |
1987 { | |
1988 Lisp_Object spec = Fmake_vector (make_number (FONT_SPEC_MAX), Qnil); | |
1989 Lisp_Object extra = Qnil; | |
1990 int i; | |
1991 | |
1992 for (i = 0; i < nargs; i += 2) | |
1993 { | |
1994 enum font_property_index prop; | |
1995 Lisp_Object key = args[i], val = args[i + 1]; | |
1996 | |
1997 prop = check_font_prop_name (key); | |
1998 if (prop < FONT_EXTRA_INDEX) | |
1999 ASET (spec, prop, (font_property_table[prop].validater) (prop, val)); | |
2000 else | |
2001 extra = Fcons (Fcons (key, val), extra); | |
2002 } | |
2003 ASET (spec, FONT_EXTRA_INDEX, extra); | |
2004 return spec; | |
2005 } | |
2006 | |
2007 | |
2008 DEFUN ("font-get", Ffont_get, Sfont_get, 2, 2, 0, | |
2009 doc: /* Return the value of FONT's PROP property. | |
2010 FONT may be a font-spec or font-entity. | |
2011 If FONT is font-entity and PROP is :extra, always nil is returned. */) | |
2012 (font, prop) | |
2013 Lisp_Object font, prop; | |
2014 { | |
2015 enum font_property_index idx; | |
2016 | |
2017 CHECK_FONT (font); | |
2018 idx = check_font_prop_name (prop); | |
2019 if (idx < FONT_EXTRA_INDEX) | |
2020 return AREF (font, idx); | |
2021 if (FONT_ENTITY_P (font)) | |
2022 return Qnil; | |
2023 return Fcdr (Fassoc (AREF (font, FONT_EXTRA_INDEX), prop)); | |
2024 } | |
2025 | |
2026 | |
2027 DEFUN ("font-put", Ffont_put, Sfont_put, 3, 3, 0, | |
2028 doc: /* Set one property of FONT-SPEC: give property PROP value VALUE. */) | |
2029 (font_spec, prop, val) | |
2030 Lisp_Object font_spec, prop, val; | |
2031 { | |
2032 enum font_property_index idx; | |
2033 Lisp_Object extra, slot; | |
2034 | |
2035 CHECK_FONT_SPEC (font_spec); | |
2036 idx = check_font_prop_name (prop); | |
2037 if (idx < FONT_EXTRA_INDEX) | |
2038 return ASET (font_spec, idx, val); | |
2039 extra = AREF (font_spec, FONT_EXTRA_INDEX); | |
2040 slot = Fassoc (extra, prop); | |
2041 if (NILP (slot)) | |
2042 extra = Fcons (Fcons (prop, val), extra); | |
2043 else | |
2044 Fsetcdr (slot, val); | |
2045 return val; | |
2046 } | |
2047 | |
2048 DEFUN ("list-fonts", Flist_fonts, Slist_fonts, 1, 4, 0, | |
2049 doc: /* List available fonts matching FONT-SPEC on the current frame. | |
2050 Optional 2nd argument FRAME specifies the target frame. | |
2051 Optional 3rd argument NUM, if non-nil, limits the number of returned fonts. | |
2052 Optional 4th argument PREFER, if non-nil, is a font-spec to sort fonts | |
2053 by closeness to PREFER. */) | |
2054 (font_spec, frame, num, prefer) | |
2055 Lisp_Object font_spec, frame, num, prefer; | |
2056 { | |
2057 Lisp_Object vec, list, tail; | |
2058 int n = 0, i, len; | |
2059 | |
2060 if (NILP (frame)) | |
2061 frame = selected_frame; | |
2062 CHECK_LIVE_FRAME (frame); | |
2063 CHECK_VALIDATE_FONT_SPEC (font_spec); | |
2064 if (! NILP (num)) | |
2065 { | |
2066 CHECK_NUMBER (num); | |
2067 n = XINT (num); | |
2068 if (n <= 0) | |
2069 return Qnil; | |
2070 } | |
2071 if (! NILP (prefer)) | |
2072 CHECK_FONT (prefer); | |
2073 | |
2074 vec = font_list_entities (frame, font_spec); | |
2075 len = ASIZE (vec); | |
2076 if (len == 0) | |
2077 return Qnil; | |
2078 if (len == 1) | |
2079 return Fcons (AREF (vec, 0), Qnil); | |
2080 | |
2081 if (! NILP (prefer)) | |
2082 vec = font_sort_entites (vec, prefer, frame, font_spec); | |
2083 | |
2084 list = tail = Fcons (AREF (vec, 0), Qnil); | |
2085 if (n == 0 || n > len) | |
2086 n = len; | |
2087 for (i = 1; i < n; i++) | |
2088 { | |
2089 Lisp_Object val = Fcons (AREF (vec, i), Qnil); | |
2090 | |
2091 XSETCDR (tail, val); | |
2092 tail = val; | |
2093 } | |
2094 return list; | |
2095 } | |
2096 | |
2097 DEFUN ("list-families", Flist_families, Slist_families, 0, 1, 0, | |
2098 doc: /* List available font families on the current frame. | |
2099 Optional 2nd argument FRAME specifies the target frame. */) | |
2100 (frame) | |
2101 Lisp_Object frame; | |
2102 { | |
2103 FRAME_PTR f; | |
2104 struct font_driver_list *driver_list; | |
2105 Lisp_Object list; | |
2106 | |
2107 if (NILP (frame)) | |
2108 frame = selected_frame; | |
2109 CHECK_LIVE_FRAME (frame); | |
2110 f = XFRAME (frame); | |
2111 list = Qnil; | |
2112 for (driver_list = f->font_driver_list; driver_list; | |
2113 driver_list = driver_list->next) | |
2114 if (driver_list->driver->list_family) | |
2115 { | |
2116 Lisp_Object val = driver_list->driver->list_family (frame); | |
2117 | |
2118 if (NILP (list)) | |
2119 list = val; | |
2120 else | |
2121 { | |
2122 Lisp_Object tail = list; | |
2123 | |
2124 for (; CONSP (val); val = XCDR (val)) | |
2125 if (NILP (Fmemq (XCAR (val), tail))) | |
2126 list = Fcons (XCAR (val), list); | |
2127 } | |
2128 } | |
2129 return list; | |
2130 } | |
2131 | |
2132 DEFUN ("find-font", Ffind_font, Sfind_font, 1, 2, 0, | |
2133 doc: /* Return a font-entity matching with FONT-SPEC on the current frame. | |
2134 Optional 2nd argument FRAME, if non-nil, specifies the target frame. */) | |
2135 (font_spec, frame) | |
2136 Lisp_Object font_spec, frame; | |
2137 { | |
2138 Lisp_Object val = Flist_fonts (font_spec, frame, make_number (1), Qnil); | |
2139 | |
2140 if (CONSP (val)) | |
2141 val = XCAR (val); | |
2142 return val; | |
2143 } | |
2144 | |
2145 DEFUN ("font-xlfd-name", Ffont_xlfd_name, Sfont_xlfd_name, 1, 1, 0, | |
2146 doc: /* Return XLFD name of FONT. | |
2147 FONT is a font-spec, font-entity, or font-object. | |
2148 If the name is too long for XLFD (maximum 255 chars), return nil. */) | |
2149 (font) | |
2150 Lisp_Object font; | |
2151 { | |
2152 char name[256]; | |
2153 int pixel_size = 0; | |
2154 | |
2155 if (FONT_SPEC_P (font)) | |
2156 CHECK_VALIDATE_FONT_SPEC (font); | |
2157 else if (FONT_ENTITY_P (font)) | |
2158 CHECK_FONT (font); | |
2159 else | |
2160 { | |
2161 struct font *fontp; | |
2162 | |
2163 CHECK_FONT_GET_OBJECT (font, fontp); | |
2164 font = fontp->entity; | |
2165 pixel_size = fontp->pixel_size; | |
2166 } | |
2167 | |
2168 if (font_unparse_xlfd (font, pixel_size, name, 256) < 0) | |
2169 return Qnil; | |
2170 return build_string (name); | |
2171 } | |
2172 | |
2173 DEFUN ("clear-font-cache", Fclear_font_cache, Sclear_font_cache, 0, 0, 0, | |
2174 doc: /* Clear font cache. */) | |
2175 () | |
2176 { | |
2177 Lisp_Object list, frame; | |
2178 | |
2179 FOR_EACH_FRAME (list, frame) | |
2180 { | |
2181 FRAME_PTR f = XFRAME (frame); | |
2182 struct font_driver_list *driver_list = f->font_driver_list; | |
2183 | |
2184 for (; driver_list; driver_list = driver_list->next) | |
2185 { | |
2186 Lisp_Object cache = driver_list->driver->get_cache (frame); | |
2187 Lisp_Object tail, elt; | |
2188 | |
2189 for (tail = XCDR (cache); CONSP (tail); tail = XCDR (tail)) | |
2190 { | |
2191 elt = XCAR (tail); | |
2192 if (CONSP (elt) && FONT_SPEC_P (XCAR (elt))) | |
2193 { | |
2194 Lisp_Object vec = XCDR (elt); | |
2195 int i; | |
2196 | |
2197 for (i = 0; i < ASIZE (vec); i++) | |
2198 { | |
2199 Lisp_Object entity = AREF (vec, i); | |
2200 Lisp_Object objlist = AREF (entity, FONT_OBJLIST_INDEX); | |
2201 | |
2202 for (; CONSP (objlist); objlist = XCDR (objlist)) | |
2203 { | |
2204 Lisp_Object val = XCAR (objlist); | |
2205 struct Lisp_Save_Value *p = XSAVE_VALUE (val); | |
2206 struct font *font = p->pointer; | |
2207 | |
2208 xassert (font | |
2209 && driver_list->driver == font->driver); | |
2210 driver_list->driver->close (f, font); | |
2211 p->pointer = NULL; | |
2212 p->integer = 0; | |
2213 } | |
2214 if (driver_list->driver->free_entity) | |
2215 driver_list->driver->free_entity (entity); | |
2216 } | |
2217 } | |
2218 } | |
2219 XSETCDR (cache, Qnil); | |
2220 } | |
2221 } | |
2222 | |
2223 return Qnil; | |
2224 } | |
2225 | |
2226 DEFUN ("internal-set-font-style-table", Finternal_set_font_style_table, | |
2227 Sinternal_set_font_style_table, 2, 2, 0, | |
2228 doc: /* Set font style table for PROP to TABLE. | |
2229 PROP must be `:weight', `:slant', or `:width'. | |
2230 TABLE must be an alist of symbols vs the corresponding numeric values | |
2231 sorted by numeric values. */) | |
2232 (prop, table) | |
2233 Lisp_Object prop, table; | |
2234 { | |
2235 int table_index; | |
2236 int numeric; | |
2237 Lisp_Object tail, val; | |
2238 | |
2239 CHECK_SYMBOL (prop); | |
2240 table_index = (EQ (prop, QCweight) ? 0 | |
2241 : EQ (prop, QCslant) ? 1 | |
2242 : EQ (prop, QCwidth) ? 2 | |
2243 : 3); | |
2244 if (table_index >= ASIZE (font_style_table)) | |
2245 error ("Invalid font style property: %s", SDATA (SYMBOL_NAME (prop))); | |
2246 table = Fcopy_sequence (table); | |
2247 numeric = -1; | |
2248 for (tail = table; ! NILP (tail); tail = Fcdr (tail)) | |
2249 { | |
2250 prop = Fcar (Fcar (tail)); | |
2251 val = Fcdr (Fcar (tail)); | |
2252 CHECK_SYMBOL (prop); | |
2253 CHECK_NATNUM (val); | |
2254 if (numeric > XINT (val)) | |
2255 error ("Numeric values not sorted for %s", SDATA (SYMBOL_NAME (prop))); | |
2256 numeric = XINT (val); | |
2257 XSETCAR (tail, Fcons (prop, val)); | |
2258 } | |
2259 ASET (font_style_table, table_index, table); | |
2260 return Qnil; | |
2261 } | |
2262 | |
2263 DEFUN ("font-make-gstring", Ffont_make_gstring, Sfont_make_gstring, 2, 2, 0, | |
2264 doc: /* Return a newly created glyph-string for FONT-OBJECT with NUM glyphs. | |
2265 FONT-OBJECT may be nil if it is not yet known. */) | |
2266 (font_object, num) | |
2267 Lisp_Object font_object, num; | |
2268 { | |
2269 Lisp_Object gstring, g; | |
2270 int len; | |
2271 int i; | |
2272 | |
2273 if (! NILP (font_object)) | |
2274 CHECK_FONT_OBJECT (font_object); | |
2275 CHECK_NATNUM (num); | |
2276 | |
2277 len = XINT (num) + 1; | |
2278 gstring = Fmake_vector (make_number (len), Qnil); | |
2279 g = Fmake_vector (make_number (6), Qnil); | |
2280 ASET (g, 0, font_object); | |
2281 ASET (gstring, 0, g); | |
2282 for (i = 1; i < len; i++) | |
2283 ASET (gstring, i, Fmake_vector (make_number (8), make_number (0))); | |
2284 return gstring; | |
2285 } | |
2286 | |
2287 DEFUN ("font-fill-gstring", Ffont_fill_gstring, Sfont_fill_gstring, 4, 5, 0, | |
2288 doc: /* Fillin glyph-string GSTRING by characters for FONT-OBJECT. | |
2289 START and END specifies the region to extract characters. | |
2290 If optional 3rd argument OBJECT is non-nil, it is a buffer or a string from | |
2291 where to extract characters. | |
2292 FONT-OBJECT may be nil if GSTRING already already contains one. */) | |
2293 (gstring, font_object, start, end, object) | |
2294 Lisp_Object gstring, font_object, start, end, object; | |
2295 { | |
2296 int len, i, c; | |
2297 unsigned code; | |
2298 struct font *font; | |
2299 | |
2300 CHECK_VECTOR (gstring); | |
2301 if (NILP (font_object)) | |
2302 font_object = Faref (Faref (gstring, make_number (0)), make_number (0)); | |
2303 CHECK_FONT_GET_OBJECT (font_object, font); | |
2304 | |
2305 if (STRINGP (object)) | |
2306 { | |
2307 const unsigned char *p; | |
2308 | |
2309 CHECK_NATNUM (start); | |
2310 CHECK_NATNUM (end); | |
2311 if (XINT (start) > XINT (end) | |
2312 || XINT (end) > ASIZE (object) | |
2313 || XINT (end) - XINT (start) >= XINT (Flength (gstring))) | |
2314 args_out_of_range (start, end); | |
2315 | |
2316 len = XINT (end) - XINT (start); | |
2317 p = SDATA (object) + string_char_to_byte (object, XINT (start)); | |
2318 for (i = 0; i < len; i++) | |
2319 { | |
2320 Lisp_Object g = LGSTRING_GLYPH (gstring, i); | |
2321 | |
2322 c = STRING_CHAR_ADVANCE (p); | |
2323 code = font->driver->encode_char (font, c); | |
2324 if (code > MOST_POSITIVE_FIXNUM) | |
2325 error ("Glyph code 0x%X is too large", code); | |
2326 ASET (g, 0, make_number (i)); | |
2327 ASET (g, 1, make_number (i + 1)); | |
2328 LGLYPH_SET_CHAR (g, make_number (c)); | |
2329 LGLYPH_SET_CODE (g, make_number (code)); | |
2330 } | |
2331 } | |
2332 else | |
2333 { | |
2334 int pos, pos_byte; | |
2335 | |
2336 if (! NILP (object)) | |
2337 Fset_buffer (object); | |
2338 validate_region (&start, &end); | |
2339 if (XINT (end) - XINT (start) > len) | |
2340 args_out_of_range (start, end); | |
2341 len = XINT (end) - XINT (start); | |
2342 pos = XINT (start); | |
2343 pos_byte = CHAR_TO_BYTE (pos); | |
2344 for (i = 0; i < len; i++) | |
2345 { | |
2346 Lisp_Object g = LGSTRING_GLYPH (gstring, i); | |
2347 | |
2348 FETCH_CHAR_ADVANCE (c, pos, pos_byte); | |
2349 code = font->driver->encode_char (font, c); | |
2350 if (code > MOST_POSITIVE_FIXNUM) | |
2351 error ("Glyph code 0x%X is too large", code); | |
2352 ASET (g, 0, make_number (i)); | |
2353 ASET (g, 1, make_number (i + 1)); | |
2354 LGLYPH_SET_CHAR (g, make_number (c)); | |
2355 LGLYPH_SET_CODE (g, make_number (code)); | |
2356 } | |
2357 } | |
2358 return Qnil; | |
2359 } | |
2360 | |
2361 | |
2362 #ifdef FONT_DEBUG | |
2363 | |
2364 DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0, | |
2365 doc: /* Open FONT-ENTITY. */) | |
2366 (font_entity, size, frame) | |
2367 Lisp_Object font_entity; | |
2368 Lisp_Object size; | |
2369 Lisp_Object frame; | |
2370 { | |
2371 int isize; | |
2372 | |
2373 CHECK_FONT_ENTITY (font_entity); | |
2374 if (NILP (size)) | |
2375 size = AREF (font_entity, FONT_SIZE_INDEX); | |
2376 CHECK_NUMBER (size); | |
2377 if (NILP (frame)) | |
2378 frame = selected_frame; | |
2379 CHECK_LIVE_FRAME (frame); | |
2380 | |
2381 isize = XINT (size); | |
2382 if (isize < 0) | |
2383 isize = POINT_TO_PIXEL (- isize, XFRAME (frame)->resy); | |
2384 | |
2385 return font_open_entity (XFRAME (frame), font_entity, isize); | |
2386 } | |
2387 | |
2388 DEFUN ("close-font", Fclose_font, Sclose_font, 1, 2, 0, | |
2389 doc: /* Close FONT-OBJECT. */) | |
2390 (font_object, frame) | |
2391 Lisp_Object font_object, frame; | |
2392 { | |
2393 CHECK_FONT_OBJECT (font_object); | |
2394 if (NILP (frame)) | |
2395 frame = selected_frame; | |
2396 CHECK_LIVE_FRAME (frame); | |
2397 font_close_object (XFRAME (frame), font_object); | |
2398 return Qnil; | |
2399 } | |
2400 | |
2401 DEFUN ("query-font", Fquery_font, Squery_font, 1, 1, 0, | |
2402 doc: /* Return information about FONT-OBJECT. */) | |
2403 (font_object) | |
2404 Lisp_Object font_object; | |
2405 { | |
2406 struct font *font; | |
2407 Lisp_Object val; | |
2408 | |
2409 CHECK_FONT_GET_OBJECT (font_object, font); | |
2410 | |
2411 val = Fmake_vector (make_number (9), Qnil); | |
2412 ASET (val, 0, Ffont_xlfd_name (font_object)); | |
2413 if (font->file_name) | |
2414 ASET (val, 1, make_unibyte_string (font->file_name, | |
2415 strlen (font->file_name))); | |
2416 ASET (val, 2, make_number (font->pixel_size)); | |
2417 ASET (val, 3, make_number (font->font.size)); | |
2418 ASET (val, 4, make_number (font->ascent)); | |
2419 ASET (val, 5, make_number (font->descent)); | |
2420 ASET (val, 6, make_number (font->font.space_width)); | |
2421 ASET (val, 7, make_number (font->font.average_width)); | |
2422 if (font->driver->otf_capability) | |
2423 ASET (val, 8, font->driver->otf_capability (font)); | |
2424 return val; | |
2425 } | |
2426 | |
2427 DEFUN ("get-font-glyphs", Fget_font_glyphs, Sget_font_glyphs, 2, 2, 0, | |
2428 doc: /* Return a vector of glyphs of FONT-OBJECT for drawing STRING. | |
2429 Each element is a vector [GLYPH-CODE LBEARING RBEARING WIDTH ASCENT DESCENT]. */) | |
2430 (font_object, string) | |
2431 Lisp_Object font_object, string; | |
2432 { | |
2433 struct font *font; | |
2434 int i, len; | |
2435 Lisp_Object vec; | |
2436 | |
2437 CHECK_FONT_GET_OBJECT (font_object, font); | |
2438 CHECK_STRING (string); | |
2439 len = SCHARS (string); | |
2440 vec = Fmake_vector (make_number (len), Qnil); | |
2441 for (i = 0; i < len; i++) | |
2442 { | |
2443 Lisp_Object ch = Faref (string, make_number (i)); | |
2444 Lisp_Object val; | |
2445 int c = XINT (ch); | |
2446 unsigned code; | |
2447 struct font_metrics metrics; | |
2448 | |
2449 code = font->driver->encode_char (font, c); | |
2450 if (code == FONT_INVALID_CODE) | |
2451 continue; | |
2452 val = Fmake_vector (make_number (6), Qnil); | |
2453 if (code <= MOST_POSITIVE_FIXNUM) | |
2454 ASET (val, 0, make_number (code)); | |
2455 else | |
2456 ASET (val, 0, Fcons (make_number (code >> 16), | |
2457 make_number (code & 0xFFFF))); | |
2458 font->driver->text_extents (font, &code, 1, &metrics); | |
2459 ASET (val, 1, make_number (metrics.lbearing)); | |
2460 ASET (val, 2, make_number (metrics.rbearing)); | |
2461 ASET (val, 3, make_number (metrics.width)); | |
2462 ASET (val, 4, make_number (metrics.ascent)); | |
2463 ASET (val, 5, make_number (metrics.descent)); | |
2464 ASET (vec, i, val); | |
2465 } | |
2466 return vec; | |
2467 } | |
2468 | |
2469 #if 0 | |
2470 DEFUN ("draw-string", Fdraw_string, Sdraw_string, 2, 2, 0, | |
2471 doc: /* Draw STRING by FONT-OBJECT on the top left corner of the current frame. | |
2472 The value is a number of glyphs drawn. | |
2473 Type C-l to recover what previously shown. */) | |
2474 (font_object, string) | |
2475 Lisp_Object font_object, string; | |
2476 { | |
2477 Lisp_Object frame = selected_frame; | |
2478 FRAME_PTR f = XFRAME (frame); | |
2479 struct font *font; | |
2480 struct face *face; | |
2481 int i, len, width; | |
2482 unsigned *code; | |
2483 | |
2484 CHECK_FONT_GET_OBJECT (font_object, font); | |
2485 CHECK_STRING (string); | |
2486 len = SCHARS (string); | |
2487 code = alloca (sizeof (unsigned) * len); | |
2488 for (i = 0; i < len; i++) | |
2489 { | |
2490 Lisp_Object ch = Faref (string, make_number (i)); | |
2491 Lisp_Object val; | |
2492 int c = XINT (ch); | |
2493 | |
2494 code[i] = font->driver->encode_char (font, c); | |
2495 if (code[i] == FONT_INVALID_CODE) | |
2496 break; | |
2497 } | |
2498 face = FACE_FROM_ID (f, DEFAULT_FACE_ID); | |
2499 face->fontp = font; | |
2500 if (font->driver->prepare_face) | |
2501 font->driver->prepare_face (f, face); | |
2502 width = font->driver->text_extents (font, code, i, NULL); | |
2503 len = font->driver->draw_text (f, face, 0, font->ascent, code, i, width); | |
2504 if (font->driver->done_face) | |
2505 font->driver->done_face (f, face); | |
2506 face->fontp = NULL; | |
2507 return make_number (len); | |
2508 } | |
2509 #endif | |
2510 | |
2511 #endif /* FONT_DEBUG */ | |
2512 | |
2513 | |
2514 extern void syms_of_ftfont P_ (()); | |
2515 extern void syms_of_xfont P_ (()); | |
2516 extern void syms_of_xftfont P_ (()); | |
2517 extern void syms_of_ftxfont P_ (()); | |
2518 extern void syms_of_bdffont P_ (()); | |
2519 extern void syms_of_w32font P_ (()); | |
2520 extern void syms_of_atmfont P_ (()); | |
2521 | |
2522 void | |
2523 syms_of_font () | |
2524 { | |
2525 sort_shift_bits[FONT_SLANT_INDEX] = 0; | |
2526 sort_shift_bits[FONT_WEIGHT_INDEX] = 7; | |
2527 sort_shift_bits[FONT_SIZE_INDEX] = 14; | |
2528 sort_shift_bits[FONT_WIDTH_INDEX] = 21; | |
2529 sort_shift_bits[FONT_ADSTYLE_INDEX] = 28; | |
2530 sort_shift_bits[FONT_FOUNDRY_INDEX] = 29; | |
2531 sort_shift_bits[FONT_FAMILY_INDEX] = 30; | |
2532 sort_shift_bits[FONT_REGISTRY_INDEX] = 31; | |
2533 /* Note that sort_shift_bits[FONT_SLANT_TYPE] is never used. */ | |
2534 | |
2535 staticpro (&font_style_table); | |
2536 font_style_table = Fmake_vector (make_number (3), Qnil); | |
2537 | |
2538 staticpro (&font_family_alist); | |
2539 font_family_alist = Qnil; | |
2540 | |
2541 DEFSYM (Qfontp, "fontp"); | |
2542 | |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
2543 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
|
2544 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
|
2545 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
|
2546 |
90400 | 2547 DEFSYM (QCotf, ":otf"); |
2548 DEFSYM (QClanguage, ":language"); | |
2549 DEFSYM (QCscript, ":script"); | |
2550 | |
2551 DEFSYM (QCfoundry, ":foundry"); | |
2552 DEFSYM (QCadstyle, ":adstyle"); | |
2553 DEFSYM (QCregistry, ":registry"); | |
2554 DEFSYM (QCextra, ":extra"); | |
2555 | |
2556 staticpro (&null_string); | |
2557 null_string = build_string (""); | |
2558 staticpro (&null_vector); | |
2559 null_vector = Fmake_vector (make_number (0), Qnil); | |
2560 | |
2561 staticpro (&scratch_font_spec); | |
2562 scratch_font_spec = Ffont_spec (0, NULL); | |
2563 staticpro (&scratch_font_prefer); | |
2564 scratch_font_prefer = Ffont_spec (0, NULL); | |
2565 | |
2566 defsubr (&Sfontp); | |
2567 defsubr (&Sfont_spec); | |
2568 defsubr (&Sfont_get); | |
2569 defsubr (&Sfont_put); | |
2570 defsubr (&Slist_fonts); | |
2571 defsubr (&Slist_families); | |
2572 defsubr (&Sfind_font); | |
2573 defsubr (&Sfont_xlfd_name); | |
2574 defsubr (&Sclear_font_cache); | |
2575 defsubr (&Sinternal_set_font_style_table); | |
2576 defsubr (&Sfont_make_gstring); | |
2577 defsubr (&Sfont_fill_gstring); | |
2578 | |
2579 #ifdef FONT_DEBUG | |
2580 defsubr (&Sopen_font); | |
2581 defsubr (&Sclose_font); | |
2582 defsubr (&Squery_font); | |
2583 defsubr (&Sget_font_glyphs); | |
2584 #if 0 | |
2585 defsubr (&Sdraw_string); | |
2586 #endif | |
2587 #endif /* FONT_DEBUG */ | |
2588 | |
2589 #ifdef HAVE_FREETYPE | |
2590 syms_of_ftfont (); | |
2591 #ifdef HAVE_X_WINDOWS | |
2592 syms_of_xfont (); | |
2593 syms_of_ftxfont (); | |
2594 #ifdef HAVE_XFT | |
2595 syms_of_xftfont (); | |
2596 #endif /* HAVE_XFT */ | |
2597 #endif /* HAVE_X_WINDOWS */ | |
2598 #else /* not HAVE_FREETYPE */ | |
2599 #ifdef HAVE_X_WINDOWS | |
2600 syms_of_xfont (); | |
2601 #endif /* HAVE_X_WINDOWS */ | |
2602 #endif /* not HAVE_FREETYPE */ | |
2603 #ifdef HAVE_BDFFONT | |
2604 syms_of_bdffont (); | |
2605 #endif /* HAVE_BDFFONT */ | |
2606 #ifdef WINDOWSNT | |
2607 syms_of_w32font (); | |
2608 #endif /* WINDOWSNT */ | |
2609 #ifdef MAC_OS | |
2610 syms_of_atmfont (); | |
2611 #endif /* MAC_OS */ | |
2612 } | |
90427 | 2613 |
2614 /* arch-tag: 74c9475d-5976-4c93-a327-942ae3072846 | |
2615 (do not change this comment) */ |