Mercurial > emacs
annotate src/font.c @ 93186:3c66b698cc43
(calendar-persian-read-date): New name for persian-prompt-for-date.
Update callers, make old name an obsolete alias. Doc fix. Move
definition before use.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Tue, 25 Mar 2008 03:42:01 +0000 |
parents | edc3ba5b9670 |
children | d1731f0f8048 |
rev | line source |
---|---|
90400 | 1 /* font.c -- "Font" primitives. |
91553 | 2 Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. |
3 Copyright (C) 2006, 2007, 2008 | |
90400 | 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 | |
91550
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
11 the Free Software Foundation; either version 3, or (at your option) |
90400 | 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> | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
28 #ifdef HAVE_M17N_FLT |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
29 #include <m17n-flt.h> |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
30 #endif |
90400 | 31 |
32 #include "lisp.h" | |
33 #include "buffer.h" | |
34 #include "frame.h" | |
90541 | 35 #include "window.h" |
90400 | 36 #include "dispextern.h" |
37 #include "charset.h" | |
38 #include "character.h" | |
39 #include "composite.h" | |
40 #include "fontset.h" | |
41 #include "font.h" | |
42 | |
91909 | 43 #ifdef HAVE_X_WINDOWS |
44 #include "xterm.h" | |
45 #endif /* HAVE_X_WINDOWS */ | |
46 | |
47 #ifdef HAVE_NTGUI | |
48 #include "w32term.h" | |
49 #endif /* HAVE_NTGUI */ | |
50 | |
51 #ifdef MAC_OS | |
52 #include "macterm.h" | |
53 #endif /* MAC_OS */ | |
54 | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
55 #ifndef FONT_DEBUG |
90400 | 56 #define FONT_DEBUG |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
57 #endif |
90400 | 58 |
59 #ifdef FONT_DEBUG | |
60 #undef xassert | |
61 #define xassert(X) do {if (!(X)) abort ();} while (0) | |
62 #else | |
63 #define xassert(X) (void) 0 | |
64 #endif | |
65 | |
66 int enable_font_backend; | |
67 | |
90677
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
68 Lisp_Object Qopentype; |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
69 |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
70 /* Important character set symbols. */ |
90622
bb9362e3a03b
(Qunicode_sip): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90590
diff
changeset
|
71 Lisp_Object Qiso8859_1, Qiso10646_1, Qunicode_bmp, Qunicode_sip; |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
72 |
90400 | 73 /* Like CHECK_FONT_SPEC but also validate properties of the font-spec, |
74 and set X to the validated result. */ | |
75 | |
76 #define CHECK_VALIDATE_FONT_SPEC(x) \ | |
77 do { \ | |
91943
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
78 if (! FONT_SPEC_P (x)) wrong_type_argument (Qfont, x); \ |
90400 | 79 x = font_prop_validate (x); \ |
80 } while (0) | |
81 | |
82 /* Number of pt per inch (from the TeXbook). */ | |
83 #define PT_PER_INCH 72.27 | |
84 | |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
85 /* Return a pixel size (integer) corresponding to POINT size (double) |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
86 on resolution DPI. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
87 #define POINT_TO_PIXEL(POINT, DPI) ((POINT) * (DPI) / PT_PER_INCH + 0.5) |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
88 |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
89 /* Return a point size (double) corresponding to POINT size (integer) |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
90 on resolution DPI. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
91 #define PIXEL_TO_POINT(PIXEL, DPI) ((PIXEL) * PT_PER_INCH * 10 / (DPI) + 0.5) |
90400 | 92 |
93 /* Special string of zero length. It is used to specify a NULL name | |
94 in a font properties (e.g. adstyle). We don't use the symbol of | |
95 NULL name because it's confusing (Lisp printer prints nothing for | |
96 it). */ | |
97 Lisp_Object null_string; | |
98 | |
99 /* Special vector of zero length. This is repeatedly used by (struct | |
100 font_driver *)->list when a specified font is not found. */ | |
101 Lisp_Object null_vector; | |
102 | |
103 /* Vector of 3 elements. Each element is an alist for one of font | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
104 style properties (weight, slant, width). Each alist contains a |
90400 | 105 mapping between symbolic property values (e.g. `medium' for weight) |
106 and numeric property values (e.g. 100). So, it looks like this: | |
107 [((thin . 0) ... (heavy . 210)) | |
108 ((ro . 0) ... (ot . 210)) | |
109 ((ultracondensed . 50) ... (wide . 200))] */ | |
110 static Lisp_Object font_style_table; | |
111 | |
112 /* Alist of font family vs the corresponding aliases. | |
113 Each element has this form: | |
114 (FAMILY ALIAS1 ALIAS2 ...) */ | |
115 | |
116 static Lisp_Object font_family_alist; | |
117 | |
118 /* Symbols representing keys of normal font properties. */ | |
119 extern Lisp_Object QCtype, QCfamily, QCweight, QCslant, QCwidth, QCsize, QCname; | |
120 Lisp_Object QCfoundry, QCadstyle, QCregistry, QCextra; | |
121 /* Symbols representing keys of font extra info. */ | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
122 Lisp_Object QCspacing, QCdpi, QCscalable, QCotf, QClanguage, QCscript; |
91125
6c9a19ff6c55
(Qfontp): Remove unused symbol.
Jason Rumney <jasonr@gnu.org>
parents:
91112
diff
changeset
|
123 Lisp_Object QCantialias; |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
124 /* Symbols representing values of font spacing property. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
125 Lisp_Object Qc, Qm, Qp, Qd; |
90400 | 126 |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
127 /* Alist of font registry symbol and the corresponding charsets |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
128 information. The information is retrieved from |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
129 Vfont_encoding_alist on demand. |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
130 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
131 Eash element has the form: |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
132 (REGISTRY . (ENCODING-CHARSET-ID . REPERTORY-CHARSET-ID)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
133 or |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
134 (REGISTRY . nil) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
135 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
136 In the former form, ENCODING-CHARSET-ID is an ID of a charset that |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
137 encodes a character code to a glyph code of a font, and |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
138 REPERTORY-CHARSET-ID is an ID of a charset that tells if a |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
139 character is supported by a font. |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
140 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
141 The latter form means that the information for REGISTRY couldn't be |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
142 retrieved. */ |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
143 static Lisp_Object font_charset_alist; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
144 |
91112
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
145 /* List of all font drivers. Each font-backend (XXXfont.c) calls |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
146 register_font_driver in syms_of_XXXfont to register its font-driver |
90400 | 147 here. */ |
148 static struct font_driver_list *font_driver_list; | |
149 | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
150 static int font_pixel_size P_ ((FRAME_PTR f, Lisp_Object)); |
90400 | 151 static Lisp_Object prop_name_to_numeric P_ ((enum font_property_index, |
152 Lisp_Object)); | |
153 static Lisp_Object prop_numeric_to_name P_ ((enum font_property_index, int)); | |
154 static Lisp_Object font_open_entity P_ ((FRAME_PTR, Lisp_Object, int)); | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
155 static void build_font_family_alist P_ ((void)); |
90400 | 156 |
157 /* Number of registered font drivers. */ | |
158 static int num_font_drivers; | |
159 | |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
160 /* Return a pixel size of font-spec SPEC on frame F. */ |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
161 |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
162 static int |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
163 font_pixel_size (f, spec) |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
164 FRAME_PTR f; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
165 Lisp_Object spec; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
166 { |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
167 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
|
168 double point_size; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
169 int pixel_size, dpi; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
170 Lisp_Object extra, val; |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
171 |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
172 if (INTEGERP (size)) |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
173 return XINT (size); |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
174 if (NILP (size)) |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
175 return 0; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
176 point_size = XFLOAT_DATA (size); |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
177 extra = AREF (spec, FONT_EXTRA_INDEX); |
90903
c3e1394462ec
(font_pixel_size): Reverse assq_no_quit args.
Jason Rumney <jasonr@gnu.org>
parents:
90888
diff
changeset
|
178 val = assq_no_quit (QCdpi, extra); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
179 if (CONSP (val)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
180 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
181 if (INTEGERP (XCDR (val))) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
182 dpi = XINT (XCDR (val)); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
183 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
184 dpi = XFLOAT_DATA (XCDR (val)) + 0.5; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
185 } |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
186 else |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
187 dpi = f->resy; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
188 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
|
189 return pixel_size; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
190 } |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
191 |
90400 | 192 /* Return a numeric value corresponding to PROP's NAME (symbol). If |
193 NAME is not registered in font_style_table, return Qnil. PROP must | |
194 be one of FONT_{WEIGHT|SLANT|SWIDTH}_INDEX. */ | |
195 | |
196 static Lisp_Object | |
197 prop_name_to_numeric (prop, name) | |
198 enum font_property_index prop; | |
199 Lisp_Object name; | |
200 { | |
201 int table_index = prop - FONT_WEIGHT_INDEX; | |
202 Lisp_Object val; | |
203 | |
204 val = assq_no_quit (name, AREF (font_style_table, table_index)); | |
205 return (NILP (val) ? Qnil : XCDR (val)); | |
206 } | |
207 | |
208 | |
209 /* Return a name (symbol) corresponding to PROP's NUMERIC value. If | |
210 no name is registered for NUMERIC in font_style_table, return a | |
211 symbol of integer name (e.g. `123'). PROP must be one of | |
212 FONT_{WEIGHT|SLANT|SWIDTH}_INDEX. */ | |
213 | |
214 static Lisp_Object | |
215 prop_numeric_to_name (prop, numeric) | |
216 enum font_property_index prop; | |
217 int numeric; | |
218 { | |
219 int table_index = prop - FONT_WEIGHT_INDEX; | |
220 Lisp_Object table = AREF (font_style_table, table_index); | |
221 char buf[10]; | |
222 | |
223 while (! NILP (table)) | |
224 { | |
225 if (XINT (XCDR (XCAR (table))) >= numeric) | |
226 { | |
227 if (XINT (XCDR (XCAR (table))) == numeric) | |
228 return XCAR (XCAR (table)); | |
229 else | |
230 break; | |
231 } | |
232 table = XCDR (table); | |
233 } | |
234 sprintf (buf, "%d", numeric); | |
235 return intern (buf); | |
236 } | |
237 | |
238 | |
239 /* Return a symbol whose name is STR (length LEN). If STR contains | |
240 uppercase letters, downcase them in advance. */ | |
241 | |
242 Lisp_Object | |
243 intern_downcase (str, len) | |
244 char *str; | |
245 int len; | |
246 { | |
247 char *buf; | |
248 int i; | |
249 | |
250 for (i = 0; i < len; i++) | |
251 if (isupper (str[i])) | |
252 break; | |
253 if (i == len) | |
254 return Fintern (make_unibyte_string (str, len), Qnil); | |
255 buf = alloca (len); | |
256 if (! buf) | |
257 return Fintern (null_string, Qnil); | |
258 bcopy (str, buf, len); | |
259 for (; i < len; i++) | |
260 if (isascii (buf[i])) | |
261 buf[i] = tolower (buf[i]); | |
262 return Fintern (make_unibyte_string (buf, len), Qnil); | |
263 } | |
264 | |
265 extern Lisp_Object Vface_alternative_font_family_alist; | |
266 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
267 /* Setup font_family_alist of the form: |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
268 ((FAMILY-SYMBOL ALIAS-SYMBOL ...) ...) |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
269 from Vface_alternative_font_family_alist of the form: |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
270 ((FAMILY-STRING ALIAS-STRING ...) ...) */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
271 |
90400 | 272 static void |
273 build_font_family_alist () | |
274 { | |
275 Lisp_Object alist = Vface_alternative_font_family_alist; | |
276 | |
277 for (; CONSP (alist); alist = XCDR (alist)) | |
278 { | |
279 Lisp_Object tail, elt; | |
280 | |
281 for (tail = XCAR (alist), elt = Qnil ; CONSP (tail); tail = XCDR (tail)) | |
282 elt = nconc2 (elt, Fcons (Fintern (XCAR (tail), Qnil), Qnil)); | |
283 font_family_alist = Fcons (elt, font_family_alist); | |
284 } | |
285 } | |
286 | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
287 extern Lisp_Object find_font_encoding P_ ((Lisp_Object)); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
288 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
289 /* Return encoding charset and repertory charset for REGISTRY in |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
290 ENCODING and REPERTORY correspondingly. If correct information for |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
291 REGISTRY is available, return 0. Otherwise return -1. */ |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
292 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
293 int |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
294 font_registry_charsets (registry, encoding, repertory) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
295 Lisp_Object registry; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
296 struct charset **encoding, **repertory; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
297 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
298 Lisp_Object val; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
299 int encoding_id, repertory_id; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
300 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
301 val = assq_no_quit (registry, font_charset_alist); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
302 if (! NILP (val)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
303 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
304 val = XCDR (val); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
305 if (NILP (val)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
306 return -1; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
307 encoding_id = XINT (XCAR (val)); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
308 repertory_id = XINT (XCDR (val)); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
309 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
310 else |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
311 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
312 val = find_font_encoding (SYMBOL_NAME (registry)); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
313 if (SYMBOLP (val) && CHARSETP (val)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
314 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
315 encoding_id = repertory_id = XINT (CHARSET_SYMBOL_ID (val)); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
316 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
317 else if (CONSP (val)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
318 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
319 if (! CHARSETP (XCAR (val))) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
320 goto invalid_entry; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
321 encoding_id = XINT (CHARSET_SYMBOL_ID (XCAR (val))); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
322 if (NILP (XCDR (val))) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
323 repertory_id = -1; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
324 else |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
325 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
326 if (! CHARSETP (XCDR (val))) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
327 goto invalid_entry; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
328 repertory_id = XINT (CHARSET_SYMBOL_ID (XCDR (val))); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
329 } |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
330 } |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
331 else |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
332 goto invalid_entry; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
333 val = Fcons (make_number (encoding_id), make_number (repertory_id)); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
334 font_charset_alist |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
335 = nconc2 (font_charset_alist, Fcons (Fcons (registry, val), Qnil)); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
336 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
337 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
338 if (encoding) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
339 *encoding = CHARSET_FROM_ID (encoding_id); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
340 if (repertory) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
341 *repertory = repertory_id >= 0 ? CHARSET_FROM_ID (repertory_id) : NULL; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
342 return 0; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
343 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
344 invalid_entry: |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
345 font_charset_alist |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
346 = nconc2 (font_charset_alist, Fcons (Fcons (registry, Qnil), Qnil)); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
347 return -1; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
348 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
349 |
90400 | 350 |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
351 /* Font property value validaters. See the comment of |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
352 font_property_table for the meaning of the arguments. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
353 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
354 static Lisp_Object font_prop_validate_symbol P_ ((Lisp_Object, Lisp_Object)); |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
355 static Lisp_Object font_prop_validate_style P_ ((Lisp_Object, Lisp_Object)); |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
356 static Lisp_Object font_prop_validate_non_neg P_ ((Lisp_Object, Lisp_Object)); |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
357 static Lisp_Object font_prop_validate_spacing P_ ((Lisp_Object, Lisp_Object)); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
358 static int get_font_prop_index P_ ((Lisp_Object, int)); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
359 static Lisp_Object font_prop_validate P_ ((Lisp_Object)); |
90400 | 360 |
361 static Lisp_Object | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
362 font_prop_validate_symbol (prop, val) |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
363 Lisp_Object prop, val; |
90400 | 364 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
365 if (EQ (prop, QCotf)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
366 return (SYMBOLP (val) ? val : Qerror); |
90400 | 367 if (STRINGP (val)) |
368 val = (SCHARS (val) == 0 ? null_string | |
369 : intern_downcase ((char *) SDATA (val), SBYTES (val))); | |
370 else if (SYMBOLP (val)) | |
371 { | |
372 if (SCHARS (SYMBOL_NAME (val)) == 0) | |
373 val = null_string; | |
374 } | |
375 else | |
376 val = Qerror; | |
377 return val; | |
378 } | |
379 | |
380 static Lisp_Object | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
381 font_prop_validate_style (prop, val) |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
382 Lisp_Object prop, val; |
90400 | 383 { |
384 if (! INTEGERP (val)) | |
385 { | |
386 if (STRINGP (val)) | |
387 val = intern_downcase ((char *) SDATA (val), SBYTES (val)); | |
388 if (! SYMBOLP (val)) | |
389 val = Qerror; | |
390 else | |
391 { | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
392 enum font_property_index prop_index |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
393 = (EQ (prop, QCweight) ? FONT_WEIGHT_INDEX |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
394 : EQ (prop, QCslant) ? FONT_SLANT_INDEX |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
395 : FONT_WIDTH_INDEX); |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
396 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
397 val = prop_name_to_numeric (prop_index, val); |
90400 | 398 if (NILP (val)) |
399 val = Qerror; | |
400 } | |
401 } | |
402 return val; | |
403 } | |
404 | |
405 static Lisp_Object | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
406 font_prop_validate_non_neg (prop, val) |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
407 Lisp_Object prop, val; |
90400 | 408 { |
409 return (NATNUMP (val) || (FLOATP (val) && XFLOAT_DATA (val) >= 0) | |
410 ? val : Qerror); | |
411 } | |
412 | |
413 static Lisp_Object | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
414 font_prop_validate_spacing (prop, val) |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
415 Lisp_Object prop, val; |
90400 | 416 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
417 if (NILP (val) || (NATNUMP (val) && XINT (val) <= FONT_SPACING_CHARCELL)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
418 return val; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
419 if (EQ (val, Qc)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
420 return make_number (FONT_SPACING_CHARCELL); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
421 if (EQ (val, Qm)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
422 return make_number (FONT_SPACING_MONO); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
423 if (EQ (val, Qp)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
424 return make_number (FONT_SPACING_PROPORTIONAL); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
425 return Qerror; |
90400 | 426 } |
427 | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
428 static Lisp_Object |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
429 font_prop_validate_otf (prop, val) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
430 Lisp_Object prop, val; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
431 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
432 Lisp_Object tail, tmp; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
433 int i; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
434 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
435 /* VAL = (SCRIPT [ LANGSYS [ GSUB-FEATURES [ GPOS-FEATURES ]]]) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
436 GSUB-FEATURES = (FEATURE ... [ nil FEATURE ... ]) | nil |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
437 GPOS-FEATURES = (FEATURE ... [ nil FEATURE ... ]) | nil */ |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
438 if (! CONSP (val)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
439 return Qerror; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
440 if (! SYMBOLP (XCAR (val))) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
441 return Qerror; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
442 tail = XCDR (val); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
443 if (NILP (tail)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
444 return val; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
445 if (! CONSP (tail) || ! SYMBOLP (XCAR (val))) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
446 return Qerror; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
447 for (i = 0; i < 2; i++) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
448 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
449 tail = XCDR (tail); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
450 if (NILP (tail)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
451 return val; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
452 if (! CONSP (tail)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
453 return Qerror; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
454 for (tmp = XCAR (tail); CONSP (tmp); tmp = XCDR (tmp)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
455 if (! SYMBOLP (XCAR (tmp))) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
456 return Qerror; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
457 if (! NILP (tmp)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
458 return Qerror; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
459 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
460 return val; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
461 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
462 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
463 /* Structure of known font property keys and validater of the |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
464 values. */ |
90400 | 465 struct |
466 { | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
467 /* Pointer to the key symbol. */ |
90400 | 468 Lisp_Object *key; |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
469 /* Function to validate PROP's value VAL, or NULL if any value is |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
470 ok. The value is VAL or its regularized value if VAL is valid, |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
471 and Qerror if not. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
472 Lisp_Object (*validater) P_ ((Lisp_Object prop, Lisp_Object val)); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
473 } font_property_table[] = |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
474 { { &QCtype, font_prop_validate_symbol }, |
90400 | 475 { &QCfoundry, font_prop_validate_symbol }, |
476 { &QCfamily, font_prop_validate_symbol }, | |
477 { &QCadstyle, font_prop_validate_symbol }, | |
478 { &QCregistry, font_prop_validate_symbol }, | |
479 { &QCweight, font_prop_validate_style }, | |
480 { &QCslant, font_prop_validate_style }, | |
481 { &QCwidth, font_prop_validate_style }, | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
482 { &QCsize, font_prop_validate_non_neg }, |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
483 { &QClanguage, font_prop_validate_symbol }, |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
484 { &QCscript, font_prop_validate_symbol }, |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
485 { &QCdpi, font_prop_validate_non_neg }, |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
486 { &QCspacing, font_prop_validate_spacing }, |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
487 { &QCscalable, NULL }, |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
488 { &QCotf, font_prop_validate_otf }, |
91125
6c9a19ff6c55
(Qfontp): Remove unused symbol.
Jason Rumney <jasonr@gnu.org>
parents:
91112
diff
changeset
|
489 { &QCantialias, font_prop_validate_symbol } |
90400 | 490 }; |
491 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
492 /* Size (number of elements) of the above table. */ |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
493 #define FONT_PROPERTY_TABLE_SIZE \ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
494 ((sizeof font_property_table) / (sizeof *font_property_table)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
495 |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
496 /* Return an index number of font property KEY or -1 if KEY is not an |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
497 already known property. Start searching font_property_table from |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
498 index FROM (which is 0 or FONT_EXTRA_INDEX). */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
499 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
500 static int |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
501 get_font_prop_index (key, from) |
90400 | 502 Lisp_Object key; |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
503 int from; |
90400 | 504 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
505 for (; from < FONT_PROPERTY_TABLE_SIZE; from++) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
506 if (EQ (key, *font_property_table[from].key)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
507 return from; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
508 return -1; |
90400 | 509 } |
510 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
511 /* Validate font properties in SPEC (vector) while updating elements |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
512 to regularized values. Signal an error if an invalid property is |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
513 found. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
514 |
90400 | 515 static Lisp_Object |
516 font_prop_validate (spec) | |
517 Lisp_Object spec; | |
518 { | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
519 int i; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
520 Lisp_Object prop, val, extra; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
521 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
522 for (i = FONT_TYPE_INDEX; i < FONT_EXTRA_INDEX; i++) |
90400 | 523 { |
524 if (! NILP (AREF (spec, i))) | |
525 { | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
526 prop = *font_property_table[i].key; |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
527 val = (font_property_table[i].validater) (prop, AREF (spec, i)); |
90400 | 528 if (EQ (val, Qerror)) |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
529 Fsignal (Qfont, list2 (build_string ("invalid font property"), |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
530 Fcons (prop, AREF (spec, i)))); |
90400 | 531 ASET (spec, i, val); |
532 } | |
533 } | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
534 for (extra = AREF (spec, FONT_EXTRA_INDEX); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
535 CONSP (extra); extra = XCDR (extra)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
536 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
537 Lisp_Object elt = XCAR (extra); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
538 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
539 prop = XCAR (elt); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
540 i = get_font_prop_index (prop, FONT_EXTRA_INDEX); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
541 if (i >= 0 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
542 && font_property_table[i].validater) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
543 { |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
544 val = (font_property_table[i].validater) (prop, XCDR (elt)); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
545 if (EQ (val, Qerror)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
546 Fsignal (Qfont, list2 (build_string ("invalid font property"), |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
547 elt)); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
548 XSETCDR (elt, val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
549 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
550 } |
90400 | 551 return spec; |
552 } | |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
553 |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
554 /* Store VAL as a value of extra font property PROP in FONT. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
555 |
90888
5f03b3602143
(font_put_extra): Expose externally.
Jason Rumney <jasonr@gnu.org>
parents:
90883
diff
changeset
|
556 Lisp_Object |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
557 font_put_extra (font, prop, val) |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
558 Lisp_Object font, prop, val; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
559 { |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
560 Lisp_Object extra = AREF (font, FONT_EXTRA_INDEX); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
561 Lisp_Object slot = (NILP (extra) ? Qnil : assq_no_quit (prop, extra)); |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
562 |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
563 if (NILP (slot)) |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
564 { |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
565 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
|
566 ASET (font, FONT_EXTRA_INDEX, extra); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
567 return val; |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
568 } |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
569 XSETCDR (slot, val); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
570 return val; |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
571 } |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
572 |
90400 | 573 |
574 /* Font name parser and unparser */ | |
575 | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
576 static Lisp_Object intern_font_field P_ ((char *, int)); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
577 static int parse_matrix P_ ((char *)); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
578 static int font_expand_wildcards P_ ((Lisp_Object *, int)); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
579 static int font_parse_name P_ ((char *, Lisp_Object)); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
580 |
90400 | 581 /* An enumerator for each field of an XLFD font name. */ |
582 enum xlfd_field_index | |
583 { | |
584 XLFD_FOUNDRY_INDEX, | |
585 XLFD_FAMILY_INDEX, | |
586 XLFD_WEIGHT_INDEX, | |
587 XLFD_SLANT_INDEX, | |
588 XLFD_SWIDTH_INDEX, | |
589 XLFD_ADSTYLE_INDEX, | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
590 XLFD_PIXEL_INDEX, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
591 XLFD_POINT_INDEX, |
90400 | 592 XLFD_RESX_INDEX, |
593 XLFD_RESY_INDEX, | |
594 XLFD_SPACING_INDEX, | |
595 XLFD_AVGWIDTH_INDEX, | |
596 XLFD_REGISTRY_INDEX, | |
597 XLFD_ENCODING_INDEX, | |
598 XLFD_LAST_INDEX | |
599 }; | |
600 | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
601 /* An enumerator for mask bit corresponding to each XLFD field. */ |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
602 enum xlfd_field_mask |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
603 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
604 XLFD_FOUNDRY_MASK = 0x0001, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
605 XLFD_FAMILY_MASK = 0x0002, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
606 XLFD_WEIGHT_MASK = 0x0004, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
607 XLFD_SLANT_MASK = 0x0008, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
608 XLFD_SWIDTH_MASK = 0x0010, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
609 XLFD_ADSTYLE_MASK = 0x0020, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
610 XLFD_PIXEL_MASK = 0x0040, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
611 XLFD_POINT_MASK = 0x0080, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
612 XLFD_RESX_MASK = 0x0100, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
613 XLFD_RESY_MASK = 0x0200, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
614 XLFD_SPACING_MASK = 0x0400, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
615 XLFD_AVGWIDTH_MASK = 0x0800, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
616 XLFD_REGISTRY_MASK = 0x1000, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
617 XLFD_ENCODING_MASK = 0x2000 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
618 }; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
619 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
620 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
621 /* Return a Lispy value of a XLFD font field at STR and LEN bytes. |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
622 If LEN is zero, it returns `null_string'. |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
623 If STR is "*", it returns nil. |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
624 If all characters in STR are digits, it returns an integer. |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
625 Otherwise, it returns a symbol interned from downcased STR. */ |
90400 | 626 |
627 static Lisp_Object | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
628 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
|
629 char *str; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
630 int len; |
90400 | 631 { |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
632 int i; |
90400 | 633 |
634 if (len == 0) | |
635 return null_string; | |
636 if (*str == '*' && len == 1) | |
637 return Qnil; | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
638 if (isdigit (*str)) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
639 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
640 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
|
641 if (! isdigit (str[i])) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
642 break; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
643 if (i == len) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
644 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
|
645 } |
90400 | 646 return intern_downcase (str, len); |
647 } | |
648 | |
649 /* Parse P pointing the pixel/point size field of the form | |
650 `[A B C D]' which specifies a transformation matrix: | |
651 | |
652 A B 0 | |
653 C D 0 | |
654 0 0 1 | |
655 | |
656 by which all glyphs of the font are transformed. The spec says | |
657 that scalar value N for the pixel/point size is equivalent to: | |
658 A = N * resx/resy, B = C = 0, D = N. | |
659 | |
660 Return the scalar value N if the form is valid. Otherwise return | |
661 -1. */ | |
662 | |
663 static int | |
664 parse_matrix (p) | |
665 char *p; | |
666 { | |
667 double matrix[4]; | |
668 char *end; | |
669 int i; | |
670 | |
671 for (i = 0, p++; i < 4 && *p && *p != ']'; i++) | |
672 { | |
673 if (*p == '~') | |
674 matrix[i] = - strtod (p + 1, &end); | |
675 else | |
676 matrix[i] = strtod (p, &end); | |
677 p = end; | |
678 } | |
679 return (i == 4 ? (int) matrix[3] : -1); | |
680 } | |
681 | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
682 /* 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
|
683 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
|
684 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
|
685 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
686 static int |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
687 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
|
688 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
|
689 int n; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
690 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
691 /* Copy of FIELD. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
692 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
|
693 /* 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
|
694 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
|
695 struct { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
696 /* Minimum possible field. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
697 int from; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
698 /* Maxinum possible field. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
699 int to; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
700 /* 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
|
701 int mask; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
702 } range[XLFD_LAST_INDEX]; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
703 int i, j; |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
704 int range_from, range_to; |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
705 unsigned range_mask; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
706 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
707 #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
|
708 | 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
|
709 #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
|
710 #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
|
711 | XLFD_AVGWIDTH_MASK) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
712 #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
|
713 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
714 /* 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
|
715 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
|
716 following loop. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
717 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
|
718 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
|
719 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
720 /* The triplet RANGE_FROM, RANGE_TO, and RANGE_MASK is a |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
721 position-based retriction for FIELD[I]. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
722 for (i = 0, range_from = 0, range_to = 14 - n; i < n; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
723 i++, range_from++, range_to++, range_mask <<= 1) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
724 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
725 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
|
726 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
727 tmp[i] = val; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
728 if (NILP (val)) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
729 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
730 /* Wildcard. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
731 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
|
732 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
|
733 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
|
734 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
735 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
736 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
737 /* 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
|
738 retriction for FIELD[I]. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
739 int from, to; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
740 unsigned mask; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
741 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
742 if (INTEGERP (val)) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
743 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
744 int numeric = XINT (val); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
745 |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
746 if (i + 1 == n) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
747 from = to = XLFD_ENCODING_INDEX, |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
748 mask = XLFD_ENCODING_MASK; |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
749 else if (numeric == 0) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
750 from = XLFD_PIXEL_INDEX, to = XLFD_AVGWIDTH_INDEX, |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
751 mask = XLFD_PIXEL_MASK | XLFD_LARGENUM_MASK; |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
752 else if (numeric <= 48) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
753 from = to = XLFD_PIXEL_INDEX, |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
754 mask = XLFD_PIXEL_MASK; |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
755 else |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
756 from = XLFD_POINT_INDEX, to = XLFD_AVGWIDTH_INDEX, |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
757 mask = XLFD_LARGENUM_MASK; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
758 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
759 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
|
760 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
|
761 mask = XLFD_NULL_MASK; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
762 else if (i == 0) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
763 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
|
764 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
|
765 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
766 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
|
767 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
768 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
|
769 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
|
770 mask = XLFD_REGENC_MASK; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
771 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
772 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
|
773 mask = XLFD_ENCODING_MASK; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
774 } |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
775 else if (range_from <= XLFD_WEIGHT_INDEX |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
776 && range_to >= XLFD_WEIGHT_INDEX |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
777 && !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
|
778 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
|
779 else if (range_from <= XLFD_SLANT_INDEX |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
780 && range_to >= XLFD_SLANT_INDEX |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
781 && !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
|
782 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
|
783 else if (range_from <= XLFD_SWIDTH_INDEX |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
784 && range_to >= XLFD_SWIDTH_INDEX |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
785 && !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
|
786 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
|
787 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
788 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
789 if (EQ (val, Qc) || EQ (val, Qm) || EQ (val, Qp) || EQ (val, Qd)) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
790 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
|
791 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
792 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
|
793 mask = XLFD_SYMBOL_MASK; |
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 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
796 /* 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
|
797 mask &= range_mask; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
798 while (from < range_from) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
799 mask &= ~(1 << from++); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
800 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
|
801 from++; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
802 while (to > range_to) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
803 mask &= ~(1 << to--); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
804 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
|
805 to--; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
806 if (from > to) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
807 return -1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
808 range[i].from = from; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
809 range[i].to = to; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
810 range[i].mask = mask; |
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 (from > range_from || to < range_to) |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
813 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
814 /* The range is narrowed by value-based restrictions. |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
815 Reflect it to the other fields. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
816 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
817 /* Following fields should be after FROM. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
818 range_from = from; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
819 /* Preceding fields should be before TO. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
820 for (j = i - 1, from--, to--; j >= 0; j--, from--, to--) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
821 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
822 /* Check FROM for non-wildcard field. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
823 if (! NILP (tmp[j]) && range[j].from < from) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
824 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
825 while (range[j].from < from) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
826 range[j].mask &= ~(1 << range[j].from++); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
827 while (from < 14 && ! (range[j].mask & (1 << from))) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
828 from++; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
829 range[j].from = from; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
830 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
831 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
832 from = range[j].from; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
833 if (range[j].to > to) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
834 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
835 while (range[j].to > to) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
836 range[j].mask &= ~(1 << range[j].to--); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
837 while (to >= 0 && ! (range[j].mask & (1 << to))) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
838 to--; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
839 range[j].to = to; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
840 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
841 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
842 to = range[j].to; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
843 if (from > to) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
844 return -1; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
845 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
846 } |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
847 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
848 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
849 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
850 /* 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
|
851 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
|
852 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
853 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
|
854 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
855 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
|
856 /* 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
|
857 return -1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
858 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
|
859 field[j] = 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 field[j++] = tmp[i]; |
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 (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
|
864 return -1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
865 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
|
866 field[j] = Qnil; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
867 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
|
868 field[XLFD_ENCODING_INDEX] |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
869 = 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
|
870 return 0; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
871 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
872 |
92113
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
873 |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
874 #ifdef ENABLE_CHECKING |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
875 /* Match a 14-field XLFD pattern against a full XLFD font name. */ |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
876 static int |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
877 font_match_xlfd (char *pattern, char *name) |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
878 { |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
879 while (*pattern && *name) |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
880 { |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
881 if (*pattern == *name) |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
882 pattern++; |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
883 else if (*pattern == '*') |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
884 if (*name == pattern[1]) |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
885 pattern += 2; |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
886 else |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
887 ; |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
888 else |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
889 return 0; |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
890 name++; |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
891 } |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
892 return 1; |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
893 } |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
894 |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
895 /* Make sure the font object matches the XLFD font name. */ |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
896 static int |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
897 font_check_xlfd_parse (Lisp_Object font, char *name) |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
898 { |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
899 char name_check[256]; |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
900 font_unparse_xlfd (font, 0, name_check, 255); |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
901 return font_match_xlfd (name_check, name); |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
902 } |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
903 |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
904 #endif |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
905 |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
906 /* 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
|
907 (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
|
908 follows: |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
909 specified XLFD fields FONT property |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
910 --------------------- ------------- |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
911 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
|
912 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
|
913 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
|
914 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
915 If NAME is successfully parsed, return 0. Otherwise return -1. |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
916 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
917 FONT is usually a font-spec, but when this function is called from |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
918 X font backend driver, it is a font-entity. In that case, NAME is |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
919 a fully specified XLFD, and we set FONT_EXTRA_INDEX of FONT to a |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
920 symbol RESX-RESY-SPACING-AVGWIDTH. |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
921 */ |
90400 | 922 |
923 int | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
924 font_parse_xlfd (name, font) |
90400 | 925 char *name; |
926 Lisp_Object font; | |
927 { | |
928 int len = strlen (name); | |
929 int i, j; | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
930 Lisp_Object dpi, spacing; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
931 int avgwidth; |
90695
a1cd7344d6a2
(font_parse_xlfd): Fix the array size of `f'.
Kenichi Handa <handa@m17n.org>
parents:
90677
diff
changeset
|
932 char *f[XLFD_LAST_INDEX + 1]; |
90400 | 933 Lisp_Object val; |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
934 char *p; |
90400 | 935 |
936 if (len > 255) | |
937 /* Maximum XLFD name length is 255. */ | |
938 return -1; | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
939 /* Accept "*-.." as a fully specified XLFD. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
940 if (name[0] == '*' && name[1] == '-') |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
941 i = 1, f[XLFD_FOUNDRY_INDEX] = name; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
942 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
943 i = 0; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
944 for (p = name + i; *p; p++) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
945 if (*p == '-' && i < XLFD_LAST_INDEX) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
946 f[i++] = p + 1; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
947 f[i] = p; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
948 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
949 dpi = spacing = Qnil; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
950 avgwidth = -1; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
951 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
952 if (i == XLFD_LAST_INDEX) |
90400 | 953 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
954 int pixel_size; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
955 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
956 /* Fully specified XLFD. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
957 for (i = 0, j = FONT_FOUNDRY_INDEX; i < XLFD_WEIGHT_INDEX; i++, j++) |
90400 | 958 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
959 val = intern_font_field (f[i], f[i + 1] - 1 - f[i]); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
960 if (! NILP (val)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
961 ASET (font, j, val); |
90400 | 962 } |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
963 for (j = FONT_WEIGHT_INDEX; i < XLFD_ADSTYLE_INDEX; i++, j++) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
964 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
965 val = intern_font_field (f[i], f[i + 1] - 1 - f[i]); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
966 if (! NILP (val)) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
967 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
968 Lisp_Object numeric = prop_name_to_numeric (j, val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
969 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
970 if (INTEGERP (numeric)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
971 val = numeric; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
972 ASET (font, j, val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
973 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
974 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
975 val = intern_font_field (f[i], f[i + 1] - 1 - f[i]); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
976 if (! NILP (val)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
977 ASET (font, FONT_ADSTYLE_INDEX, val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
978 i = XLFD_REGISTRY_INDEX; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
979 val = intern_font_field (f[i], f[i + 2] - f[i]); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
980 if (! NILP (val)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
981 ASET (font, FONT_REGISTRY_INDEX, val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
982 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
983 p = f[XLFD_PIXEL_INDEX]; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
984 if (*p == '[' && (pixel_size = parse_matrix (p)) >= 0) |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
985 ASET (font, FONT_SIZE_INDEX, make_number (pixel_size)); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
986 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
987 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
988 i = XLFD_PIXEL_INDEX; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
989 val = intern_font_field (f[i], f[i + 1] - 1 - f[i]); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
990 if (! NILP (val)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
991 ASET (font, FONT_SIZE_INDEX, val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
992 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
993 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
994 double point_size = -1; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
995 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
996 xassert (FONT_SPEC_P (font)); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
997 p = f[XLFD_POINT_INDEX]; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
998 if (*p == '[') |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
999 point_size = parse_matrix (p); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1000 else if (isdigit (*p)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1001 point_size = atoi (p), point_size /= 10; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1002 if (point_size >= 0) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1003 ASET (font, FONT_SIZE_INDEX, make_float (point_size)); |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1004 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1005 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1006 i = XLFD_PIXEL_INDEX; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1007 val = intern_font_field (f[i], f[i + 1] - 1 - f[i]); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1008 if (! NILP (val)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1009 ASET (font, FONT_SIZE_INDEX, val); |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1010 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1011 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1012 } |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1013 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1014 /* Parse RESX, RESY, SPACING, and AVGWIDTH. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1015 if (FONT_ENTITY_P (font)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1016 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1017 i = XLFD_RESX_INDEX; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1018 ASET (font, FONT_EXTRA_INDEX, |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1019 intern_font_field (f[i], f[XLFD_REGISTRY_INDEX] - 1 - f[i])); |
92113
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
1020 eassert (font_check_xlfd_parse (font, name)); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1021 return 0; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1022 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1023 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1024 /* Here we just setup DPI, SPACING, and AVGWIDTH. They are set |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1025 in FONT_EXTRA_INDEX later. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1026 i = XLFD_RESX_INDEX; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1027 dpi = intern_font_field (f[i], f[i + 1] - 1 - f[i]); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1028 i = XLFD_SPACING_INDEX; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1029 spacing = intern_font_field (f[i], f[i + 1] - 1 - f[i]); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1030 p = f[XLFD_AVGWIDTH_INDEX]; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1031 if (*p == '~') |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1032 p++; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1033 if (isdigit (*p)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1034 avgwidth = atoi (p); |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1035 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1036 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1037 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1038 int wild_card_found = 0; |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1039 Lisp_Object prop[XLFD_LAST_INDEX]; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1040 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1041 for (j = 0; j < i; j++) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1042 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1043 if (*f[j] == '*') |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1044 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1045 if (f[j][1] && f[j][1] != '-') |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1046 return -1; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1047 prop[j] = Qnil; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1048 wild_card_found = 1; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1049 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1050 else if (isdigit (*f[j])) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1051 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1052 for (p = f[j] + 1; isdigit (*p); p++); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1053 if (*p && *p != '-') |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1054 prop[j] = intern_downcase (f[j], p - f[j]); |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1055 else |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1056 prop[j] = make_number (atoi (f[j])); |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1057 } |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1058 else if (j + 1 < i) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1059 prop[j] = intern_font_field (f[j], f[j + 1] - 1 - f[j]); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1060 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1061 prop[j] = intern_font_field (f[j], f[i] - f[j]); |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1062 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1063 if (! wild_card_found) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1064 return -1; |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1065 if (font_expand_wildcards (prop, i) < 0) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1066 return -1; |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1067 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1068 for (i = 0, j = FONT_FOUNDRY_INDEX; i < XLFD_WEIGHT_INDEX; i++, j++) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1069 if (! NILP (prop[i])) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1070 ASET (font, j, prop[i]); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1071 for (j = FONT_WEIGHT_INDEX; i < XLFD_ADSTYLE_INDEX; i++, j++) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1072 if (! NILP (prop[i])) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1073 ASET (font, j, prop[i]); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1074 if (! NILP (prop[XLFD_ADSTYLE_INDEX])) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1075 ASET (font, FONT_ADSTYLE_INDEX, prop[XLFD_ADSTYLE_INDEX]); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1076 val = prop[XLFD_REGISTRY_INDEX]; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1077 if (NILP (val)) |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1078 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1079 val = prop[XLFD_ENCODING_INDEX]; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1080 if (! NILP (val)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1081 val = Fintern (concat2 (build_string ("*-"), SYMBOL_NAME (val)), |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1082 Qnil); |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1083 } |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1084 else if (NILP (prop[XLFD_ENCODING_INDEX])) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1085 val = Fintern (concat2 (SYMBOL_NAME (val), build_string ("-*")), |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1086 Qnil); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1087 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1088 val = Fintern (concat3 (SYMBOL_NAME (val), build_string ("-"), |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1089 SYMBOL_NAME (prop[XLFD_ENCODING_INDEX])), |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1090 Qnil); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1091 if (! NILP (val)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1092 ASET (font, FONT_REGISTRY_INDEX, val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1093 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1094 if (INTEGERP (prop[XLFD_PIXEL_INDEX])) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1095 ASET (font, FONT_SIZE_INDEX, prop[XLFD_PIXEL_INDEX]); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1096 else if (INTEGERP (prop[XLFD_POINT_INDEX])) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1097 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1098 double point_size = XINT (prop[XLFD_POINT_INDEX]); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1099 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1100 ASET (font, FONT_SIZE_INDEX, make_float (point_size / 10)); |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1101 } |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1102 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1103 dpi = prop[XLFD_RESX_INDEX]; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1104 spacing = prop[XLFD_SPACING_INDEX]; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1105 if (INTEGERP (prop[XLFD_AVGWIDTH_INDEX])) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1106 avgwidth = XINT (prop[XLFD_AVGWIDTH_INDEX]); |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1107 } |
90400 | 1108 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1109 if (! NILP (dpi)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1110 font_put_extra (font, QCdpi, dpi); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1111 if (! NILP (spacing)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1112 font_put_extra (font, QCspacing, spacing); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1113 if (avgwidth >= 0) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1114 font_put_extra (font, QCscalable, avgwidth == 0 ? Qt : Qnil); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1115 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1116 return 0; |
90400 | 1117 } |
1118 | |
1119 /* Store XLFD name of FONT (font-spec or font-entity) in NAME (NBYTES | |
1120 length), and return the name length. If FONT_SIZE_INDEX of FONT is | |
1121 0, use PIXEL_SIZE instead. */ | |
1122 | |
1123 int | |
1124 font_unparse_xlfd (font, pixel_size, name, nbytes) | |
1125 Lisp_Object font; | |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1126 int pixel_size; |
90400 | 1127 char *name; |
1128 int nbytes; | |
1129 { | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1130 char *f[XLFD_REGISTRY_INDEX + 1]; |
90400 | 1131 Lisp_Object val; |
1132 int i, j, len = 0; | |
1133 | |
1134 xassert (FONTP (font)); | |
1135 | |
1136 for (i = FONT_FOUNDRY_INDEX, j = XLFD_FOUNDRY_INDEX; i <= FONT_REGISTRY_INDEX; | |
1137 i++, j++) | |
1138 { | |
1139 if (i == FONT_ADSTYLE_INDEX) | |
1140 j = XLFD_ADSTYLE_INDEX; | |
1141 else if (i == FONT_REGISTRY_INDEX) | |
1142 j = XLFD_REGISTRY_INDEX; | |
1143 val = AREF (font, i); | |
1144 if (NILP (val)) | |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1145 { |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1146 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
|
1147 f[j] = "*-*", len += 4; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1148 else |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1149 f[j] = "*", len += 2; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1150 } |
90400 | 1151 else |
1152 { | |
1153 if (SYMBOLP (val)) | |
1154 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
|
1155 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
|
1156 && ! strchr ((char *) SDATA (val), '-')) |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1157 { |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1158 /* 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
|
1159 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
|
1160 { |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1161 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
|
1162 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
|
1163 len += SBYTES (val) + 3; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1164 } |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1165 else |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1166 { |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1167 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
|
1168 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
|
1169 len += SBYTES (val) + 4; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1170 } |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1171 } |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1172 else |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1173 f[j] = (char *) SDATA (val), len += SBYTES (val) + 1; |
90400 | 1174 } |
1175 } | |
1176 | |
1177 for (i = FONT_WEIGHT_INDEX, j = XLFD_WEIGHT_INDEX; i <= FONT_WIDTH_INDEX; | |
1178 i++, j++) | |
1179 { | |
1180 val = AREF (font, i); | |
1181 if (NILP (val)) | |
1182 f[j] = "*", len += 2; | |
1183 else | |
1184 { | |
1185 if (INTEGERP (val)) | |
1186 val = prop_numeric_to_name (i, XINT (val)); | |
1187 if (SYMBOLP (val)) | |
1188 val = SYMBOL_NAME (val); | |
1189 xassert (STRINGP (val)); | |
1190 f[j] = (char *) SDATA (val), len += SBYTES (val) + 1; | |
1191 } | |
1192 } | |
1193 | |
1194 val = AREF (font, FONT_SIZE_INDEX); | |
1195 xassert (NUMBERP (val) || NILP (val)); | |
1196 if (INTEGERP (val)) | |
1197 { | |
91943
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1198 int i = XINT (val); |
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1199 if (i <= 0) |
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1200 i = pixel_size; |
90400 | 1201 if (i > 0) |
91943
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1202 { |
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1203 f[XLFD_PIXEL_INDEX] = alloca (22); |
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1204 len += sprintf (f[XLFD_PIXEL_INDEX], "%d-*", i) + 1; |
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1205 } |
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1206 else |
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1207 f[XLFD_PIXEL_INDEX] = "*-*", len += 4; |
90400 | 1208 } |
1209 else if (FLOATP (val)) | |
1210 { | |
91943
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1211 int i = XFLOAT_DATA (val) * 10; |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1212 f[XLFD_PIXEL_INDEX] = alloca (12); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1213 len += sprintf (f[XLFD_PIXEL_INDEX], "*-%d", i) + 1; |
90400 | 1214 } |
1215 else | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1216 f[XLFD_PIXEL_INDEX] = "*-*", len += 4; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1217 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1218 val = AREF (font, FONT_EXTRA_INDEX); |
90400 | 1219 |
1220 if (FONT_ENTITY_P (font) | |
1221 && EQ (AREF (font, FONT_TYPE_INDEX), Qx)) | |
1222 { | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1223 /* Setup names for RESX-RESY-SPACING-AVWIDTH. */ |
90400 | 1224 if (SYMBOLP (val) && ! NILP (val)) |
1225 { | |
1226 val = SYMBOL_NAME (val); | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1227 f[XLFD_RESX_INDEX] = (char *) SDATA (val), len += SBYTES (val) + 1; |
90400 | 1228 } |
1229 else | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1230 f[XLFD_RESX_INDEX] = "*-*-*-*", len += 6; |
90400 | 1231 } |
1232 else | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1233 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1234 Lisp_Object dpi = assq_no_quit (QCdpi, val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1235 Lisp_Object spacing = assq_no_quit (QCspacing, val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1236 Lisp_Object scalable = assq_no_quit (QCscalable, val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1237 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1238 if (CONSP (dpi) || CONSP (spacing) || CONSP (scalable)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1239 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1240 char *str = alloca (24); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1241 int this_len; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1242 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1243 if (CONSP (dpi) && INTEGERP (XCDR (dpi))) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1244 this_len = sprintf (str, "%d-%d", |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1245 XINT (XCDR (dpi)), XINT (XCDR (dpi))); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1246 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1247 this_len = sprintf (str, "*-*"); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1248 if (CONSP (spacing) && ! NILP (XCDR (spacing))) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1249 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1250 val = XCDR (spacing); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1251 if (INTEGERP (val)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1252 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1253 if (XINT (val) < FONT_SPACING_MONO) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1254 val = Qp; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1255 else if (XINT (val) < FONT_SPACING_CHARCELL) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1256 val = Qm; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1257 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1258 val = Qc; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1259 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1260 xassert (SYMBOLP (val)); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1261 this_len += sprintf (str + this_len, "-%c", |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1262 SDATA (SYMBOL_NAME (val))[0]); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1263 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1264 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1265 this_len += sprintf (str + this_len, "-*"); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1266 if (CONSP (scalable) && ! NILP (XCDR (spacing))) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1267 this_len += sprintf (str + this_len, "-0"); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1268 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1269 this_len += sprintf (str + this_len, "-*"); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1270 f[XLFD_RESX_INDEX] = str; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1271 len += this_len; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1272 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1273 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1274 f[XLFD_RESX_INDEX] = "*-*-*-*", len += 8; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1275 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1276 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1277 len++; /* for terminating '\0'. */ |
90400 | 1278 if (len >= nbytes) |
1279 return -1; | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1280 return sprintf (name, "-%s-%s-%s-%s-%s-%s-%s-%s-%s", |
90400 | 1281 f[XLFD_FOUNDRY_INDEX], f[XLFD_FAMILY_INDEX], |
1282 f[XLFD_WEIGHT_INDEX], f[XLFD_SLANT_INDEX], | |
1283 f[XLFD_SWIDTH_INDEX], | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1284 f[XLFD_ADSTYLE_INDEX], f[XLFD_PIXEL_INDEX], |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1285 f[XLFD_RESX_INDEX], f[XLFD_REGISTRY_INDEX]); |
90400 | 1286 } |
1287 | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1288 /* 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
|
1289 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
|
1290 successfully parsed, return 0. Otherwise return -1. */ |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1291 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1292 int |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1293 font_parse_fcname (name, font) |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1294 char *name; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1295 Lisp_Object font; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1296 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1297 char *p0, *p1; |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1298 int len = strlen (name); |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1299 char *copy; |
91261
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1300 int weight_set = 0; |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1301 int slant_set = 0; |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1302 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1303 if (len == 0) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1304 return -1; |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1305 /* It is assured that (name[0] && name[0] != '-'). */ |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1306 if (name[0] == ':') |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1307 p0 = name; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1308 else |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1309 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1310 Lisp_Object family; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1311 double point_size; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1312 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1313 for (p0 = name + 1; *p0 && (*p0 != '-' && *p0 != ':'); p0++) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1314 if (*p0 == '\\' && p0[1]) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1315 p0++; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1316 family = intern_font_field (name, p0 - name); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1317 if (*p0 == '-') |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1318 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1319 if (! isdigit (p0[1])) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1320 return -1; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1321 point_size = strtod (p0 + 1, &p1); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1322 if (*p1 && *p1 != ':') |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1323 return -1; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1324 ASET (font, FONT_SIZE_INDEX, make_float (point_size)); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1325 p0 = p1; |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1326 } |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1327 ASET (font, FONT_FAMILY_INDEX, family); |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1328 } |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1329 |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1330 len -= p0 - name; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1331 copy = alloca (len + 1); |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1332 if (! copy) |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1333 return -1; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1334 name = copy; |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
1335 |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1336 /* 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
|
1337 extra, copy unknown ones to COPY. */ |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1338 while (*p0) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1339 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1340 Lisp_Object key, val; |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1341 int prop; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1342 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1343 for (p1 = p0 + 1; *p1 && *p1 != '=' && *p1 != ':'; p1++); |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1344 if (*p1 != '=') |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1345 { |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1346 /* Must be an enumerated value. */ |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1347 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
|
1348 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
|
1349 || 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
|
1350 || 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
|
1351 || 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
|
1352 || 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
|
1353 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1354 ASET (font, FONT_WEIGHT_INDEX, val); |
91261
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1355 weight_set = 1; |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1356 } |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1357 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
|
1358 || 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
|
1359 || 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
|
1360 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1361 ASET (font, FONT_SLANT_INDEX, val); |
91261
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1362 slant_set = 1; |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1363 } |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1364 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
|
1365 || 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
|
1366 || 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
|
1367 { |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1368 font_put_extra (font, QCspacing, |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1369 (p0[1] == 'c' ? Qc : p0[1] == 'm' ? Qm : Qp)); |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1370 } |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1371 else |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1372 { |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1373 /* unknown key */ |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1374 bcopy (p0, copy, p1 - p0); |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1375 copy += p1 - p0; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1376 } |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1377 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1378 else |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1379 { |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1380 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
|
1381 prop = FONT_SIZE_INDEX; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1382 else |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1383 { |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1384 key = intern_font_field (p0, p1 - p0); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1385 prop = get_font_prop_index (key, 0); |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1386 } |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1387 p0 = p1 + 1; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1388 for (p1 = p0; *p1 && *p1 != ':'; p1++); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1389 val = intern_font_field (p0, p1 - p0); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1390 if (! NILP (val)) |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1391 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1392 if (prop >= 0 && prop < FONT_EXTRA_INDEX) |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1393 { |
91261
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1394 if (prop == FONT_WEIGHT_INDEX) |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1395 weight_set = 1; |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1396 else if (prop == FONT_SLANT_INDEX) |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1397 slant_set = 1; |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1398 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1399 ASET (font, prop, val); |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1400 } |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1401 else |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1402 font_put_extra (font, key, val); |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1403 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1404 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1405 p0 = p1; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1406 } |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1407 |
91261
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1408 if (!weight_set) |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1409 ASET (font, FONT_WEIGHT_INDEX, build_string ("normal")); |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1410 if (!slant_set) |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1411 ASET (font, FONT_SLANT_INDEX, build_string ("normal")); |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1412 |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1413 return 0; |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1414 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1415 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1416 /* 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
|
1417 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
|
1418 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
|
1419 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1420 int |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1421 font_unparse_fcname (font, pixel_size, name, nbytes) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1422 Lisp_Object font; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1423 int pixel_size; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1424 char *name; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1425 int nbytes; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1426 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1427 Lisp_Object val; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1428 int point_size; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1429 int dpi, spacing, scalable; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1430 int i, len = 1; |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1431 char *p; |
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1432 Lisp_Object styles[3]; |
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
1433 char *style_names[3] = { "weight", "slant", "width" }; |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1434 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1435 val = AREF (font, FONT_FAMILY_INDEX); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1436 if (SYMBOLP (val) && ! NILP (val)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1437 len += SBYTES (SYMBOL_NAME (val)); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1438 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1439 val = AREF (font, FONT_SIZE_INDEX); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1440 if (INTEGERP (val)) |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1441 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1442 if (XINT (val) != 0) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1443 pixel_size = XINT (val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1444 point_size = -1; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1445 len += 21; /* for ":pixelsize=NUM" */ |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1446 } |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1447 else if (FLOATP (val)) |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1448 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1449 pixel_size = -1; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1450 point_size = (int) XFLOAT_DATA (val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1451 len += 11; /* for "-NUM" */ |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1452 } |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1453 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1454 val = AREF (font, FONT_FOUNDRY_INDEX); |
90629
c4849318378c
(font_unparse_fcname): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
90622
diff
changeset
|
1455 if (SYMBOLP (val) && ! NILP (val)) |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1456 /* ":foundry=NAME" */ |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1457 len += 9 + SBYTES (SYMBOL_NAME (val)); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1458 |
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1459 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
|
1460 { |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1461 val = AREF (font, i); |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1462 if (INTEGERP (val)) |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1463 { |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1464 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
|
1465 } |
92381
edc3ba5b9670
(font_unparse_fcname): Increase len when style is a symbol.
Jason Rumney <jasonr@gnu.org>
parents:
92237
diff
changeset
|
1466 if (SYMBOLP (val) && ! NILP (val)) |
edc3ba5b9670
(font_unparse_fcname): Increase len when style is a symbol.
Jason Rumney <jasonr@gnu.org>
parents:
92237
diff
changeset
|
1467 len += (strlen (style_names[i - FONT_WEIGHT_INDEX]) |
edc3ba5b9670
(font_unparse_fcname): Increase len when style is a symbol.
Jason Rumney <jasonr@gnu.org>
parents:
92237
diff
changeset
|
1468 + 2 + SBYTES (SYMBOL_NAME (val))); /* :xxx=NAME */ |
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1469 styles[i - FONT_WEIGHT_INDEX] = val; |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1470 } |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1471 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1472 val = AREF (font, FONT_EXTRA_INDEX); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1473 if (FONT_ENTITY_P (font) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1474 && EQ (AREF (font, FONT_TYPE_INDEX), Qx)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1475 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1476 char *p; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1477 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1478 /* VAL is a symbol of name `RESX-RESY-SPACING-AVWIDTH'. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1479 p = (char *) SDATA (SYMBOL_NAME (val)); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1480 dpi = atoi (p); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1481 for (p++; *p != '-'; p++); /* skip RESX */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1482 for (p++; *p != '-'; p++); /* skip RESY */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1483 spacing = (*p == 'c' ? FONT_SPACING_CHARCELL |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1484 : *p == 'm' ? FONT_SPACING_MONO |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1485 : FONT_SPACING_PROPORTIONAL); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1486 for (p++; *p != '-'; p++); /* skip SPACING */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1487 scalable = (atoi (p) == 0); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1488 /* The longest pattern is ":dpi=NUM:scalable=False:spacing=100" */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1489 len += 42; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1490 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1491 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1492 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1493 Lisp_Object elt; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1494 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1495 dpi = spacing = scalable = -1; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1496 elt = assq_no_quit (QCdpi, val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1497 if (CONSP (elt)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1498 dpi = XINT (XCDR (elt)), len += 15; /* for ":dpi=NUM" */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1499 elt = assq_no_quit (QCspacing, val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1500 if (CONSP (elt)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1501 spacing = XINT (XCDR (elt)), len += 12; /* for ":spacing=100" */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1502 elt = assq_no_quit (QCscalable, val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1503 if (CONSP (elt)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1504 scalable = ! NILP (XCDR (elt)), len += 15; /* for ":scalable=False" */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1505 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1506 |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1507 if (len > nbytes) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1508 return -1; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1509 p = name; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1510 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
|
1511 p += sprintf(p, "%s", |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1512 SDATA (SYMBOL_NAME (AREF (font, FONT_FAMILY_INDEX)))); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1513 if (point_size > 0) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1514 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1515 if (p == name) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1516 p += sprintf (p, "%d", point_size); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1517 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1518 p += sprintf (p, "-%d", point_size); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1519 } |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1520 else if (pixel_size > 0) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1521 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
|
1522 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
|
1523 && ! NILP (AREF (font, FONT_FOUNDRY_INDEX))) |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1524 p += sprintf (p, ":foundry=%s", |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1525 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
|
1526 for (i = 0; i < 3; i++) |
90640
bbc1344cea0e
(font_unparse_fcname): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
90629
diff
changeset
|
1527 if (SYMBOLP (styles[i]) && ! NILP (styles [i])) |
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1528 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
|
1529 SDATA (SYMBOL_NAME (styles [i]))); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1530 if (dpi >= 0) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1531 p += sprintf (p, ":dpi=%d", dpi); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1532 if (spacing >= 0) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1533 p += sprintf (p, ":spacing=%d", spacing); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1534 if (scalable > 0) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1535 p += sprintf (p, ":scalable=True"); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1536 else if (scalable == 0) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1537 p += sprintf (p, ":scalable=False"); |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1538 return (p - name); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1539 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1540 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1541 /* 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
|
1542 (font-spec or font-entity). If NAME is successfully parsed, return |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1543 0. Otherwise return -1. |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1544 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1545 If NAME is XLFD and FONT is a font-entity, store |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1546 RESX-RESY-SPACING-AVWIDTH information as a symbol in |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1547 FONT_EXTRA_INDEX. */ |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1548 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1549 static int |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1550 font_parse_name (name, font) |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1551 char *name; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1552 Lisp_Object font; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1553 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1554 if (name[0] == '-' || index (name, '*')) |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1555 return font_parse_xlfd (name, font); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1556 return font_parse_fcname (name, font); |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1557 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1558 |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
1559 /* Merge old style font specification (either a font name NAME or a |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
1560 combination of a family name FAMILY and a registry name REGISTRY |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
1561 into the font specification SPEC. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
1562 |
90400 | 1563 void |
1564 font_merge_old_spec (name, family, registry, spec) | |
1565 Lisp_Object name, family, registry, spec; | |
1566 { | |
1567 if (STRINGP (name)) | |
1568 { | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1569 if (font_parse_xlfd ((char *) SDATA (name), spec) < 0) |
90400 | 1570 { |
1571 Lisp_Object extra = Fcons (Fcons (QCname, name), Qnil); | |
1572 | |
1573 ASET (spec, FONT_EXTRA_INDEX, extra); | |
1574 } | |
1575 } | |
1576 else | |
1577 { | |
1578 if (! NILP (family)) | |
1579 { | |
1580 int len; | |
1581 char *p0, *p1; | |
1582 | |
1583 xassert (STRINGP (family)); | |
1584 len = SBYTES (family); | |
1585 p0 = (char *) SDATA (family); | |
1586 p1 = index (p0, '-'); | |
1587 if (p1) | |
1588 { | |
90530
76d717f9ceda
(font_merge_old_spec): Treat '*' in foundry as a wild
Kenichi Handa <handa@m17n.org>
parents:
90507
diff
changeset
|
1589 if ((*p0 != '*' || p1 - p0 > 1) |
76d717f9ceda
(font_merge_old_spec): Treat '*' in foundry as a wild
Kenichi Handa <handa@m17n.org>
parents:
90507
diff
changeset
|
1590 && NILP (AREF (spec, FONT_FOUNDRY_INDEX))) |
90400 | 1591 ASET (spec, FONT_FOUNDRY_INDEX, |
1592 intern_downcase (p0, p1 - p0)); | |
1593 if (NILP (AREF (spec, FONT_FAMILY_INDEX))) | |
1594 ASET (spec, FONT_FAMILY_INDEX, | |
1595 intern_downcase (p1 + 1, len - (p1 + 1 - p0))); | |
1596 } | |
1597 else if (NILP (AREF (spec, FONT_FAMILY_INDEX))) | |
1598 ASET (spec, FONT_FAMILY_INDEX, intern_downcase (p0, len)); | |
1599 } | |
1600 if (! NILP (registry) | |
1601 && NILP (AREF (spec, FONT_REGISTRY_INDEX))) | |
1602 ASET (spec, FONT_REGISTRY_INDEX, | |
1603 intern_downcase ((char *) SDATA (registry), SBYTES (registry))); | |
1604 } | |
1605 } | |
1606 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
1607 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
1608 /* This part (through the next ^L) is still experimental and never |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
1609 tested. We may drastically change codes. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
1610 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
1611 /* OTF handler */ |
90541 | 1612 |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1613 #define LGSTRING_HEADER_SIZE 6 |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1614 #define LGSTRING_GLYPH_SIZE 8 |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1615 |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1616 static int |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1617 check_gstring (gstring) |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1618 Lisp_Object gstring; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1619 { |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1620 Lisp_Object val; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1621 int i, j; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1622 |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1623 CHECK_VECTOR (gstring); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1624 val = AREF (gstring, 0); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1625 CHECK_VECTOR (val); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1626 if (ASIZE (val) < LGSTRING_HEADER_SIZE) |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1627 goto err; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1628 CHECK_FONT_OBJECT (LGSTRING_FONT (gstring)); |
91550
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1629 if (!NILP (LGSTRING_SLOT (gstring, LGSTRING_IX_LBEARING))) |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1630 CHECK_NUMBER (LGSTRING_SLOT (gstring, LGSTRING_IX_LBEARING)); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1631 if (!NILP (LGSTRING_SLOT (gstring, LGSTRING_IX_RBEARING))) |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1632 CHECK_NUMBER (LGSTRING_SLOT (gstring, LGSTRING_IX_RBEARING)); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1633 if (!NILP (LGSTRING_SLOT (gstring, LGSTRING_IX_WIDTH))) |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1634 CHECK_NATNUM (LGSTRING_SLOT (gstring, LGSTRING_IX_WIDTH)); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1635 if (!NILP (LGSTRING_SLOT (gstring, LGSTRING_IX_ASCENT))) |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1636 CHECK_NUMBER (LGSTRING_SLOT (gstring, LGSTRING_IX_ASCENT)); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1637 if (!NILP (LGSTRING_SLOT (gstring, LGSTRING_IX_ASCENT))) |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1638 CHECK_NUMBER (LGSTRING_SLOT (gstring, LGSTRING_IX_ASCENT)); |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1639 |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1640 for (i = 0; i < LGSTRING_LENGTH (gstring); i++) |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1641 { |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1642 val = LGSTRING_GLYPH (gstring, i); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1643 CHECK_VECTOR (val); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1644 if (ASIZE (val) < LGSTRING_GLYPH_SIZE) |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1645 goto err; |
91550
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1646 if (NILP (AREF (val, LGLYPH_IX_CHAR))) |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1647 break; |
91550
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1648 CHECK_NATNUM (AREF (val, LGLYPH_IX_FROM)); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1649 CHECK_NATNUM (AREF (val, LGLYPH_IX_TO)); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1650 CHECK_CHARACTER (AREF (val, LGLYPH_IX_CHAR)); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1651 if (!NILP (AREF (val, LGLYPH_IX_CODE))) |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1652 CHECK_NATNUM (AREF (val, LGLYPH_IX_CODE)); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1653 if (!NILP (AREF (val, LGLYPH_IX_WIDTH))) |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1654 CHECK_NATNUM (AREF (val, LGLYPH_IX_WIDTH)); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1655 if (!NILP (AREF (val, LGLYPH_IX_ADJUSTMENT))) |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1656 { |
91550
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1657 val = AREF (val, LGLYPH_IX_ADJUSTMENT); |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1658 CHECK_VECTOR (val); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1659 if (ASIZE (val) < 3) |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1660 goto err; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1661 for (j = 0; j < 3; j++) |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1662 CHECK_NUMBER (AREF (val, j)); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1663 } |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1664 } |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1665 return i; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1666 err: |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1667 error ("Invalid glyph-string format"); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1668 return -1; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1669 } |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1670 |
90823
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1671 static void |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1672 check_otf_features (otf_features) |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1673 Lisp_Object otf_features; |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1674 { |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1675 Lisp_Object val, elt; |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1676 |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1677 CHECK_CONS (otf_features); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1678 CHECK_SYMBOL (XCAR (otf_features)); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1679 otf_features = XCDR (otf_features); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1680 CHECK_CONS (otf_features); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1681 CHECK_SYMBOL (XCAR (otf_features)); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1682 otf_features = XCDR (otf_features); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1683 for (val = Fcar (otf_features); ! NILP (val); val = Fcdr (val)) |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1684 { |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1685 CHECK_SYMBOL (Fcar (val)); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1686 if (SBYTES (SYMBOL_NAME (XCAR (val))) > 4) |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1687 error ("Invalid OTF GSUB feature: %s", SYMBOL_NAME (XCAR (val))); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1688 } |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1689 otf_features = XCDR (otf_features); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1690 for (val = Fcar (otf_features); ! NILP (val); val = Fcdr (val)) |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1691 { |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1692 CHECK_SYMBOL (Fcar (val)); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1693 if (SBYTES (SYMBOL_NAME (XCAR (val))) > 4) |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1694 error ("Invalid OTF GPOS feature: %s", SYMBOL_NAME (XCAR (val))); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1695 } |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1696 } |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1697 |
90400 | 1698 #ifdef HAVE_LIBOTF |
1699 #include <otf.h> | |
1700 | |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1701 Lisp_Object otf_list; |
90400 | 1702 |
1703 static Lisp_Object | |
1704 otf_tag_symbol (tag) | |
1705 OTF_Tag tag; | |
1706 { | |
1707 char name[5]; | |
1708 | |
1709 OTF_tag_name (tag, name); | |
1710 return Fintern (make_unibyte_string (name, 4), Qnil); | |
1711 } | |
1712 | |
1713 static OTF * | |
1714 otf_open (entity, file) | |
1715 Lisp_Object entity; | |
1716 char *file; | |
1717 { | |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1718 Lisp_Object val = Fassoc (entity, otf_list); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1719 OTF *otf; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1720 |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1721 if (! NILP (val)) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1722 otf = XSAVE_VALUE (XCDR (val))->pointer; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1723 else |
90400 | 1724 { |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1725 otf = file ? OTF_open (file) : NULL; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1726 val = make_save_value (otf, 0); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1727 otf_list = Fcons (Fcons (entity, val), otf_list); |
90400 | 1728 } |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1729 return otf; |
90400 | 1730 } |
1731 | |
1732 | |
1733 /* Return a list describing which scripts/languages FONT supports by | |
1734 which GSUB/GPOS features of OpenType tables. See the comment of | |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
1735 (struct font_driver).otf_capability. */ |
90400 | 1736 |
1737 Lisp_Object | |
1738 font_otf_capability (font) | |
1739 struct font *font; | |
1740 { | |
1741 OTF *otf; | |
1742 Lisp_Object capability = Fcons (Qnil, Qnil); | |
1743 int i; | |
1744 | |
1745 otf = otf_open (font->entity, font->file_name); | |
1746 if (! otf) | |
1747 return Qnil; | |
1748 for (i = 0; i < 2; i++) | |
1749 { | |
1750 OTF_GSUB_GPOS *gsub_gpos; | |
1751 Lisp_Object script_list = Qnil; | |
1752 int j; | |
1753 | |
1754 if (OTF_get_features (otf, i == 0) < 0) | |
1755 continue; | |
1756 gsub_gpos = i == 0 ? otf->gsub : otf->gpos; | |
1757 for (j = gsub_gpos->ScriptList.ScriptCount - 1; j >= 0; j--) | |
1758 { | |
1759 OTF_Script *script = gsub_gpos->ScriptList.Script + j; | |
1760 Lisp_Object langsys_list = Qnil; | |
1761 Lisp_Object script_tag = otf_tag_symbol (script->ScriptTag); | |
1762 int k; | |
1763 | |
1764 for (k = script->LangSysCount; k >= 0; k--) | |
1765 { | |
1766 OTF_LangSys *langsys; | |
1767 Lisp_Object feature_list = Qnil; | |
1768 Lisp_Object langsys_tag; | |
1769 int l; | |
1770 | |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1771 if (k == script->LangSysCount) |
90400 | 1772 { |
1773 langsys = &script->DefaultLangSys; | |
1774 langsys_tag = Qnil; | |
1775 } | |
1776 else | |
1777 { | |
1778 langsys = script->LangSys + k; | |
1779 langsys_tag | |
1780 = otf_tag_symbol (script->LangSysRecord[k].LangSysTag); | |
1781 } | |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1782 for (l = langsys->FeatureCount - 1; l >= 0; l--) |
90400 | 1783 { |
1784 OTF_Feature *feature | |
1785 = gsub_gpos->FeatureList.Feature + langsys->FeatureIndex[l]; | |
1786 Lisp_Object feature_tag | |
1787 = otf_tag_symbol (feature->FeatureTag); | |
1788 | |
1789 feature_list = Fcons (feature_tag, feature_list); | |
1790 } | |
1791 langsys_list = Fcons (Fcons (langsys_tag, feature_list), | |
1792 langsys_list); | |
1793 } | |
1794 script_list = Fcons (Fcons (script_tag, langsys_list), | |
1795 script_list); | |
1796 } | |
1797 | |
1798 if (i == 0) | |
1799 XSETCAR (capability, script_list); | |
1800 else | |
1801 XSETCDR (capability, script_list); | |
1802 } | |
1803 | |
1804 return capability; | |
1805 } | |
1806 | |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1807 /* Parse OTF features in SPEC and write a proper features spec string |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1808 in FEATURES for the call of OTF_drive_gsub/gpos (of libotf). It is |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1809 assured that the sufficient memory has already allocated for |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1810 FEATURES. */ |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1811 |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1812 static void |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1813 generate_otf_features (spec, features) |
90400 | 1814 Lisp_Object spec; |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1815 char *features; |
90400 | 1816 { |
1817 Lisp_Object val; | |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1818 char *p, *pend; |
90400 | 1819 int asterisk; |
1820 | |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1821 p = features; |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1822 *p = '\0'; |
90400 | 1823 for (asterisk = 0; CONSP (spec); spec = XCDR (spec)) |
1824 { | |
1825 val = XCAR (spec); | |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1826 CHECK_SYMBOL (val); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1827 if (p > features) |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1828 *p++ = ','; |
90400 | 1829 if (SREF (SYMBOL_NAME (val), 0) == '*') |
1830 { | |
1831 asterisk = 1; | |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1832 *p++ = '*'; |
90400 | 1833 } |
1834 else if (! asterisk) | |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1835 { |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1836 val = SYMBOL_NAME (val); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1837 p += sprintf (p, "%s", SDATA (val)); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1838 } |
90400 | 1839 else |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1840 { |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1841 val = SYMBOL_NAME (val); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1842 p += sprintf (p, "~%s", SDATA (val)); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1843 } |
90400 | 1844 } |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1845 if (CONSP (spec)) |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1846 error ("OTF spec too long"); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1847 } |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1848 |
90400 | 1849 |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1850 Lisp_Object |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1851 font_otf_DeviceTable (device_table) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1852 OTF_DeviceTable *device_table; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1853 { |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1854 int len = device_table->StartSize - device_table->EndSize + 1; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1855 |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1856 return Fcons (make_number (len), |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1857 make_unibyte_string (device_table->DeltaValue, len)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1858 } |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1859 |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1860 Lisp_Object |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1861 font_otf_ValueRecord (value_format, value_record) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1862 int value_format; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1863 OTF_ValueRecord *value_record; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1864 { |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1865 Lisp_Object val = Fmake_vector (make_number (8), Qnil); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1866 |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1867 if (value_format & OTF_XPlacement) |
91909 | 1868 ASET (val, 0, make_number (value_record->XPlacement)); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1869 if (value_format & OTF_YPlacement) |
91909 | 1870 ASET (val, 1, make_number (value_record->YPlacement)); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1871 if (value_format & OTF_XAdvance) |
91909 | 1872 ASET (val, 2, make_number (value_record->XAdvance)); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1873 if (value_format & OTF_YAdvance) |
91909 | 1874 ASET (val, 3, make_number (value_record->YAdvance)); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1875 if (value_format & OTF_XPlaDevice) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1876 ASET (val, 4, font_otf_DeviceTable (&value_record->XPlaDevice)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1877 if (value_format & OTF_YPlaDevice) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1878 ASET (val, 4, font_otf_DeviceTable (&value_record->YPlaDevice)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1879 if (value_format & OTF_XAdvDevice) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1880 ASET (val, 4, font_otf_DeviceTable (&value_record->XAdvDevice)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1881 if (value_format & OTF_YAdvDevice) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1882 ASET (val, 4, font_otf_DeviceTable (&value_record->YAdvDevice)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1883 return val; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1884 } |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1885 |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1886 Lisp_Object |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1887 font_otf_Anchor (anchor) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1888 OTF_Anchor *anchor; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1889 { |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1890 Lisp_Object val; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1891 |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1892 val = Fmake_vector (make_number (anchor->AnchorFormat + 1), Qnil); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1893 ASET (val, 0, make_number (anchor->XCoordinate)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1894 ASET (val, 1, make_number (anchor->YCoordinate)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1895 if (anchor->AnchorFormat == 2) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1896 ASET (val, 2, make_number (anchor->f.f1.AnchorPoint)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1897 else |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1898 { |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1899 ASET (val, 3, font_otf_DeviceTable (&anchor->f.f2.XDeviceTable)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1900 ASET (val, 4, font_otf_DeviceTable (&anchor->f.f2.YDeviceTable)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1901 } |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1902 return val; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1903 } |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1904 |
90400 | 1905 #endif /* HAVE_LIBOTF */ |
1906 | |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1907 /* G-string (glyph string) handler */ |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1908 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1909 /* G-string is a vector of the form [HEADER GLYPH ...]. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1910 See the docstring of `font-make-gstring' for more detail. */ |
90400 | 1911 |
1912 struct font * | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1913 font_prepare_composition (cmp, f) |
90400 | 1914 struct composition *cmp; |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1915 FRAME_PTR f; |
90400 | 1916 { |
1917 Lisp_Object gstring | |
1918 = AREF (XHASH_TABLE (composition_hash_table)->key_and_value, | |
1919 cmp->hash_index * 2); | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1920 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1921 cmp->font = XSAVE_VALUE (LGSTRING_FONT (gstring))->pointer; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1922 cmp->glyph_len = LGSTRING_LENGTH (gstring); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1923 cmp->pixel_width = LGSTRING_WIDTH (gstring); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1924 cmp->lbearing = LGSTRING_LBEARING (gstring); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1925 cmp->rbearing = LGSTRING_RBEARING (gstring); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1926 cmp->ascent = LGSTRING_ASCENT (gstring); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1927 cmp->descent = LGSTRING_DESCENT (gstring); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1928 cmp->width = cmp->pixel_width / FRAME_COLUMN_WIDTH (f); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1929 if (cmp->width == 0) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1930 cmp->width = 1; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1931 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1932 return cmp->font; |
90400 | 1933 } |
1934 | |
1935 | |
1936 /* Font sorting */ | |
1937 | |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1938 static unsigned font_score P_ ((Lisp_Object, Lisp_Object *)); |
90400 | 1939 static int font_compare P_ ((const void *, const void *)); |
1940 static Lisp_Object font_sort_entites P_ ((Lisp_Object, Lisp_Object, | |
1941 Lisp_Object, Lisp_Object)); | |
1942 | |
1943 /* We sort fonts by scoring each of them against a specified | |
1944 font-spec. The score value is 32 bit (`unsigned'), and the smaller | |
1945 the value is, the closer the font is to the font-spec. | |
1946 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
1947 Each 1-bit of the highest 4 bits of the score is used for atomic |
90400 | 1948 properties FOUNDRY, FAMILY, ADSTYLE, and REGISTRY. |
1949 | |
1950 Each 7-bit in the lowest 28 bits are used for numeric properties | |
1951 WEIGHT, SLANT, WIDTH, and SIZE. */ | |
1952 | |
1953 /* How many bits to shift to store the difference value of each font | |
1954 property in a score. */ | |
1955 static int sort_shift_bits[FONT_SIZE_INDEX + 1]; | |
1956 | |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1957 /* 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
|
1958 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
|
1959 SPEC_PROP. */ |
90400 | 1960 |
1961 static unsigned | |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1962 font_score (entity, spec_prop) |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1963 Lisp_Object entity, *spec_prop; |
90400 | 1964 { |
1965 unsigned score = 0; | |
1966 int i; | |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1967 /* Score four atomic fields. Maximum difference is 1. */ |
90400 | 1968 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
|
1969 if (! NILP (spec_prop[i]) |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1970 && ! 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
|
1971 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
|
1972 |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1973 /* Score four numeric fields. Maximum difference is 127. */ |
90400 | 1974 for (i = FONT_WEIGHT_INDEX; i <= FONT_SIZE_INDEX; i++) |
1975 { | |
1976 Lisp_Object entity_val = AREF (entity, i); | |
91261
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1977 Lisp_Object spec_val = spec_prop[i]; |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1978 |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1979 /* If weight and slant are unspecified, score normal lower (low wins). */ |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1980 if (NILP (spec_val)) |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1981 { |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1982 if (i == FONT_WEIGHT_INDEX || i == FONT_SLANT_INDEX) |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1983 spec_val = prop_name_to_numeric (i, build_string ("normal")); |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1984 } |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1985 |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1986 if (! NILP (spec_val) && ! EQ (spec_val, entity_val)) |
90400 | 1987 { |
1988 if (! INTEGERP (entity_val)) | |
1989 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
|
1990 else |
90400 | 1991 { |
91261
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1992 int diff = XINT (entity_val) - XINT (spec_val); |
90400 | 1993 |
1994 if (diff < 0) | |
1995 diff = - diff; | |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1996 if (i == FONT_SIZE_INDEX) |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1997 { |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1998 if (XINT (entity_val) > 0 |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1999 && diff > FONT_PIXEL_SIZE_QUANTUM) |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2000 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
|
2001 } |
91261
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
2002 #ifdef WINDOWSNT |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
2003 else if (i == FONT_WEIGHT_INDEX) |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
2004 { |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
2005 /* Windows uses a much wider range for weight (100-900) |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
2006 compared with freetype (0-210), so scale down the |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
2007 difference. A more general way of doing this |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
2008 would be to look up the values of regular and bold |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
2009 and/or light and calculate the scale factor from them, |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
2010 but the lookup would be expensive, and if only Windows |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
2011 needs it, not worth the effort. */ |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
2012 score |= min (diff / 4, 127) << sort_shift_bits[i]; |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
2013 } |
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
2014 #endif |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2015 else |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2016 score |= min (diff, 127) << sort_shift_bits[i]; |
90400 | 2017 } |
2018 } | |
2019 } | |
2020 | |
2021 return score; | |
2022 } | |
2023 | |
2024 | |
2025 /* The comparison function for qsort. */ | |
2026 | |
2027 static int | |
2028 font_compare (d1, d2) | |
2029 const void *d1, *d2; | |
2030 { | |
2031 return (*(unsigned *) d1 < *(unsigned *) d2 | |
2032 ? -1 : *(unsigned *) d1 > *(unsigned *) d2); | |
2033 } | |
2034 | |
2035 | |
2036 /* The structure for elements being sorted by qsort. */ | |
2037 struct font_sort_data | |
2038 { | |
2039 unsigned score; | |
2040 Lisp_Object entity; | |
2041 }; | |
2042 | |
2043 | |
2044 /* Sort font-entities in vector VEC by closeness to font-spec PREFER. | |
2045 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
|
2046 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
|
2047 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
|
2048 get the font-entities in VEC. */ |
90400 | 2049 |
2050 static Lisp_Object | |
2051 font_sort_entites (vec, prefer, frame, spec) | |
2052 Lisp_Object vec, prefer, frame, spec; | |
2053 { | |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2054 Lisp_Object prefer_prop[FONT_SPEC_MAX]; |
90400 | 2055 int len, i; |
2056 struct font_sort_data *data; | |
2057 USE_SAFE_ALLOCA; | |
2058 | |
2059 len = ASIZE (vec); | |
2060 if (len <= 1) | |
2061 return vec; | |
2062 | |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2063 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
|
2064 prefer_prop[i] = AREF (prefer, i); |
90400 | 2065 |
2066 if (! NILP (spec)) | |
2067 { | |
2068 /* As it is assured that all fonts in VEC match with SPEC, we | |
2069 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
|
2070 corresponding properties in PREFER_PROP to nil. */ |
90400 | 2071 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
|
2072 if (! NILP (AREF (spec, i))) |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2073 prefer_prop[i++] = Qnil; |
90400 | 2074 } |
2075 | |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2076 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
|
2077 prefer_prop[FONT_SIZE_INDEX] |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2078 = 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
|
2079 |
90400 | 2080 /* Scoring and sorting. */ |
2081 SAFE_ALLOCA (data, struct font_sort_data *, (sizeof *data) * len); | |
2082 for (i = 0; i < len; i++) | |
2083 { | |
2084 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
|
2085 data[i].score = font_score (data[i].entity, prefer_prop); |
90400 | 2086 } |
2087 qsort (data, len, sizeof *data, font_compare); | |
2088 for (i = 0; i < len; i++) | |
2089 ASET (vec, i, data[i].entity); | |
2090 SAFE_FREE (); | |
2091 | |
2092 return vec; | |
2093 } | |
2094 | |
2095 | |
2096 /* API of Font Service Layer. */ | |
2097 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2098 /* Reflect ORDER (see the variable font_sort_order in xfaces.c) to |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2099 sort_shift_bits. Finternal_set_font_selection_order calls this |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2100 function with font_sort_order after setting up it. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2101 |
90400 | 2102 void |
2103 font_update_sort_order (order) | |
2104 int *order; | |
2105 { | |
2106 int i, shift_bits = 21; | |
2107 | |
2108 for (i = 0; i < 4; i++, shift_bits -= 7) | |
2109 { | |
2110 int xlfd_idx = order[i]; | |
2111 | |
2112 if (xlfd_idx == XLFD_WEIGHT_INDEX) | |
2113 sort_shift_bits[FONT_WEIGHT_INDEX] = shift_bits; | |
2114 else if (xlfd_idx == XLFD_SLANT_INDEX) | |
2115 sort_shift_bits[FONT_SLANT_INDEX] = shift_bits; | |
2116 else if (xlfd_idx == XLFD_SWIDTH_INDEX) | |
2117 sort_shift_bits[FONT_WIDTH_INDEX] = shift_bits; | |
2118 else | |
2119 sort_shift_bits[FONT_SIZE_INDEX] = shift_bits; | |
2120 } | |
2121 } | |
2122 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2123 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2124 /* Return weight property of FONT as symbol. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2125 |
90400 | 2126 Lisp_Object |
2127 font_symbolic_weight (font) | |
2128 Lisp_Object font; | |
2129 { | |
2130 Lisp_Object weight = AREF (font, FONT_WEIGHT_INDEX); | |
2131 | |
2132 if (INTEGERP (weight)) | |
2133 weight = prop_numeric_to_name (FONT_WEIGHT_INDEX, XINT (weight)); | |
2134 return weight; | |
2135 } | |
2136 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2137 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2138 /* Return slant property of FONT as symbol. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2139 |
90400 | 2140 Lisp_Object |
2141 font_symbolic_slant (font) | |
2142 Lisp_Object font; | |
2143 { | |
2144 Lisp_Object slant = AREF (font, FONT_SLANT_INDEX); | |
2145 | |
2146 if (INTEGERP (slant)) | |
2147 slant = prop_numeric_to_name (FONT_SLANT_INDEX, XINT (slant)); | |
2148 return slant; | |
2149 } | |
2150 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2151 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2152 /* Return width property of FONT as symbol. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2153 |
90400 | 2154 Lisp_Object |
2155 font_symbolic_width (font) | |
2156 Lisp_Object font; | |
2157 { | |
2158 Lisp_Object width = AREF (font, FONT_WIDTH_INDEX); | |
2159 | |
2160 if (INTEGERP (width)) | |
2161 width = prop_numeric_to_name (FONT_WIDTH_INDEX, XINT (width)); | |
2162 return width; | |
2163 } | |
2164 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2165 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2166 /* Check if ENTITY matches with the font specification SPEC. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2167 |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2168 int |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2169 font_match_p (spec, entity) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2170 Lisp_Object spec, entity; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2171 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2172 int i; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2173 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2174 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
|
2175 if (! NILP (AREF (spec, i)) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2176 && ! EQ (AREF (spec, i), AREF (entity, i))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2177 return 0; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2178 if (INTEGERP (AREF (spec, FONT_SIZE_INDEX)) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2179 && XINT (AREF (entity, FONT_SIZE_INDEX)) > 0 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2180 && (XINT (AREF (spec, FONT_SIZE_INDEX)) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2181 != XINT (AREF (entity, FONT_SIZE_INDEX)))) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2182 return 0; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2183 return 1; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2184 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2185 |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2186 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2187 /* Return a lispy font object corresponding to FONT. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2188 |
90400 | 2189 Lisp_Object |
2190 font_find_object (font) | |
2191 struct font *font; | |
2192 { | |
2193 Lisp_Object tail, elt; | |
2194 | |
2195 for (tail = AREF (font->entity, FONT_OBJLIST_INDEX); CONSP (tail); | |
2196 tail = XCDR (tail)) | |
2197 { | |
2198 elt = XCAR (tail); | |
2199 if (font == XSAVE_VALUE (elt)->pointer | |
2200 && XSAVE_VALUE (elt)->integer > 0) | |
2201 return elt; | |
2202 } | |
2203 abort (); | |
2204 return Qnil; | |
2205 } | |
2206 | |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2207 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2208 /* Font cache |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2209 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2210 Each font backend has the callback function get_cache, and it |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2211 returns a cons cell of which cdr part can be freely used for |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2212 caching fonts. The cons cell may be shared by multiple frames |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2213 and/or multiple font drivers. So, we arrange the cdr part as this: |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2214 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2215 ((DRIVER-TYPE NUM-FRAMES FONT-CACHE-DATA ...) ...) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2216 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2217 where DRIVER-TYPE is a symbol such as `x', `xft', etc., NUM-FRAMES |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2218 is a number frames sharing this cache, and FONT-CACHE-DATA is a |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2219 cons (FONT-SPEC FONT-ENTITY ...). */ |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2220 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2221 static void font_prepare_cache P_ ((FRAME_PTR, struct font_driver *)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2222 static void font_finish_cache P_ ((FRAME_PTR, struct font_driver *)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2223 static Lisp_Object font_get_cache P_ ((FRAME_PTR, struct font_driver *)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2224 static void font_clear_cache P_ ((FRAME_PTR, Lisp_Object, |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2225 struct font_driver *)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2226 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2227 static void |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2228 font_prepare_cache (f, driver) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2229 FRAME_PTR f; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2230 struct font_driver *driver; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2231 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2232 Lisp_Object cache, val; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2233 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2234 cache = driver->get_cache (f); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2235 val = XCDR (cache); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2236 while (CONSP (val) && ! EQ (XCAR (XCAR (val)), driver->type)) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2237 val = XCDR (val); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2238 if (NILP (val)) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2239 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2240 val = Fcons (driver->type, Fcons (make_number (1), Qnil)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2241 XSETCDR (cache, Fcons (val, XCDR (cache))); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2242 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2243 else |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2244 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2245 val = XCDR (XCAR (val)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2246 XSETCAR (val, make_number (XINT (XCAR (val)) + 1)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2247 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2248 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2249 |
91909 | 2250 |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2251 static void |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2252 font_finish_cache (f, driver) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2253 FRAME_PTR f; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2254 struct font_driver *driver; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2255 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2256 Lisp_Object cache, val, tmp; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2257 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2258 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2259 cache = driver->get_cache (f); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2260 val = XCDR (cache); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2261 while (CONSP (val) && ! EQ (XCAR (XCAR (val)), driver->type)) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2262 cache = val, val = XCDR (val); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2263 xassert (! NILP (val)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2264 tmp = XCDR (XCAR (val)); |
91909 | 2265 XSETCAR (tmp, make_number (XINT (XCAR (tmp)) - 1)); |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2266 if (XINT (XCAR (tmp)) == 0) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2267 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2268 font_clear_cache (f, XCAR (val), driver); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2269 XSETCDR (cache, XCDR (val)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2270 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2271 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2272 |
91909 | 2273 |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2274 static Lisp_Object |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2275 font_get_cache (f, driver) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2276 FRAME_PTR f; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2277 struct font_driver *driver; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2278 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2279 Lisp_Object val = driver->get_cache (f); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2280 Lisp_Object type = driver->type; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2281 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2282 xassert (CONSP (val)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2283 for (val = XCDR (val); ! EQ (XCAR (XCAR (val)), type); val = XCDR (val)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2284 xassert (CONSP (val)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2285 /* VAL = ((DRIVER-TYPE NUM-FRAMES FONT-CACHE-DATA ...) ...) */ |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2286 val = XCDR (XCAR (val)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2287 return val; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2288 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2289 |
91909 | 2290 static int num_fonts; |
2291 | |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2292 static void |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2293 font_clear_cache (f, cache, driver) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2294 FRAME_PTR f; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2295 Lisp_Object cache; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2296 struct font_driver *driver; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2297 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2298 Lisp_Object tail, elt; |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
2299 |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2300 /* CACHE = (DRIVER-TYPE NUM-FRAMES FONT-CACHE-DATA ...) */ |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2301 for (tail = XCDR (XCDR (cache)); CONSP (tail); tail = XCDR (tail)) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2302 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2303 elt = XCAR (tail); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2304 if (CONSP (elt) && FONT_SPEC_P (XCAR (elt))) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2305 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2306 Lisp_Object vec = XCDR (elt); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2307 int i; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2308 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2309 for (i = 0; i < ASIZE (vec); i++) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2310 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2311 Lisp_Object entity = AREF (vec, i); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2312 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2313 if (EQ (driver->type, AREF (entity, FONT_TYPE_INDEX))) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2314 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2315 Lisp_Object objlist = AREF (entity, FONT_OBJLIST_INDEX); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2316 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2317 for (; CONSP (objlist); objlist = XCDR (objlist)) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2318 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2319 Lisp_Object val = XCAR (objlist); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2320 struct Lisp_Save_Value *p = XSAVE_VALUE (val); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2321 struct font *font = p->pointer; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2322 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2323 xassert (font && driver == font->driver); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2324 driver->close (f, font); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2325 p->pointer = NULL; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2326 p->integer = 0; |
91909 | 2327 num_fonts--; |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2328 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2329 if (driver->free_entity) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2330 driver->free_entity (entity); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2331 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2332 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2333 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2334 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2335 XSETCDR (cache, Qnil); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2336 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2337 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2338 |
90400 | 2339 static Lisp_Object scratch_font_spec, scratch_font_prefer; |
2340 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2341 |
90400 | 2342 /* Return a vector of font-entities matching with SPEC on frame F. */ |
2343 | |
2344 static Lisp_Object | |
2345 font_list_entities (frame, spec) | |
2346 Lisp_Object frame, spec; | |
2347 { | |
2348 FRAME_PTR f = XFRAME (frame); | |
2349 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
|
2350 Lisp_Object ftype, family, size, alternate_familes; |
90400 | 2351 Lisp_Object *vec = alloca (sizeof (Lisp_Object) * num_font_drivers); |
2352 int i; | |
2353 | |
2354 if (! vec) | |
2355 return null_vector; | |
2356 | |
2357 family = AREF (spec, FONT_FAMILY_INDEX); | |
2358 if (NILP (family)) | |
2359 alternate_familes = Qnil; | |
2360 else | |
2361 { | |
2362 if (NILP (font_family_alist) | |
2363 && !NILP (Vface_alternative_font_family_alist)) | |
2364 build_font_family_alist (); | |
2365 alternate_familes = assq_no_quit (family, font_family_alist); | |
2366 if (! NILP (alternate_familes)) | |
2367 alternate_familes = XCDR (alternate_familes); | |
2368 } | |
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2369 size = AREF (spec, FONT_SIZE_INDEX); |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2370 if (FLOATP (size)) |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2371 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
|
2372 |
90400 | 2373 xassert (ASIZE (spec) == FONT_SPEC_MAX); |
2374 ftype = AREF (spec, FONT_TYPE_INDEX); | |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
2375 |
90400 | 2376 for (i = 0; driver_list; driver_list = driver_list->next) |
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
2377 if (driver_list->on |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
2378 && (NILP (ftype) || EQ (driver_list->driver->type, ftype))) |
90400 | 2379 { |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2380 Lisp_Object cache = font_get_cache (f, driver_list->driver); |
90400 | 2381 Lisp_Object tail = alternate_familes; |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2382 |
90400 | 2383 ASET (spec, FONT_TYPE_INDEX, driver_list->driver->type); |
2384 ASET (spec, FONT_FAMILY_INDEX, family); | |
2385 | |
2386 while (1) | |
2387 { | |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2388 Lisp_Object val = assoc_no_quit (spec, XCDR (cache)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2389 |
90400 | 2390 if (CONSP (val)) |
2391 val = XCDR (val); | |
2392 else | |
2393 { | |
2394 val = driver_list->driver->list (frame, spec); | |
2395 if (VECTORP (val)) | |
2396 XSETCDR (cache, Fcons (Fcons (Fcopy_sequence (spec), val), | |
2397 XCDR (cache))); | |
2398 } | |
2399 if (VECTORP (val) && ASIZE (val) > 0) | |
2400 { | |
2401 vec[i++] = val; | |
2402 break; | |
2403 } | |
2404 if (NILP (tail)) | |
2405 break; | |
2406 ASET (spec, FONT_FAMILY_INDEX, XCAR (tail)); | |
2407 tail = XCDR (tail); | |
2408 } | |
2409 } | |
2410 ASET (spec, FONT_TYPE_INDEX, ftype); | |
2411 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
|
2412 ASET (spec, FONT_SIZE_INDEX, size); |
90400 | 2413 return (i > 0 ? Fvconcat (i, vec) : null_vector); |
2414 } | |
2415 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2416 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2417 /* Return a font entity matching with SPEC on FRAME. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2418 |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2419 static Lisp_Object |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2420 font_matching_entity (frame, spec) |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2421 Lisp_Object frame, spec; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2422 { |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2423 FRAME_PTR f = XFRAME (frame); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2424 struct font_driver_list *driver_list = f->font_driver_list; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2425 Lisp_Object ftype, size, entity; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2426 |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2427 ftype = AREF (spec, FONT_TYPE_INDEX); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2428 size = AREF (spec, FONT_SIZE_INDEX); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2429 if (FLOATP (size)) |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2430 ASET (spec, FONT_SIZE_INDEX, make_number (font_pixel_size (f, spec))); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2431 entity = Qnil; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2432 for (; driver_list; driver_list = driver_list->next) |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2433 if (driver_list->on |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2434 && (NILP (ftype) || EQ (driver_list->driver->type, ftype))) |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2435 { |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2436 Lisp_Object cache = font_get_cache (f, driver_list->driver); |
90590 | 2437 Lisp_Object key; |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2438 |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2439 ASET (spec, FONT_TYPE_INDEX, driver_list->driver->type); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2440 key = Fcons (spec, Qnil); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2441 entity = assoc_no_quit (key, XCDR (cache)); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2442 if (CONSP (entity)) |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2443 entity = XCDR (entity); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2444 else |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2445 { |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2446 entity = driver_list->driver->match (frame, spec); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2447 if (! NILP (entity)) |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2448 { |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2449 XSETCAR (key, Fcopy_sequence (spec)); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2450 XSETCDR (cache, Fcons (Fcons (key, entity), XCDR (cache))); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2451 } |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2452 } |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2453 if (! NILP (entity)) |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2454 break; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2455 } |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2456 ASET (spec, FONT_TYPE_INDEX, ftype); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2457 ASET (spec, FONT_SIZE_INDEX, size); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2458 return entity; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2459 } |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2460 |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2461 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2462 /* Open a font of ENTITY and PIXEL_SIZE on frame F, and return the |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2463 opened font object. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2464 |
90400 | 2465 static Lisp_Object |
2466 font_open_entity (f, entity, pixel_size) | |
2467 FRAME_PTR f; | |
2468 Lisp_Object entity; | |
2469 int pixel_size; | |
2470 { | |
2471 struct font_driver_list *driver_list; | |
91909 | 2472 Lisp_Object objlist, size, val, font_object; |
90400 | 2473 struct font *font; |
2474 | |
2475 size = AREF (entity, FONT_SIZE_INDEX); | |
2476 xassert (NATNUMP (size)); | |
2477 if (XINT (size) != 0) | |
2478 pixel_size = XINT (size); | |
2479 | |
91909 | 2480 font_object = Qnil; |
90400 | 2481 for (objlist = AREF (entity, FONT_OBJLIST_INDEX); CONSP (objlist); |
2482 objlist = XCDR (objlist)) | |
2483 { | |
2484 font = XSAVE_VALUE (XCAR (objlist))->pointer; | |
2485 if (font->pixel_size == pixel_size) | |
2486 { | |
91909 | 2487 font_object = XCAR (objlist); |
2488 XSAVE_VALUE (font_object)->integer++; | |
2489 break; | |
90400 | 2490 } |
2491 } | |
2492 | |
91909 | 2493 if (NILP (font_object)) |
2494 { | |
2495 val = AREF (entity, FONT_TYPE_INDEX); | |
2496 for (driver_list = f->font_driver_list; | |
2497 driver_list && ! EQ (driver_list->driver->type, val); | |
2498 driver_list = driver_list->next); | |
2499 if (! driver_list) | |
2500 return Qnil; | |
2501 | |
2502 font = driver_list->driver->open (f, entity, pixel_size); | |
2503 if (! font) | |
2504 return Qnil; | |
2505 font->scalable = XINT (size) == 0; | |
2506 | |
2507 font_object = make_save_value (font, 1); | |
2508 ASET (entity, FONT_OBJLIST_INDEX, | |
2509 Fcons (font_object, AREF (entity, FONT_OBJLIST_INDEX))); | |
2510 num_fonts++; | |
2511 } | |
2512 | |
2513 if (FRAME_SMALLEST_CHAR_WIDTH (f) > font->min_width) | |
2514 FRAME_SMALLEST_CHAR_WIDTH (f) = font->min_width; | |
2515 if (FRAME_SMALLEST_CHAR_WIDTH (f) <= 0) | |
2516 FRAME_SMALLEST_CHAR_WIDTH (f) = 1; | |
2517 if (FRAME_SMALLEST_FONT_HEIGHT (f) > font->font.height) | |
2518 FRAME_SMALLEST_FONT_HEIGHT (f) = font->font.height; | |
2519 if (FRAME_SMALLEST_FONT_HEIGHT (f) <= 0) | |
2520 FRAME_SMALLEST_FONT_HEIGHT (f) = 1; | |
2521 | |
2522 return font_object; | |
90400 | 2523 } |
2524 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2525 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2526 /* Close FONT_OBJECT that is opened on frame F. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2527 |
90400 | 2528 void |
2529 font_close_object (f, font_object) | |
2530 FRAME_PTR f; | |
2531 Lisp_Object font_object; | |
2532 { | |
90541 | 2533 struct font *font = XSAVE_VALUE (font_object)->pointer; |
2534 Lisp_Object objlist; | |
90400 | 2535 Lisp_Object tail, prev = Qnil; |
2536 | |
91909 | 2537 xassert (XSAVE_VALUE (font_object)->integer > 0); |
90541 | 2538 XSAVE_VALUE (font_object)->integer--; |
2539 if (XSAVE_VALUE (font_object)->integer > 0) | |
2540 return; | |
2541 | |
2542 objlist = AREF (font->entity, FONT_OBJLIST_INDEX); | |
90400 | 2543 for (prev = Qnil, tail = objlist; CONSP (tail); |
2544 prev = tail, tail = XCDR (tail)) | |
2545 if (EQ (font_object, XCAR (tail))) | |
2546 { | |
90541 | 2547 if (font->driver->close) |
2548 font->driver->close (f, font); | |
2549 XSAVE_VALUE (font_object)->pointer = NULL; | |
2550 if (NILP (prev)) | |
2551 ASET (font->entity, FONT_OBJLIST_INDEX, XCDR (objlist)); | |
2552 else | |
2553 XSETCDR (prev, XCDR (objlist)); | |
91909 | 2554 num_fonts--; |
90541 | 2555 return; |
90400 | 2556 } |
90541 | 2557 abort (); |
90400 | 2558 } |
2559 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2560 |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2561 /* Return 1 if FONT on F has a glyph for character C, 0 if not, -1 if |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2562 FONT is a font-entity and it must be opened to check. */ |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2563 |
90400 | 2564 int |
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2565 font_has_char (f, font, c) |
90400 | 2566 FRAME_PTR f; |
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2567 Lisp_Object font; |
90400 | 2568 int c; |
2569 { | |
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2570 struct font *fontp; |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2571 |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2572 if (FONT_ENTITY_P (font)) |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2573 { |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2574 Lisp_Object type = AREF (font, FONT_TYPE_INDEX); |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2575 struct font_driver_list *driver_list; |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2576 |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2577 for (driver_list = f->font_driver_list; |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2578 driver_list && ! EQ (driver_list->driver->type, type); |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2579 driver_list = driver_list->next); |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2580 if (! driver_list) |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2581 return 0; |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2582 if (! driver_list->driver->has_char) |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2583 return -1; |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2584 return driver_list->driver->has_char (font, c); |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2585 } |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2586 |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2587 xassert (FONT_OBJECT_P (font)); |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2588 fontp = XSAVE_VALUE (font)->pointer; |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2589 |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2590 if (fontp->driver->has_char) |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2591 { |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2592 int result = fontp->driver->has_char (fontp->entity, c); |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2593 |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2594 if (result >= 0) |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2595 return result; |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2596 } |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2597 return (fontp->driver->encode_char (fontp, c) != FONT_INVALID_CODE); |
90400 | 2598 } |
2599 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2600 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2601 /* Return the glyph ID of FONT_OBJECT for character C. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2602 |
90400 | 2603 unsigned |
2604 font_encode_char (font_object, c) | |
2605 Lisp_Object font_object; | |
2606 int c; | |
2607 { | |
2608 struct font *font = XSAVE_VALUE (font_object)->pointer; | |
2609 | |
2610 return font->driver->encode_char (font, c); | |
2611 } | |
2612 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2613 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2614 /* Return the name of FONT_OBJECT. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2615 |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2616 Lisp_Object |
90400 | 2617 font_get_name (font_object) |
2618 Lisp_Object font_object; | |
2619 { | |
2620 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
|
2621 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
|
2622 : font->font.name ? font->font.name |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2623 : NULL); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2624 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2625 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
|
2626 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2627 |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2628 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2629 /* Return the specification of FONT_OBJECT. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2630 |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2631 Lisp_Object |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2632 font_get_spec (font_object) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2633 Lisp_Object font_object; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2634 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2635 struct font *font = XSAVE_VALUE (font_object)->pointer; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2636 Lisp_Object spec = Ffont_spec (0, NULL); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2637 int i; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2638 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2639 for (i = 0; i < FONT_SIZE_INDEX; i++) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2640 ASET (spec, i, AREF (font->entity, i)); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2641 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
|
2642 return spec; |
90400 | 2643 } |
2644 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2645 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2646 /* Return the frame on which FONT exists. FONT is a font object or a |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2647 font entity. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2648 |
90400 | 2649 Lisp_Object |
2650 font_get_frame (font) | |
2651 Lisp_Object font; | |
2652 { | |
2653 if (FONT_OBJECT_P (font)) | |
2654 font = ((struct font *) XSAVE_VALUE (font)->pointer)->entity; | |
2655 xassert (FONT_ENTITY_P (font)); | |
2656 return AREF (font, FONT_FRAME_INDEX); | |
2657 } | |
2658 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2659 |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2660 /* Find a font entity best matching with LFACE. If SPEC is non-nil, |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2661 the font must exactly match with it. C, if not negative, is a |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2662 character that the entity must support. */ |
90400 | 2663 |
2664 Lisp_Object | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2665 font_find_for_lface (f, lface, spec, c) |
90400 | 2666 FRAME_PTR f; |
2667 Lisp_Object *lface; | |
2668 Lisp_Object spec; | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2669 int c; |
90400 | 2670 { |
91353
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2671 Lisp_Object frame, entities, val; |
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2672 int i, result; |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2673 |
90507
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2674 XSETFRAME (frame, f); |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2675 |
90400 | 2676 if (NILP (spec)) |
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2677 { |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2678 if (c >= 0x100) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2679 return Qnil; |
90507
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2680 for (i = 0; i < FONT_SPEC_MAX; i++) |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2681 ASET (scratch_font_spec, i, Qnil); |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2682 ASET (scratch_font_spec, FONT_REGISTRY_INDEX, Qiso8859_1); |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2683 |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2684 if (! NILP (lface[LFACE_FAMILY_INDEX])) |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2685 font_merge_old_spec (Qnil, lface[LFACE_FAMILY_INDEX], Qnil, |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2686 scratch_font_spec); |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2687 entities = font_list_entities (frame, scratch_font_spec); |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2688 while (ASIZE (entities) == 0) |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2689 { |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2690 /* Try without FOUNDRY or FAMILY. */ |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2691 if (! NILP (AREF (scratch_font_spec, FONT_FOUNDRY_INDEX))) |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2692 { |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2693 ASET (scratch_font_spec, FONT_FOUNDRY_INDEX, Qnil); |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2694 entities = font_list_entities (frame, scratch_font_spec); |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2695 } |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2696 else if (! NILP (AREF (scratch_font_spec, FONT_FAMILY_INDEX))) |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2697 { |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2698 ASET (scratch_font_spec, FONT_FAMILY_INDEX, Qnil); |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2699 entities = font_list_entities (frame, scratch_font_spec); |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2700 } |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2701 else |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2702 break; |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2703 } |
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2704 } |
90507
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2705 else |
90400 | 2706 { |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2707 Lisp_Object registry = AREF (spec, FONT_REGISTRY_INDEX); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2708 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2709 if (NILP (registry)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2710 registry = Qiso8859_1; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2711 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2712 if (c >= 0) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2713 { |
91353
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2714 struct charset *encoding, *repertory; |
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2715 |
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2716 if (font_registry_charsets (registry, &encoding, &repertory) < 0) |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2717 return Qnil; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2718 if (repertory) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2719 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2720 if (ENCODE_CHAR (repertory, c) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2721 == CHARSET_INVALID_CODE (repertory)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2722 return Qnil; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2723 /* Any font of this registry support C. So, let's |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2724 suppress the further checking. */ |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2725 c = -1; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2726 } |
91353
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2727 else if (c > encoding->max_char) |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2728 return Qnil; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2729 } |
90507
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2730 for (i = 0; i < FONT_SPEC_MAX; i++) |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2731 ASET (scratch_font_spec, i, AREF (spec, i)); |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2732 ASET (scratch_font_spec, FONT_REGISTRY_INDEX, registry); |
90507
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2733 entities = font_list_entities (frame, scratch_font_spec); |
90400 | 2734 } |
2735 | |
90507
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2736 if (ASIZE (entities) == 0) |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2737 return Qnil; |
90400 | 2738 if (ASIZE (entities) > 1) |
2739 { | |
90507
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2740 /* Sort fonts by properties specified in LFACE. */ |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
2741 Lisp_Object prefer = scratch_font_prefer; |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2742 double pt; |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2743 |
90507
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2744 if (! NILP (lface[LFACE_FAMILY_INDEX])) |
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2745 font_merge_old_spec (Qnil, lface[LFACE_FAMILY_INDEX], Qnil, prefer); |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2746 ASET (prefer, FONT_WEIGHT_INDEX, |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2747 font_prop_validate_style (QCweight, lface[LFACE_WEIGHT_INDEX])); |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2748 ASET (prefer, FONT_SLANT_INDEX, |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2749 font_prop_validate_style (QCslant, lface[LFACE_SLANT_INDEX])); |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2750 ASET (prefer, FONT_WIDTH_INDEX, |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2751 font_prop_validate_style (QCwidth, lface[LFACE_SWIDTH_INDEX])); |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2752 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
|
2753 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
|
2754 |
90400 | 2755 font_sort_entites (entities, prefer, frame, spec); |
2756 } | |
2757 | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2758 if (c < 0) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2759 return AREF (entities, 0); |
91353
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2760 |
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2761 val = AREF (entities, 0); |
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2762 result = font_has_char (f, val, c); |
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2763 if (result > 0) |
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2764 return val; |
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2765 if (result == 0) |
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2766 return Qnil; |
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2767 val = font_open_for_lface (f, val, lface, spec); |
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2768 if (NILP (val)) |
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2769 return Qnil; |
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2770 result = font_has_char (f, val, c); |
91360
203e06d5def6
(font_find_for_lface): Fix previous change. Be sure to
Kenichi Handa <handa@m17n.org>
parents:
91353
diff
changeset
|
2771 font_close_object (f, val); |
91353
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2772 if (result > 0) |
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2773 return val; |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2774 return Qnil; |
90400 | 2775 } |
2776 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2777 |
90400 | 2778 Lisp_Object |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2779 font_open_for_lface (f, entity, lface, spec) |
90400 | 2780 FRAME_PTR f; |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2781 Lisp_Object entity; |
90400 | 2782 Lisp_Object *lface; |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2783 Lisp_Object spec; |
90400 | 2784 { |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2785 int size; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2786 |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2787 if (FONT_SPEC_P (spec) && INTEGERP (AREF (spec, FONT_SIZE_INDEX))) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2788 size = XINT (AREF (spec, FONT_SIZE_INDEX)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2789 else |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2790 { |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2791 double pt = XINT (lface[LFACE_HEIGHT_INDEX]); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2792 |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2793 pt /= 10; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2794 size = POINT_TO_PIXEL (pt, f->resy); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2795 } |
90400 | 2796 return font_open_entity (f, entity, size); |
2797 } | |
2798 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2799 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2800 /* Load a font best matching with FACE's font-related properties into |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2801 FACE on frame F. If no proper font is found, record that FACE has |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2802 no font. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2803 |
90400 | 2804 void |
2805 font_load_for_face (f, face) | |
2806 FRAME_PTR f; | |
2807 struct face *face; | |
2808 { | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2809 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
|
2810 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2811 if (NILP (font_object)) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2812 { |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2813 Lisp_Object entity = font_find_for_lface (f, face->lface, Qnil, -1); |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2814 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2815 if (! NILP (entity)) |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2816 font_object = font_open_for_lface (f, entity, face->lface, Qnil); |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2817 } |
91350
9673276f310c
(font_load_for_face): Handle the case that the font in
Kenichi Handa <handa@m17n.org>
parents:
91337
diff
changeset
|
2818 else if (STRINGP (font_object)) |
9673276f310c
(font_load_for_face): Handle the case that the font in
Kenichi Handa <handa@m17n.org>
parents:
91337
diff
changeset
|
2819 { |
9673276f310c
(font_load_for_face): Handle the case that the font in
Kenichi Handa <handa@m17n.org>
parents:
91337
diff
changeset
|
2820 font_object = font_open_by_name (f, SDATA (font_object)); |
9673276f310c
(font_load_for_face): Handle the case that the font in
Kenichi Handa <handa@m17n.org>
parents:
91337
diff
changeset
|
2821 } |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2822 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2823 if (! NILP (font_object)) |
90400 | 2824 { |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2825 struct font *font = XSAVE_VALUE (font_object)->pointer; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2826 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2827 face->font = font->font.font; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2828 face->font_info = (struct font_info *) font; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2829 face->font_info_id = 0; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2830 face->font_name = font->font.full_name; |
90400 | 2831 } |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2832 else |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2833 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2834 face->font = NULL; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2835 face->font_info = NULL; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2836 face->font_info_id = -1; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2837 face->font_name = NULL; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2838 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
|
2839 } |
90400 | 2840 } |
2841 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2842 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2843 /* Make FACE on frame F ready to use the font opened for FACE. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2844 |
90400 | 2845 void |
2846 font_prepare_for_face (f, face) | |
2847 FRAME_PTR f; | |
2848 struct face *face; | |
2849 { | |
2850 struct font *font = (struct font *) face->font_info; | |
2851 | |
2852 if (font->driver->prepare_face) | |
2853 font->driver->prepare_face (f, face); | |
2854 } | |
2855 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2856 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2857 /* Make FACE on frame F stop using the font opened for FACE. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2858 |
90400 | 2859 void |
2860 font_done_for_face (f, face) | |
2861 FRAME_PTR f; | |
2862 struct face *face; | |
2863 { | |
2864 struct font *font = (struct font *) face->font_info; | |
2865 | |
2866 if (font->driver->done_face) | |
2867 font->driver->done_face (f, face); | |
2868 face->extra = NULL; | |
2869 } | |
2870 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2871 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2872 /* Open a font best matching with NAME on frame F. If no proper font |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2873 is found, return Qnil. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2874 |
90400 | 2875 Lisp_Object |
2876 font_open_by_name (f, name) | |
2877 FRAME_PTR f; | |
2878 char *name; | |
2879 { | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2880 Lisp_Object args[2]; |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2881 Lisp_Object spec, prefer, size, entity, entity_list; |
90400 | 2882 Lisp_Object frame; |
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2883 int i; |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2884 int pixel_size; |
90400 | 2885 |
2886 XSETFRAME (frame, f); | |
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2887 |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2888 args[0] = QCname; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2889 args[1] = make_unibyte_string (name, strlen (name)); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2890 spec = Ffont_spec (2, args); |
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2891 prefer = scratch_font_prefer; |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2892 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
|
2893 if (NILP (AREF (spec, i))) |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2894 ASET (prefer, i, make_number (100)); |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2895 size = AREF (spec, FONT_SIZE_INDEX); |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2896 if (NILP (size)) |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2897 pixel_size = 0; |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2898 else if (INTEGERP (size)) |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2899 pixel_size = XINT (size); |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2900 else /* FLOATP (size) */ |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2901 { |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2902 double pt = XFLOAT_DATA (size); |
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2903 |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2904 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
|
2905 size = make_number (pixel_size); |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2906 ASET (spec, FONT_SIZE_INDEX, size); |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2907 } |
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2908 if (pixel_size == 0) |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2909 { |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2910 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
|
2911 size = make_number (pixel_size); |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2912 } |
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2913 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
|
2914 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
|
2915 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
|
2916 |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2917 entity_list = Flist_fonts (spec, frame, make_number (1), prefer); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2918 if (NILP (entity_list)) |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2919 entity = font_matching_entity (frame, spec); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2920 else |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2921 entity = XCAR (entity_list); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2922 return (NILP (entity) |
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2923 ? Qnil |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2924 : font_open_entity (f, entity, pixel_size)); |
90400 | 2925 } |
2926 | |
2927 | |
2928 /* Register font-driver DRIVER. This function is used in two ways. | |
2929 | |
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
2930 The first is with frame F non-NULL. In this case, make DRIVER |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
2931 available (but not yet activated) on F. All frame creaters |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
2932 (e.g. Fx_create_frame) must call this function at least once with |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
2933 an available font-driver. |
90400 | 2934 |
2935 The second is with frame F NULL. In this case, DRIVER is globally | |
2936 registered in the variable `font_driver_list'. All font-driver | |
2937 implementations must call this function in its syms_of_XXXX | |
2938 (e.g. syms_of_xfont). */ | |
2939 | |
2940 void | |
2941 register_font_driver (driver, f) | |
2942 struct font_driver *driver; | |
2943 FRAME_PTR f; | |
2944 { | |
2945 struct font_driver_list *root = f ? f->font_driver_list : font_driver_list; | |
2946 struct font_driver_list *prev, *list; | |
2947 | |
2948 if (f && ! driver->draw) | |
92113
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
2949 error ("Unusable font driver for a frame: %s", |
90400 | 2950 SDATA (SYMBOL_NAME (driver->type))); |
2951 | |
2952 for (prev = NULL, list = root; list; prev = list, list = list->next) | |
90695
a1cd7344d6a2
(font_parse_xlfd): Fix the array size of `f'.
Kenichi Handa <handa@m17n.org>
parents:
90677
diff
changeset
|
2953 if (EQ (list->driver->type, driver->type)) |
90400 | 2954 error ("Duplicated font driver: %s", SDATA (SYMBOL_NAME (driver->type))); |
2955 | |
2956 list = malloc (sizeof (struct font_driver_list)); | |
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
2957 list->on = 0; |
90400 | 2958 list->driver = driver; |
2959 list->next = NULL; | |
2960 if (prev) | |
2961 prev->next = list; | |
2962 else if (f) | |
2963 f->font_driver_list = list; | |
2964 else | |
2965 font_driver_list = list; | |
2966 num_font_drivers++; | |
2967 } | |
2968 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2969 |
90400 | 2970 /* Free font-driver list on frame F. It doesn't free font-drivers |
2971 themselves. */ | |
2972 | |
2973 void | |
2974 free_font_driver_list (f) | |
2975 FRAME_PTR f; | |
2976 { | |
2977 while (f->font_driver_list) | |
2978 { | |
2979 struct font_driver_list *next = f->font_driver_list->next; | |
2980 | |
2981 free (f->font_driver_list); | |
2982 f->font_driver_list = next; | |
2983 } | |
2984 } | |
2985 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2986 |
91112
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
2987 /* Make the frame F use font backends listed in NEW_DRIVERS (list of |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2988 symbols, e.g. xft, x). If NEW_DRIVERS is t, make F use all |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2989 available font drivers. If NEW_DRIVERS is nil, finalize all drivers. |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2990 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2991 A caller must free all realized faces if any in advance. The |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2992 return value is a list of font backends actually made used on |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2993 F. */ |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2994 |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2995 Lisp_Object |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2996 font_update_drivers (f, new_drivers) |
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
2997 FRAME_PTR f; |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
2998 Lisp_Object new_drivers; |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
2999 { |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3000 Lisp_Object active_drivers = Qnil; |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3001 struct font_driver_list *list; |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3002 |
91112
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3003 for (list = f->font_driver_list; list; list = list->next) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3004 if (list->on) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3005 { |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3006 if (! EQ (new_drivers, Qt) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3007 && NILP (Fmemq (list->driver->type, new_drivers))) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3008 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3009 if (list->driver->end_for_frame) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3010 list->driver->end_for_frame (f); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3011 font_finish_cache (f, list->driver); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3012 list->on = 0; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3013 } |
91112
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3014 } |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3015 else |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3016 { |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3017 if (EQ (new_drivers, Qt) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3018 || ! NILP (Fmemq (list->driver->type, new_drivers))) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3019 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3020 if (! list->driver->start_for_frame |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3021 || list->driver->start_for_frame (f) == 0) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3022 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3023 font_prepare_cache (f, list->driver); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3024 list->on = 1; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3025 active_drivers = nconc2 (active_drivers, |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3026 Fcons (list->driver->type, Qnil)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3027 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3028 } |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3029 } |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3030 |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3031 return active_drivers; |
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3032 } |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3033 |
91112
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3034 int |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3035 font_put_frame_data (f, driver, data) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3036 FRAME_PTR f; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3037 struct font_driver *driver; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3038 void *data; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3039 { |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3040 struct font_data_list *list, *prev; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3041 |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3042 for (prev = NULL, list = f->font_data_list; list; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3043 prev = list, list = list->next) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3044 if (list->driver == driver) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3045 break; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3046 if (! data) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3047 { |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3048 if (list) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3049 { |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3050 if (prev) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3051 prev->next = list->next; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3052 else |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3053 f->font_data_list = list->next; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3054 free (list); |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3055 } |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3056 return 0; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3057 } |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3058 |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3059 if (! list) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3060 { |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3061 list = malloc (sizeof (struct font_data_list)); |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3062 if (! list) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3063 return -1; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3064 list->driver = driver; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3065 list->next = f->font_data_list; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3066 f->font_data_list = list; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3067 } |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3068 list->data = data; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3069 return 0; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3070 } |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3071 |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3072 |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3073 void * |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3074 font_get_frame_data (f, driver) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3075 FRAME_PTR f; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3076 struct font_driver *driver; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3077 { |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3078 struct font_data_list *list; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3079 |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3080 for (list = f->font_data_list; list; list = list->next) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3081 if (list->driver == driver) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3082 break; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3083 if (! list) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3084 return NULL; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3085 return list->data; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3086 } |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3087 |
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3088 |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3089 /* Return the font used to draw character C by FACE at buffer position |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3090 POS in window W. If STRING is non-nil, it is a string containing C |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3091 at index POS. If C is negative, get C from the current buffer or |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3092 STRING. */ |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3093 |
90541 | 3094 Lisp_Object |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3095 font_at (c, pos, face, w, string) |
90541 | 3096 int c; |
3097 EMACS_INT pos; | |
3098 struct face *face; | |
3099 struct window *w; | |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3100 Lisp_Object string; |
90541 | 3101 { |
3102 FRAME_PTR f; | |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3103 int multibyte; |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3104 |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3105 if (c < 0) |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3106 { |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3107 if (NILP (string)) |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3108 { |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3109 multibyte = ! NILP (current_buffer->enable_multibyte_characters); |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3110 if (multibyte) |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3111 { |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3112 EMACS_INT pos_byte = CHAR_TO_BYTE (pos); |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3113 |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3114 c = FETCH_CHAR (pos_byte); |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3115 } |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3116 else |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3117 c = FETCH_BYTE (pos); |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3118 } |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3119 else |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3120 { |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3121 unsigned char *str; |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3122 |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3123 multibyte = STRING_MULTIBYTE (string); |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3124 if (multibyte) |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3125 { |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3126 EMACS_INT pos_byte = string_char_to_byte (string, pos); |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3127 |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3128 str = SDATA (string) + pos_byte; |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3129 c = STRING_CHAR (str, 0); |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3130 } |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3131 else |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3132 c = SDATA (string)[pos]; |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3133 } |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3134 } |
90541 | 3135 |
3136 f = XFRAME (w->frame); | |
90811
c1ed0fd37416
(font_at): If the window W is not on a window system,
Kenichi Handa <handa@m17n.org>
parents:
90695
diff
changeset
|
3137 if (! FRAME_WINDOW_P (f)) |
c1ed0fd37416
(font_at): If the window W is not on a window system,
Kenichi Handa <handa@m17n.org>
parents:
90695
diff
changeset
|
3138 return Qnil; |
90541 | 3139 if (! face) |
3140 { | |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3141 int face_id; |
92237
ce06567a933d
* dispextern.h (face_at_buffer_position, face_for_overlay_string)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92233
diff
changeset
|
3142 EMACS_INT endptr; |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3143 |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3144 if (STRINGP (string)) |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3145 face_id = face_at_string_position (w, string, pos, 0, -1, -1, &endptr, |
90541 | 3146 DEFAULT_FACE_ID, 0); |
3147 else | |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3148 face_id = face_at_buffer_position (w, pos, -1, -1, &endptr, |
90541 | 3149 pos + 100, 0); |
3150 face = FACE_FROM_ID (f, face_id); | |
3151 } | |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3152 if (multibyte) |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3153 { |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3154 int face_id = FACE_FOR_CHAR (f, face, c, pos, string); |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3155 face = FACE_FROM_ID (f, face_id); |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3156 } |
90541 | 3157 if (! face->font_info) |
3158 return Qnil; | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3159 return font_find_object ((struct font *) face->font_info); |
90541 | 3160 } |
3161 | |
90400 | 3162 |
3163 /* Lisp API */ | |
3164 | |
3165 DEFUN ("fontp", Ffontp, Sfontp, 1, 1, 0, | |
91353
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
3166 doc: /* Return t if OBJECT is a font-spec, font-entity, or font-object. |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3167 Return nil otherwise. */) |
90400 | 3168 (object) |
3169 Lisp_Object object; | |
3170 { | |
3171 return (FONTP (object) ? Qt : Qnil); | |
3172 } | |
3173 | |
3174 DEFUN ("font-spec", Ffont_spec, Sfont_spec, 0, MANY, 0, | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3175 doc: /* Return a newly created font-spec with arguments as properties. |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3176 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3177 ARGS must come in pairs KEY VALUE of font properties. KEY must be a |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3178 valid font property name listed below: |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3179 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3180 `:family', `:weight', `:slant', `:width' |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3181 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3182 They are the same as face attributes of the same name. See |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3183 `set-face-attribute'. |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3184 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3185 `:foundry' |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3186 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3187 VALUE must be a string or a symbol specifying the font foundry, e.g. ``misc''. |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3188 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3189 `:adstyle' |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3190 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3191 VALUE must be a string or a symbol specifying the additional |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3192 typographic style information of a font, e.g. ``sans''. Usually null. |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3193 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3194 `:registry' |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3195 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3196 VALUE must be a string or a symbol specifying the charset registry and |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3197 encoding of a font, e.g. ``iso8859-1''. |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3198 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3199 `:size' |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3200 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3201 VALUE must be a non-negative integer or a floating point number |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3202 specifying the font size. It specifies the font size in 1/10 pixels |
91112
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3203 (if VALUE is an integer), or in points (if VALUE is a float). |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3204 usage: (font-spec ARGS ...) */) |
90400 | 3205 (nargs, args) |
3206 int nargs; | |
3207 Lisp_Object *args; | |
3208 { | |
3209 Lisp_Object spec = Fmake_vector (make_number (FONT_SPEC_MAX), Qnil); | |
3210 int i; | |
3211 | |
3212 for (i = 0; i < nargs; i += 2) | |
3213 { | |
3214 enum font_property_index prop; | |
3215 Lisp_Object key = args[i], val = args[i + 1]; | |
3216 | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
3217 prop = get_font_prop_index (key, 0); |
90400 | 3218 if (prop < FONT_EXTRA_INDEX) |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
3219 ASET (spec, prop, val); |
90400 | 3220 else |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
3221 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
3222 if (EQ (key, QCname)) |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
3223 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
3224 CHECK_STRING (val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
3225 font_parse_name ((char *) SDATA (val), spec); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
3226 } |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3227 font_put_extra (spec, key, val); |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
3228 } |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3229 } |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
3230 CHECK_VALIDATE_FONT_SPEC (spec); |
90400 | 3231 return spec; |
3232 } | |
3233 | |
3234 | |
3235 DEFUN ("font-get", Ffont_get, Sfont_get, 2, 2, 0, | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3236 doc: /* Return the value of FONT's property KEY. |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3237 FONT is a font-spec, a font-entity, or a font-object. */) |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3238 (font, key) |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3239 Lisp_Object font, key; |
90400 | 3240 { |
3241 enum font_property_index idx; | |
3242 | |
90541 | 3243 if (FONT_OBJECT_P (font)) |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3244 { |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3245 struct font *fontp = XSAVE_VALUE (font)->pointer; |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3246 |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3247 if (EQ (key, QCotf)) |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3248 { |
90881
7bf78e56f04f
(Ffont_get): Use font driver to determine otf capability.
Jason Rumney <jasonr@gnu.org>
parents:
90823
diff
changeset
|
3249 if (fontp->driver->otf_capability) |
7bf78e56f04f
(Ffont_get): Use font driver to determine otf capability.
Jason Rumney <jasonr@gnu.org>
parents:
90823
diff
changeset
|
3250 return fontp->driver->otf_capability (fontp); |
7bf78e56f04f
(Ffont_get): Use font driver to determine otf capability.
Jason Rumney <jasonr@gnu.org>
parents:
90823
diff
changeset
|
3251 else |
7bf78e56f04f
(Ffont_get): Use font driver to determine otf capability.
Jason Rumney <jasonr@gnu.org>
parents:
90823
diff
changeset
|
3252 return Qnil; |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3253 } |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3254 font = fontp->entity; |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3255 } |
90541 | 3256 else |
3257 CHECK_FONT (font); | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3258 idx = get_font_prop_index (key, 0); |
90400 | 3259 if (idx < FONT_EXTRA_INDEX) |
3260 return AREF (font, idx); | |
3261 if (FONT_ENTITY_P (font)) | |
3262 return Qnil; | |
91240
b2febf77e71c
(Ffont_get): Fix arguments to Fassoc.
Kenichi Handa <handa@m17n.org>
parents:
91236
diff
changeset
|
3263 return Fcdr (Fassoc (key, AREF (font, FONT_EXTRA_INDEX))); |
90400 | 3264 } |
3265 | |
3266 | |
3267 DEFUN ("font-put", Ffont_put, Sfont_put, 3, 3, 0, | |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3268 doc: /* Set one property of FONT-SPEC: give property PROP value VAL. */) |
90400 | 3269 (font_spec, prop, val) |
3270 Lisp_Object font_spec, prop, val; | |
3271 { | |
3272 enum font_property_index idx; | |
3273 Lisp_Object extra, slot; | |
3274 | |
3275 CHECK_FONT_SPEC (font_spec); | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
3276 idx = get_font_prop_index (prop, 0); |
90400 | 3277 if (idx < FONT_EXTRA_INDEX) |
3278 return ASET (font_spec, idx, val); | |
3279 extra = AREF (font_spec, FONT_EXTRA_INDEX); | |
3280 slot = Fassoc (extra, prop); | |
3281 if (NILP (slot)) | |
3282 extra = Fcons (Fcons (prop, val), extra); | |
3283 else | |
3284 Fsetcdr (slot, val); | |
3285 return val; | |
3286 } | |
3287 | |
3288 DEFUN ("list-fonts", Flist_fonts, Slist_fonts, 1, 4, 0, | |
3289 doc: /* List available fonts matching FONT-SPEC on the current frame. | |
3290 Optional 2nd argument FRAME specifies the target frame. | |
3291 Optional 3rd argument NUM, if non-nil, limits the number of returned fonts. | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3292 Optional 4th argument PREFER, if non-nil, is a font-spec to |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3293 control the order of the returned list. Fonts are sorted by |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3294 how they are close to PREFER. */) |
90400 | 3295 (font_spec, frame, num, prefer) |
3296 Lisp_Object font_spec, frame, num, prefer; | |
3297 { | |
3298 Lisp_Object vec, list, tail; | |
3299 int n = 0, i, len; | |
3300 | |
3301 if (NILP (frame)) | |
3302 frame = selected_frame; | |
3303 CHECK_LIVE_FRAME (frame); | |
3304 CHECK_VALIDATE_FONT_SPEC (font_spec); | |
3305 if (! NILP (num)) | |
3306 { | |
3307 CHECK_NUMBER (num); | |
3308 n = XINT (num); | |
3309 if (n <= 0) | |
3310 return Qnil; | |
3311 } | |
3312 if (! NILP (prefer)) | |
3313 CHECK_FONT (prefer); | |
3314 | |
3315 vec = font_list_entities (frame, font_spec); | |
3316 len = ASIZE (vec); | |
3317 if (len == 0) | |
3318 return Qnil; | |
3319 if (len == 1) | |
3320 return Fcons (AREF (vec, 0), Qnil); | |
3321 | |
3322 if (! NILP (prefer)) | |
3323 vec = font_sort_entites (vec, prefer, frame, font_spec); | |
3324 | |
3325 list = tail = Fcons (AREF (vec, 0), Qnil); | |
3326 if (n == 0 || n > len) | |
3327 n = len; | |
3328 for (i = 1; i < n; i++) | |
3329 { | |
3330 Lisp_Object val = Fcons (AREF (vec, i), Qnil); | |
3331 | |
3332 XSETCDR (tail, val); | |
3333 tail = val; | |
3334 } | |
3335 return list; | |
3336 } | |
3337 | |
3338 DEFUN ("list-families", Flist_families, Slist_families, 0, 1, 0, | |
3339 doc: /* List available font families on the current frame. | |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3340 Optional argument FRAME specifies the target frame. */) |
90400 | 3341 (frame) |
3342 Lisp_Object frame; | |
3343 { | |
3344 FRAME_PTR f; | |
3345 struct font_driver_list *driver_list; | |
3346 Lisp_Object list; | |
3347 | |
3348 if (NILP (frame)) | |
3349 frame = selected_frame; | |
3350 CHECK_LIVE_FRAME (frame); | |
3351 f = XFRAME (frame); | |
3352 list = Qnil; | |
3353 for (driver_list = f->font_driver_list; driver_list; | |
3354 driver_list = driver_list->next) | |
3355 if (driver_list->driver->list_family) | |
3356 { | |
3357 Lisp_Object val = driver_list->driver->list_family (frame); | |
3358 | |
3359 if (NILP (list)) | |
3360 list = val; | |
3361 else | |
3362 { | |
3363 Lisp_Object tail = list; | |
3364 | |
3365 for (; CONSP (val); val = XCDR (val)) | |
3366 if (NILP (Fmemq (XCAR (val), tail))) | |
3367 list = Fcons (XCAR (val), list); | |
3368 } | |
3369 } | |
3370 return list; | |
3371 } | |
3372 | |
3373 DEFUN ("find-font", Ffind_font, Sfind_font, 1, 2, 0, | |
3374 doc: /* Return a font-entity matching with FONT-SPEC on the current frame. | |
3375 Optional 2nd argument FRAME, if non-nil, specifies the target frame. */) | |
3376 (font_spec, frame) | |
3377 Lisp_Object font_spec, frame; | |
3378 { | |
3379 Lisp_Object val = Flist_fonts (font_spec, frame, make_number (1), Qnil); | |
3380 | |
3381 if (CONSP (val)) | |
3382 val = XCAR (val); | |
3383 return val; | |
3384 } | |
3385 | |
3386 DEFUN ("font-xlfd-name", Ffont_xlfd_name, Sfont_xlfd_name, 1, 1, 0, | |
3387 doc: /* Return XLFD name of FONT. | |
3388 FONT is a font-spec, font-entity, or font-object. | |
3389 If the name is too long for XLFD (maximum 255 chars), return nil. */) | |
3390 (font) | |
3391 Lisp_Object font; | |
3392 { | |
3393 char name[256]; | |
3394 int pixel_size = 0; | |
3395 | |
3396 if (FONT_SPEC_P (font)) | |
3397 CHECK_VALIDATE_FONT_SPEC (font); | |
3398 else if (FONT_ENTITY_P (font)) | |
3399 CHECK_FONT (font); | |
3400 else | |
3401 { | |
3402 struct font *fontp; | |
3403 | |
3404 CHECK_FONT_GET_OBJECT (font, fontp); | |
3405 font = fontp->entity; | |
3406 pixel_size = fontp->pixel_size; | |
3407 } | |
3408 | |
3409 if (font_unparse_xlfd (font, pixel_size, name, 256) < 0) | |
3410 return Qnil; | |
3411 return build_string (name); | |
3412 } | |
3413 | |
3414 DEFUN ("clear-font-cache", Fclear_font_cache, Sclear_font_cache, 0, 0, 0, | |
3415 doc: /* Clear font cache. */) | |
3416 () | |
3417 { | |
3418 Lisp_Object list, frame; | |
3419 | |
3420 FOR_EACH_FRAME (list, frame) | |
3421 { | |
3422 FRAME_PTR f = XFRAME (frame); | |
3423 struct font_driver_list *driver_list = f->font_driver_list; | |
3424 | |
3425 for (; driver_list; driver_list = driver_list->next) | |
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3426 if (driver_list->on) |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3427 { |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3428 Lisp_Object cache = driver_list->driver->get_cache (f); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3429 Lisp_Object val; |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3430 |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3431 val = XCDR (cache); |
91909 | 3432 while (! NILP (val) |
3433 && ! EQ (XCAR (XCAR (val)), driver_list->driver->type)) | |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3434 val = XCDR (val); |
91909 | 3435 xassert (! NILP (val)); |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3436 val = XCDR (XCAR (val)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3437 if (XINT (XCAR (val)) == 0) |
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3438 { |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3439 font_clear_cache (f, XCAR (val), driver_list->driver); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3440 XSETCDR (cache, XCDR (val)); |
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3441 } |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3442 } |
90400 | 3443 } |
3444 | |
3445 return Qnil; | |
3446 } | |
3447 | |
3448 DEFUN ("internal-set-font-style-table", Finternal_set_font_style_table, | |
3449 Sinternal_set_font_style_table, 2, 2, 0, | |
3450 doc: /* Set font style table for PROP to TABLE. | |
3451 PROP must be `:weight', `:slant', or `:width'. | |
3452 TABLE must be an alist of symbols vs the corresponding numeric values | |
3453 sorted by numeric values. */) | |
3454 (prop, table) | |
3455 Lisp_Object prop, table; | |
3456 { | |
3457 int table_index; | |
3458 int numeric; | |
3459 Lisp_Object tail, val; | |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3460 |
90400 | 3461 CHECK_SYMBOL (prop); |
3462 table_index = (EQ (prop, QCweight) ? 0 | |
3463 : EQ (prop, QCslant) ? 1 | |
3464 : EQ (prop, QCwidth) ? 2 | |
3465 : 3); | |
3466 if (table_index >= ASIZE (font_style_table)) | |
3467 error ("Invalid font style property: %s", SDATA (SYMBOL_NAME (prop))); | |
3468 table = Fcopy_sequence (table); | |
3469 numeric = -1; | |
92113
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
3470 for (tail = table; CONSP (tail); tail = XCDR (tail)) |
90400 | 3471 { |
92113
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
3472 prop = Fcar (XCAR (tail)); |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
3473 val = Fcdr (XCAR (tail)); |
90400 | 3474 CHECK_SYMBOL (prop); |
3475 CHECK_NATNUM (val); | |
3476 if (numeric > XINT (val)) | |
3477 error ("Numeric values not sorted for %s", SDATA (SYMBOL_NAME (prop))); | |
92113
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
3478 else if (numeric == XINT (val)) |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
3479 error ("Duplicate numeric values for %s", SDATA (SYMBOL_NAME (prop))); |
90400 | 3480 numeric = XINT (val); |
3481 XSETCAR (tail, Fcons (prop, val)); | |
3482 } | |
3483 ASET (font_style_table, table_index, table); | |
3484 return Qnil; | |
3485 } | |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3486 |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3487 /* The following three functions are still expremental. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3488 |
90400 | 3489 DEFUN ("font-make-gstring", Ffont_make_gstring, Sfont_make_gstring, 2, 2, 0, |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3490 doc: /* Return a newly created g-string for FONT-OBJECT with NUM glyphs. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3491 FONT-OBJECT may be nil if it is not yet known. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3492 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3493 G-string is sequence of glyphs of a specific font, |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3494 and is a vector of this form: |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3495 [ HEADER GLYPH ... ] |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3496 HEADER is a vector of this form: |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3497 [FONT-OBJECT WIDTH LBEARING RBEARING ASCENT DESCENT] |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3498 where |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3499 FONT-OBJECT is a font-object for all glyphs in the g-string, |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3500 WIDTH thry DESCENT are the metrics (in pixels) of the whole G-string. |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3501 GLYPH is a vector of this form: |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3502 [ FROM-IDX TO-IDX C CODE WIDTH LBEARING RBEARING ASCENT DESCENT |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3503 [ [X-OFF Y-OFF WADJUST] | nil] ] |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3504 where |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3505 FROM-IDX and TO-IDX are used internally and should not be touched. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3506 C is the character of the glyph. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3507 CODE is the glyph-code of C in FONT-OBJECT. |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3508 WIDTH thry DESCENT are the metrics (in pixels) of the glyph. |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3509 X-OFF and Y-OFF are offests to the base position for the glyph. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3510 WADJUST is the adjustment to the normal width of the glyph. */) |
90400 | 3511 (font_object, num) |
3512 Lisp_Object font_object, num; | |
3513 { | |
3514 Lisp_Object gstring, g; | |
3515 int len; | |
3516 int i; | |
3517 | |
3518 if (! NILP (font_object)) | |
3519 CHECK_FONT_OBJECT (font_object); | |
3520 CHECK_NATNUM (num); | |
3521 | |
3522 len = XINT (num) + 1; | |
3523 gstring = Fmake_vector (make_number (len), Qnil); | |
3524 g = Fmake_vector (make_number (6), Qnil); | |
3525 ASET (g, 0, font_object); | |
3526 ASET (gstring, 0, g); | |
3527 for (i = 1; i < len; i++) | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3528 ASET (gstring, i, Fmake_vector (make_number (10), Qnil)); |
90400 | 3529 return gstring; |
3530 } | |
3531 | |
3532 DEFUN ("font-fill-gstring", Ffont_fill_gstring, Sfont_fill_gstring, 4, 5, 0, | |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3533 doc: /* Fill in glyph-string GSTRING by characters for FONT-OBJECT. |
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3534 START and END specify the region to extract characters. |
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3535 If optional 5rd argument OBJECT is non-nil, it is a buffer or a string from |
90400 | 3536 where to extract characters. |
3537 FONT-OBJECT may be nil if GSTRING already already contains one. */) | |
3538 (gstring, font_object, start, end, object) | |
3539 Lisp_Object gstring, font_object, start, end, object; | |
3540 { | |
3541 int len, i, c; | |
3542 unsigned code; | |
3543 struct font *font; | |
3544 | |
3545 CHECK_VECTOR (gstring); | |
3546 if (NILP (font_object)) | |
90541 | 3547 font_object = LGSTRING_FONT (gstring); |
90400 | 3548 CHECK_FONT_GET_OBJECT (font_object, font); |
3549 | |
3550 if (STRINGP (object)) | |
3551 { | |
3552 const unsigned char *p; | |
3553 | |
3554 CHECK_NATNUM (start); | |
3555 CHECK_NATNUM (end); | |
3556 if (XINT (start) > XINT (end) | |
3557 || XINT (end) > ASIZE (object) | |
90541 | 3558 || XINT (end) - XINT (start) > LGSTRING_LENGTH (gstring)) |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3559 args_out_of_range_3 (object, start, end); |
90400 | 3560 |
3561 len = XINT (end) - XINT (start); | |
3562 p = SDATA (object) + string_char_to_byte (object, XINT (start)); | |
3563 for (i = 0; i < len; i++) | |
3564 { | |
3565 Lisp_Object g = LGSTRING_GLYPH (gstring, i); | |
91871
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3566 /* Shut up GCC warning in comparison with |
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3567 MOST_POSITIVE_FIXNUM below. */ |
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3568 EMACS_INT cod; |
90400 | 3569 |
3570 c = STRING_CHAR_ADVANCE (p); | |
91871
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3571 cod = code = font->driver->encode_char (font, c); |
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3572 if (cod > MOST_POSITIVE_FIXNUM || code == FONT_INVALID_CODE) |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3573 break; |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3574 LGLYPH_SET_FROM (g, i); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3575 LGLYPH_SET_TO (g, i); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3576 LGLYPH_SET_CHAR (g, c); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3577 LGLYPH_SET_CODE (g, code); |
90400 | 3578 } |
3579 } | |
3580 else | |
3581 { | |
3582 int pos, pos_byte; | |
3583 | |
3584 if (! NILP (object)) | |
3585 Fset_buffer (object); | |
3586 validate_region (&start, &end); | |
90541 | 3587 if (XINT (end) - XINT (start) > LGSTRING_LENGTH (gstring)) |
90400 | 3588 args_out_of_range (start, end); |
3589 len = XINT (end) - XINT (start); | |
3590 pos = XINT (start); | |
3591 pos_byte = CHAR_TO_BYTE (pos); | |
3592 for (i = 0; i < len; i++) | |
3593 { | |
3594 Lisp_Object g = LGSTRING_GLYPH (gstring, i); | |
91871
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3595 /* Shut up GCC warning in comparison with |
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3596 MOST_POSITIVE_FIXNUM below. */ |
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3597 EMACS_INT cod; |
90400 | 3598 |
3599 FETCH_CHAR_ADVANCE (c, pos, pos_byte); | |
91871
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3600 cod = code = font->driver->encode_char (font, c); |
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3601 if (cod > MOST_POSITIVE_FIXNUM || code == FONT_INVALID_CODE) |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3602 break; |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3603 LGLYPH_SET_FROM (g, i); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3604 LGLYPH_SET_TO (g, i); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3605 LGLYPH_SET_CHAR (g, c); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3606 LGLYPH_SET_CODE (g, code); |
90400 | 3607 } |
3608 } | |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3609 for (; i < LGSTRING_LENGTH (gstring); i++) |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3610 LGSTRING_SET_GLYPH (gstring, i, Qnil); |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3611 return Qnil; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3612 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3613 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3614 DEFUN ("font-shape-text", Ffont_shape_text, Sfont_shape_text, 3, 4, 0, |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3615 doc: /* Shape text between FROM and TO by FONT-OBJECT. |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3616 If optional 4th argument STRING is non-nil, it is a string to shape, |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3617 and FROM and TO are indices to the string. |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3618 The value is the end position of the text that can be shaped by |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3619 FONT-OBJECT. */) |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3620 (from, to, font_object, string) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3621 Lisp_Object from, to, font_object, string; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3622 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3623 struct font *font; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3624 struct font_metrics metrics; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3625 EMACS_INT start, end; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3626 Lisp_Object gstring, n; |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3627 int len, i, j; |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3628 |
92183
275e5e980fc4
If the font driver doesn't have `shape' function, return Qnil.
Kenichi Handa <handa@m17n.org>
parents:
92113
diff
changeset
|
3629 if (! FONT_OBJECT_P (font_object)) |
275e5e980fc4
If the font driver doesn't have `shape' function, return Qnil.
Kenichi Handa <handa@m17n.org>
parents:
92113
diff
changeset
|
3630 return Qnil; |
275e5e980fc4
If the font driver doesn't have `shape' function, return Qnil.
Kenichi Handa <handa@m17n.org>
parents:
92113
diff
changeset
|
3631 CHECK_FONT_GET_OBJECT (font_object, font); |
275e5e980fc4
If the font driver doesn't have `shape' function, return Qnil.
Kenichi Handa <handa@m17n.org>
parents:
92113
diff
changeset
|
3632 if (! font->driver->shape) |
275e5e980fc4
If the font driver doesn't have `shape' function, return Qnil.
Kenichi Handa <handa@m17n.org>
parents:
92113
diff
changeset
|
3633 return Qnil; |
275e5e980fc4
If the font driver doesn't have `shape' function, return Qnil.
Kenichi Handa <handa@m17n.org>
parents:
92113
diff
changeset
|
3634 |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3635 if (NILP (string)) |
90541 | 3636 { |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3637 validate_region (&from, &to); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3638 start = XFASTINT (from); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3639 end = XFASTINT (to); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3640 modify_region (current_buffer, start, end, 0); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3641 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3642 else |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3643 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3644 CHECK_STRING (string); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3645 start = XINT (from); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3646 end = XINT (to); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3647 if (start < 0 || start > end || end > SCHARS (string)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3648 args_out_of_range_3 (string, from, to); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3649 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3650 |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3651 len = end - start; |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3652 gstring = Ffont_make_gstring (font_object, make_number (len)); |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3653 Ffont_fill_gstring (gstring, font_object, from, to, string); |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3654 |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3655 /* Try at most three times with larger gstring each time. */ |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3656 for (i = 0; i < 3; i++) |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3657 { |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3658 Lisp_Object args[2]; |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3659 |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3660 n = font->driver->shape (gstring); |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3661 if (INTEGERP (n)) |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3662 break; |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3663 args[0] = gstring; |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3664 args[1] = Fmake_vector (make_number (len), Qnil); |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3665 gstring = Fvconcat (2, args); |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3666 } |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3667 if (! INTEGERP (n) || XINT (n) == 0) |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3668 return Qnil; |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3669 len = XINT (n); |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3670 |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3671 for (i = 0; i < len;) |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3672 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3673 Lisp_Object gstr; |
90541 | 3674 Lisp_Object g = LGSTRING_GLYPH (gstring, i); |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3675 EMACS_INT this_from = LGLYPH_FROM (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3676 EMACS_INT this_to = LGLYPH_TO (g) + 1; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3677 int j, k; |
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3678 int need_composition = 0; |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3679 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3680 metrics.lbearing = LGLYPH_LBEARING (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3681 metrics.rbearing = LGLYPH_RBEARING (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3682 metrics.ascent = LGLYPH_ASCENT (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3683 metrics.descent = LGLYPH_DESCENT (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3684 if (NILP (LGLYPH_ADJUSTMENT (g))) |
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3685 { |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3686 metrics.width = LGLYPH_WIDTH (g); |
91550
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
3687 if (LGLYPH_CHAR (g) == 0 || metrics.width == 0) |
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3688 need_composition = 1; |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3689 } |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3690 else |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3691 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3692 metrics.width = LGLYPH_WADJUST (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3693 metrics.lbearing += LGLYPH_XOFF (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3694 metrics.rbearing += LGLYPH_XOFF (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3695 metrics.ascent -= LGLYPH_YOFF (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3696 metrics.descent += LGLYPH_YOFF (g); |
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3697 need_composition = 1; |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3698 } |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3699 for (j = i + 1; j < len; j++) |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3700 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3701 int x; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3702 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3703 g = LGSTRING_GLYPH (gstring, j); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3704 if (this_from != LGLYPH_FROM (g)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3705 break; |
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3706 need_composition = 1; |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3707 x = metrics.width + LGLYPH_LBEARING (g) + LGLYPH_XOFF (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3708 if (metrics.lbearing > x) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3709 metrics.lbearing = x; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3710 x = metrics.width + LGLYPH_RBEARING (g) + LGLYPH_XOFF (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3711 if (metrics.rbearing < x) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3712 metrics.rbearing = x; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3713 x = LGLYPH_ASCENT (g) - LGLYPH_YOFF (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3714 if (metrics.ascent < x) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3715 metrics.ascent = x; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3716 x = LGLYPH_DESCENT (g) - LGLYPH_YOFF (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3717 if (metrics.descent < x) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3718 metrics.descent = x; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3719 if (NILP (LGLYPH_ADJUSTMENT (g))) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3720 metrics.width += LGLYPH_WIDTH (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3721 else |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3722 metrics.width += LGLYPH_WADJUST (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3723 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3724 |
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3725 if (need_composition) |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3726 { |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3727 gstr = Ffont_make_gstring (font_object, make_number (j - i)); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3728 LGSTRING_SET_WIDTH (gstr, metrics.width); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3729 LGSTRING_SET_LBEARING (gstr, metrics.lbearing); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3730 LGSTRING_SET_RBEARING (gstr, metrics.rbearing); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3731 LGSTRING_SET_ASCENT (gstr, metrics.ascent); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3732 LGSTRING_SET_DESCENT (gstr, metrics.descent); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3733 for (k = i; i < j; i++) |
91307
0afaa00ae397
(Ffont_shape_text): If the font driver doesn't have a
Kenichi Handa <handa@m17n.org>
parents:
91273
diff
changeset
|
3734 { |
0afaa00ae397
(Ffont_shape_text): If the font driver doesn't have a
Kenichi Handa <handa@m17n.org>
parents:
91273
diff
changeset
|
3735 Lisp_Object g = LGSTRING_GLYPH (gstring, i); |
0afaa00ae397
(Ffont_shape_text): If the font driver doesn't have a
Kenichi Handa <handa@m17n.org>
parents:
91273
diff
changeset
|
3736 |
0afaa00ae397
(Ffont_shape_text): If the font driver doesn't have a
Kenichi Handa <handa@m17n.org>
parents:
91273
diff
changeset
|
3737 LGLYPH_SET_FROM (g, LGLYPH_FROM (g) - this_from); |
91309
3f56aab091ed
(Ffont_shape_text): Fix setting of `to' field of glyphs.
Kenichi Handa <handa@m17n.org>
parents:
91307
diff
changeset
|
3738 LGLYPH_SET_TO (g, LGLYPH_TO (g) - this_from); |
91307
0afaa00ae397
(Ffont_shape_text): If the font driver doesn't have a
Kenichi Handa <handa@m17n.org>
parents:
91273
diff
changeset
|
3739 LGSTRING_SET_GLYPH (gstr, i - k, LGSTRING_GLYPH (gstring, i)); |
0afaa00ae397
(Ffont_shape_text): If the font driver doesn't have a
Kenichi Handa <handa@m17n.org>
parents:
91273
diff
changeset
|
3740 } |
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3741 from = make_number (start + this_from); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3742 to = make_number (start + this_to); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3743 if (NILP (string)) |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3744 Fcompose_region_internal (from, to, gstr, Qnil); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3745 else |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3746 Fcompose_string_internal (string, from, to, gstr, Qnil); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3747 } |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3748 else |
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3749 i = j; |
90541 | 3750 } |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3751 |
91192
bcad98389aeb
(Ffont_shape_text): Fix the return value.
Kenichi Handa <handa@m17n.org>
parents:
91174
diff
changeset
|
3752 return to; |
90400 | 3753 } |
3754 | |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3755 DEFUN ("font-drive-otf", Ffont_drive_otf, Sfont_drive_otf, 6, 6, 0, |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3756 doc: /* Apply OpenType features on glyph-string GSTRING-IN. |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3757 OTF-FEATURES specifies which features to apply in this format: |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3758 (SCRIPT LANGSYS GSUB GPOS) |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3759 where |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3760 SCRIPT is a symbol specifying a script tag of OpenType, |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3761 LANGSYS is a symbol specifying a langsys tag of OpenType, |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3762 GSUB and GPOS, if non-nil, are lists of symbols specifying feature tags. |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3763 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3764 If LANGYS is nil, the default langsys is selected. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3765 |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3766 The features are applied in the order they appear in the list. The |
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3767 symbol `*' means to apply all available features not present in this |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3768 list, and the remaining features are ignored. For instance, (vatu |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3769 pstf * haln) is to apply vatu and pstf in this order, then to apply |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3770 all available features other than vatu, pstf, and haln. |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3771 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3772 The features are applied to the glyphs in the range FROM and TO of |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3773 the glyph-string GSTRING-IN. |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3774 |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3775 If some feature is actually applicable, the resulting glyphs are |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3776 produced in the glyph-string GSTRING-OUT from the index INDEX. In |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3777 this case, the value is the number of produced glyphs. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3778 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3779 If no feature is applicable, no glyph is produced in GSTRING-OUT, and |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3780 the value is 0. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3781 |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3782 If GSTRING-OUT is too short to hold produced glyphs, no glyphs are |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3783 produced in GSTRING-OUT, and the value is nil. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3784 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3785 See the documentation of `font-make-gstring' for the format of |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3786 glyph-string. */) |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3787 (otf_features, gstring_in, from, to, gstring_out, index) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3788 Lisp_Object otf_features, gstring_in, from, to, gstring_out, index; |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3789 { |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3790 Lisp_Object font_object = LGSTRING_FONT (gstring_in); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3791 Lisp_Object val; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3792 struct font *font; |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3793 int len, num; |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3794 |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3795 check_otf_features (otf_features); |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3796 CHECK_FONT_GET_OBJECT (font_object, font); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3797 if (! font->driver->otf_drive) |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3798 error ("Font backend %s can't drive OpenType GSUB table", |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3799 SDATA (SYMBOL_NAME (font->driver->type))); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3800 CHECK_CONS (otf_features); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3801 CHECK_SYMBOL (XCAR (otf_features)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3802 val = XCDR (otf_features); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3803 CHECK_SYMBOL (XCAR (val)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3804 val = XCDR (otf_features); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3805 if (! NILP (val)) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3806 CHECK_CONS (val); |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3807 len = check_gstring (gstring_in); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3808 CHECK_VECTOR (gstring_out); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3809 CHECK_NATNUM (from); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3810 CHECK_NATNUM (to); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3811 CHECK_NATNUM (index); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3812 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3813 if (XINT (from) >= XINT (to) || XINT (to) > len) |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3814 args_out_of_range_3 (from, to, make_number (len)); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3815 if (XINT (index) >= ASIZE (gstring_out)) |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3816 args_out_of_range (index, make_number (ASIZE (gstring_out))); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3817 num = font->driver->otf_drive (font, otf_features, |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3818 gstring_in, XINT (from), XINT (to), |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3819 gstring_out, XINT (index), 0); |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3820 if (num < 0) |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3821 return Qnil; |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3822 return make_number (num); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3823 } |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3824 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3825 DEFUN ("font-otf-alternates", Ffont_otf_alternates, Sfont_otf_alternates, |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3826 3, 3, 0, |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3827 doc: /* Return a list of alternate glyphs of CHARACTER in FONT-OBJECT. |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3828 OTF-FEATURES specifies which features of the font FONT-OBJECT to apply |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3829 in this format: |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3830 (SCRIPT LANGSYS FEATURE ...) |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3831 See the documentation of `font-otf-gsub' for more detail. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3832 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3833 The value is a list of cons cells of the format (GLYPH-ID . CHARACTER), |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3834 where GLYPH-ID is a glyph index of the font, and CHARACTER is a |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3835 character code corresponding to the glyph or nil if there's no |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3836 corresponding character. */) |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3837 (font_object, character, otf_features) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3838 Lisp_Object font_object, character, otf_features; |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3839 { |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3840 struct font *font; |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3841 Lisp_Object gstring_in, gstring_out, g; |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3842 Lisp_Object alternates; |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3843 int i, num; |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3844 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3845 CHECK_FONT_GET_OBJECT (font_object, font); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3846 if (! font->driver->otf_drive) |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3847 error ("Font backend %s can't drive OpenType GSUB table", |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3848 SDATA (SYMBOL_NAME (font->driver->type))); |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3849 CHECK_CHARACTER (character); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3850 CHECK_CONS (otf_features); |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3851 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3852 gstring_in = Ffont_make_gstring (font_object, make_number (1)); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3853 g = LGSTRING_GLYPH (gstring_in, 0); |
91550
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
3854 LGLYPH_SET_CHAR (g, XINT (character)); |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3855 gstring_out = Ffont_make_gstring (font_object, make_number (10)); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3856 while ((num = font->driver->otf_drive (font, otf_features, gstring_in, 0, 1, |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3857 gstring_out, 0, 1)) < 0) |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3858 gstring_out = Ffont_make_gstring (font_object, |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3859 make_number (ASIZE (gstring_out) * 2)); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3860 alternates = Qnil; |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3861 for (i = 0; i < num; i++) |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3862 { |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3863 Lisp_Object g = LGSTRING_GLYPH (gstring_out, i); |
91550
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
3864 int c = LGLYPH_CHAR (g); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
3865 unsigned code = LGLYPH_CODE (g); |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3866 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3867 alternates = Fcons (Fcons (make_number (code), |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3868 c > 0 ? make_number (c) : Qnil), |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3869 alternates); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3870 } |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3871 return Fnreverse (alternates); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3872 } |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3873 |
90400 | 3874 |
3875 #ifdef FONT_DEBUG | |
3876 | |
3877 DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0, | |
3878 doc: /* Open FONT-ENTITY. */) | |
3879 (font_entity, size, frame) | |
3880 Lisp_Object font_entity; | |
3881 Lisp_Object size; | |
3882 Lisp_Object frame; | |
3883 { | |
3884 int isize; | |
3885 | |
3886 CHECK_FONT_ENTITY (font_entity); | |
3887 if (NILP (size)) | |
3888 size = AREF (font_entity, FONT_SIZE_INDEX); | |
3889 CHECK_NUMBER (size); | |
3890 if (NILP (frame)) | |
3891 frame = selected_frame; | |
3892 CHECK_LIVE_FRAME (frame); | |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3893 |
90400 | 3894 isize = XINT (size); |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3895 if (isize == 0) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3896 isize = 120; |
90400 | 3897 if (isize < 0) |
3898 isize = POINT_TO_PIXEL (- isize, XFRAME (frame)->resy); | |
3899 | |
3900 return font_open_entity (XFRAME (frame), font_entity, isize); | |
3901 } | |
3902 | |
3903 DEFUN ("close-font", Fclose_font, Sclose_font, 1, 2, 0, | |
3904 doc: /* Close FONT-OBJECT. */) | |
3905 (font_object, frame) | |
3906 Lisp_Object font_object, frame; | |
3907 { | |
3908 CHECK_FONT_OBJECT (font_object); | |
3909 if (NILP (frame)) | |
3910 frame = selected_frame; | |
3911 CHECK_LIVE_FRAME (frame); | |
3912 font_close_object (XFRAME (frame), font_object); | |
3913 return Qnil; | |
3914 } | |
3915 | |
3916 DEFUN ("query-font", Fquery_font, Squery_font, 1, 1, 0, | |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3917 doc: /* Return information about FONT-OBJECT. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3918 The value is a vector: |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3919 [ NAME FILENAME PIXEL-SIZE SIZE ASCENT DESCENT SPACE-WIDTH AVERAGE-WIDTH |
90677
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
3920 CAPABILITY ] |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3921 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3922 NAME is a string of the font name (or nil if the font backend doesn't |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3923 provide a name). |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3924 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3925 FILENAME is a string of the font file (or nil if the font backend |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3926 doesn't provide a file name). |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3927 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3928 PIXEL-SIZE is a pixel size by which the font is opened. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3929 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3930 SIZE is a maximum advance width of the font in pixel. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3931 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3932 ASCENT, DESCENT, SPACE-WIDTH, AVERAGE-WIDTH are metrics of the font in |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3933 pixel. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3934 |
90677
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
3935 CAPABILITY is a list whose first element is a symbol representing the |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
3936 font format \(x, opentype, truetype, type1, pcf, or bdf) and the |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
3937 remaining elements describes a detail of the font capability. |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
3938 |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
3939 If the font is OpenType font, the form of the list is |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
3940 \(opentype GSUB GPOS) |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
3941 where GSUB shows which "GSUB" features the font supports, and GPOS |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
3942 shows which "GPOS" features the font supports. Both GSUB and GPOS are |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
3943 lists of the format: |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
3944 \((SCRIPT (LANGSYS FEATURE ...) ...) ...) |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
3945 |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
3946 If the font is not OpenType font, currently the length of the form is |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
3947 one. |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3948 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3949 SCRIPT is a symbol representing OpenType script tag. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3950 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3951 LANGSYS is a symbol representing OpenType langsys tag, or nil |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3952 representing the default langsys. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3953 |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3954 FEATURE is a symbol representing OpenType feature tag. |
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3955 |
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3956 If the font is not OpenType font, CAPABILITY is nil. */) |
90400 | 3957 (font_object) |
3958 Lisp_Object font_object; | |
3959 { | |
3960 struct font *font; | |
3961 Lisp_Object val; | |
3962 | |
3963 CHECK_FONT_GET_OBJECT (font_object, font); | |
3964 | |
3965 val = Fmake_vector (make_number (9), Qnil); | |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3966 if (font->font.full_name) |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3967 ASET (val, 0, make_unibyte_string (font->font.full_name, |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3968 strlen (font->font.full_name))); |
90400 | 3969 if (font->file_name) |
3970 ASET (val, 1, make_unibyte_string (font->file_name, | |
3971 strlen (font->file_name))); | |
3972 ASET (val, 2, make_number (font->pixel_size)); | |
3973 ASET (val, 3, make_number (font->font.size)); | |
3974 ASET (val, 4, make_number (font->ascent)); | |
3975 ASET (val, 5, make_number (font->descent)); | |
3976 ASET (val, 6, make_number (font->font.space_width)); | |
3977 ASET (val, 7, make_number (font->font.average_width)); | |
3978 if (font->driver->otf_capability) | |
90677
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
3979 ASET (val, 8, Fcons (Qopentype, font->driver->otf_capability (font))); |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
3980 else |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
3981 ASET (val, 8, Fcons (font->format, Qnil)); |
90400 | 3982 return val; |
3983 } | |
3984 | |
3985 DEFUN ("get-font-glyphs", Fget_font_glyphs, Sget_font_glyphs, 2, 2, 0, | |
3986 doc: /* Return a vector of glyphs of FONT-OBJECT for drawing STRING. | |
3987 Each element is a vector [GLYPH-CODE LBEARING RBEARING WIDTH ASCENT DESCENT]. */) | |
3988 (font_object, string) | |
3989 Lisp_Object font_object, string; | |
3990 { | |
3991 struct font *font; | |
3992 int i, len; | |
3993 Lisp_Object vec; | |
3994 | |
3995 CHECK_FONT_GET_OBJECT (font_object, font); | |
3996 CHECK_STRING (string); | |
3997 len = SCHARS (string); | |
3998 vec = Fmake_vector (make_number (len), Qnil); | |
3999 for (i = 0; i < len; i++) | |
4000 { | |
4001 Lisp_Object ch = Faref (string, make_number (i)); | |
4002 Lisp_Object val; | |
4003 int c = XINT (ch); | |
4004 unsigned code; | |
91871
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
4005 EMACS_INT cod; |
90400 | 4006 struct font_metrics metrics; |
4007 | |
91871
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
4008 cod = code = font->driver->encode_char (font, c); |
90400 | 4009 if (code == FONT_INVALID_CODE) |
4010 continue; | |
4011 val = Fmake_vector (make_number (6), Qnil); | |
91871
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
4012 if (cod <= MOST_POSITIVE_FIXNUM) |
90400 | 4013 ASET (val, 0, make_number (code)); |
4014 else | |
4015 ASET (val, 0, Fcons (make_number (code >> 16), | |
4016 make_number (code & 0xFFFF))); | |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4017 font->driver->text_extents (font, &code, 1, &metrics); |
90400 | 4018 ASET (val, 1, make_number (metrics.lbearing)); |
4019 ASET (val, 2, make_number (metrics.rbearing)); | |
4020 ASET (val, 3, make_number (metrics.width)); | |
4021 ASET (val, 4, make_number (metrics.ascent)); | |
4022 ASET (val, 5, make_number (metrics.descent)); | |
4023 ASET (vec, i, val); | |
4024 } | |
4025 return vec; | |
4026 } | |
4027 | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4028 DEFUN ("font-match-p", Ffont_match_p, Sfont_match_p, 2, 2, 0, |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4029 doc: /* Return t iff font-spec SPEC matches with FONT. |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4030 FONT is a font-spec, font-entity, or font-object. */) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4031 (spec, font) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4032 Lisp_Object spec, font; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4033 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4034 CHECK_FONT_SPEC (spec); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4035 if (FONT_OBJECT_P (font)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4036 font = ((struct font *) XSAVE_VALUE (font)->pointer)->entity; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4037 else if (! FONT_ENTITY_P (font)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4038 CHECK_FONT_SPEC (font); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4039 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4040 return (font_match_p (spec, font) ? Qt : Qnil); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4041 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4042 |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4043 DEFUN ("font-at", Ffont_at, Sfont_at, 1, 3, 0, |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4044 doc: /* Return a font-object for displaying a character at POSITION. |
90541 | 4045 Optional second arg WINDOW, if non-nil, is a window displaying |
4046 the current buffer. It defaults to the currently selected window. */) | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4047 (position, window, string) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4048 Lisp_Object position, window, string; |
90541 | 4049 { |
4050 struct window *w; | |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
4051 EMACS_INT pos; |
90541 | 4052 |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4053 if (NILP (string)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4054 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4055 CHECK_NUMBER_COERCE_MARKER (position); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4056 pos = XINT (position); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4057 if (pos < BEGV || pos >= ZV) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4058 args_out_of_range_3 (position, make_number (BEGV), make_number (ZV)); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4059 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4060 else |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4061 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4062 EMACS_INT len; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4063 unsigned char *str; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4064 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4065 CHECK_NUMBER (position); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4066 CHECK_STRING (string); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4067 pos = XINT (position); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4068 if (pos < 0 || pos >= SCHARS (string)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4069 args_out_of_range (string, position); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4070 } |
90541 | 4071 if (NILP (window)) |
4072 window = selected_window; | |
4073 CHECK_LIVE_WINDOW (window); | |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4074 w = XWINDOW (window); |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4075 |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4076 return font_at (-1, pos, NULL, w, string); |
90541 | 4077 } |
4078 | |
90400 | 4079 #if 0 |
4080 DEFUN ("draw-string", Fdraw_string, Sdraw_string, 2, 2, 0, | |
4081 doc: /* Draw STRING by FONT-OBJECT on the top left corner of the current frame. | |
4082 The value is a number of glyphs drawn. | |
4083 Type C-l to recover what previously shown. */) | |
4084 (font_object, string) | |
4085 Lisp_Object font_object, string; | |
4086 { | |
4087 Lisp_Object frame = selected_frame; | |
4088 FRAME_PTR f = XFRAME (frame); | |
4089 struct font *font; | |
4090 struct face *face; | |
4091 int i, len, width; | |
4092 unsigned *code; | |
4093 | |
4094 CHECK_FONT_GET_OBJECT (font_object, font); | |
4095 CHECK_STRING (string); | |
4096 len = SCHARS (string); | |
4097 code = alloca (sizeof (unsigned) * len); | |
4098 for (i = 0; i < len; i++) | |
4099 { | |
4100 Lisp_Object ch = Faref (string, make_number (i)); | |
4101 Lisp_Object val; | |
4102 int c = XINT (ch); | |
4103 | |
4104 code[i] = font->driver->encode_char (font, c); | |
4105 if (code[i] == FONT_INVALID_CODE) | |
4106 break; | |
4107 } | |
4108 face = FACE_FROM_ID (f, DEFAULT_FACE_ID); | |
4109 face->fontp = font; | |
4110 if (font->driver->prepare_face) | |
4111 font->driver->prepare_face (f, face); | |
4112 width = font->driver->text_extents (font, code, i, NULL); | |
4113 len = font->driver->draw_text (f, face, 0, font->ascent, code, i, width); | |
4114 if (font->driver->done_face) | |
4115 font->driver->done_face (f, face); | |
4116 face->fontp = NULL; | |
4117 return make_number (len); | |
4118 } | |
4119 #endif | |
4120 | |
4121 #endif /* FONT_DEBUG */ | |
4122 | |
4123 | |
4124 extern void syms_of_ftfont P_ (()); | |
4125 extern void syms_of_xfont P_ (()); | |
4126 extern void syms_of_xftfont P_ (()); | |
4127 extern void syms_of_ftxfont P_ (()); | |
4128 extern void syms_of_bdffont P_ (()); | |
4129 extern void syms_of_w32font P_ (()); | |
4130 extern void syms_of_atmfont P_ (()); | |
4131 | |
4132 void | |
4133 syms_of_font () | |
4134 { | |
4135 sort_shift_bits[FONT_SLANT_INDEX] = 0; | |
4136 sort_shift_bits[FONT_WEIGHT_INDEX] = 7; | |
4137 sort_shift_bits[FONT_SIZE_INDEX] = 14; | |
4138 sort_shift_bits[FONT_WIDTH_INDEX] = 21; | |
4139 sort_shift_bits[FONT_ADSTYLE_INDEX] = 28; | |
4140 sort_shift_bits[FONT_FOUNDRY_INDEX] = 29; | |
4141 sort_shift_bits[FONT_FAMILY_INDEX] = 30; | |
4142 sort_shift_bits[FONT_REGISTRY_INDEX] = 31; | |
90507
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
4143 /* Note that sort_shift_bits[FONT_TYPE_INDEX] is never used. */ |
90400 | 4144 |
4145 staticpro (&font_style_table); | |
4146 font_style_table = Fmake_vector (make_number (3), Qnil); | |
4147 | |
4148 staticpro (&font_family_alist); | |
4149 font_family_alist = Qnil; | |
4150 | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4151 staticpro (&font_charset_alist); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4152 font_charset_alist = Qnil; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4153 |
90677
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4154 DEFSYM (Qopentype, "opentype"); |
90400 | 4155 |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
4156 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
|
4157 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
|
4158 DEFSYM (Qunicode_bmp, "unicode-bmp"); |
90622
bb9362e3a03b
(Qunicode_sip): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90590
diff
changeset
|
4159 DEFSYM (Qunicode_sip, "unicode-sip"); |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
4160 |
90400 | 4161 DEFSYM (QCotf, ":otf"); |
4162 DEFSYM (QClanguage, ":language"); | |
4163 DEFSYM (QCscript, ":script"); | |
91125
6c9a19ff6c55
(Qfontp): Remove unused symbol.
Jason Rumney <jasonr@gnu.org>
parents:
91112
diff
changeset
|
4164 DEFSYM (QCantialias, ":antialias"); |
90400 | 4165 |
4166 DEFSYM (QCfoundry, ":foundry"); | |
4167 DEFSYM (QCadstyle, ":adstyle"); | |
4168 DEFSYM (QCregistry, ":registry"); | |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
4169 DEFSYM (QCspacing, ":spacing"); |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
4170 DEFSYM (QCdpi, ":dpi"); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4171 DEFSYM (QCscalable, ":scalable"); |
90400 | 4172 DEFSYM (QCextra, ":extra"); |
4173 | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4174 DEFSYM (Qc, "c"); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4175 DEFSYM (Qm, "m"); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4176 DEFSYM (Qp, "p"); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4177 DEFSYM (Qd, "d"); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4178 |
90400 | 4179 staticpro (&null_string); |
4180 null_string = build_string (""); | |
4181 staticpro (&null_vector); | |
4182 null_vector = Fmake_vector (make_number (0), Qnil); | |
4183 | |
4184 staticpro (&scratch_font_spec); | |
4185 scratch_font_spec = Ffont_spec (0, NULL); | |
4186 staticpro (&scratch_font_prefer); | |
4187 scratch_font_prefer = Ffont_spec (0, NULL); | |
4188 | |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4189 #ifdef HAVE_LIBOTF |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4190 staticpro (&otf_list); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4191 otf_list = Qnil; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4192 #endif |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4193 |
90400 | 4194 defsubr (&Sfontp); |
4195 defsubr (&Sfont_spec); | |
4196 defsubr (&Sfont_get); | |
4197 defsubr (&Sfont_put); | |
4198 defsubr (&Slist_fonts); | |
4199 defsubr (&Slist_families); | |
4200 defsubr (&Sfind_font); | |
4201 defsubr (&Sfont_xlfd_name); | |
4202 defsubr (&Sclear_font_cache); | |
4203 defsubr (&Sinternal_set_font_style_table); | |
4204 defsubr (&Sfont_make_gstring); | |
4205 defsubr (&Sfont_fill_gstring); | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4206 defsubr (&Sfont_shape_text); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4207 defsubr (&Sfont_drive_otf); |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4208 defsubr (&Sfont_otf_alternates); |
90400 | 4209 |
4210 #ifdef FONT_DEBUG | |
4211 defsubr (&Sopen_font); | |
4212 defsubr (&Sclose_font); | |
4213 defsubr (&Squery_font); | |
4214 defsubr (&Sget_font_glyphs); | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4215 defsubr (&Sfont_match_p); |
90541 | 4216 defsubr (&Sfont_at); |
90400 | 4217 #if 0 |
4218 defsubr (&Sdraw_string); | |
4219 #endif | |
4220 #endif /* FONT_DEBUG */ | |
4221 | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4222 #ifdef USE_FONT_BACKEND |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4223 if (enable_font_backend) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4224 { |
90400 | 4225 #ifdef HAVE_FREETYPE |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4226 syms_of_ftfont (); |
90400 | 4227 #ifdef HAVE_X_WINDOWS |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4228 syms_of_xfont (); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4229 syms_of_ftxfont (); |
90400 | 4230 #ifdef HAVE_XFT |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4231 syms_of_xftfont (); |
90400 | 4232 #endif /* HAVE_XFT */ |
4233 #endif /* HAVE_X_WINDOWS */ | |
4234 #else /* not HAVE_FREETYPE */ | |
4235 #ifdef HAVE_X_WINDOWS | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4236 syms_of_xfont (); |
90400 | 4237 #endif /* HAVE_X_WINDOWS */ |
4238 #endif /* not HAVE_FREETYPE */ | |
4239 #ifdef HAVE_BDFFONT | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4240 syms_of_bdffont (); |
90400 | 4241 #endif /* HAVE_BDFFONT */ |
4242 #ifdef WINDOWSNT | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4243 syms_of_w32font (); |
90400 | 4244 #endif /* WINDOWSNT */ |
4245 #ifdef MAC_OS | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4246 syms_of_atmfont (); |
90400 | 4247 #endif /* MAC_OS */ |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4248 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4249 #endif /* USE_FONT_BACKEND */ |
90400 | 4250 } |
90427 | 4251 |
4252 /* arch-tag: 74c9475d-5976-4c93-a327-942ae3072846 | |
4253 (do not change this comment) */ |