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