Mercurial > emacs
annotate src/font.c @ 95065:36c19ba93dca
(fortran-font-lock-keywords-2): Add .eqv., .neqv.
| author | Glenn Morris <rgm@gnu.org> |
|---|---|
| date | Sat, 17 May 2008 20:08:37 +0000 |
| parents | 125a7ecf00db |
| children | ae4280e6a166 |
| 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 | |
|
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94926
diff
changeset
|
9 GNU Emacs is free software: you can redistribute it and/or modify |
| 90400 | 10 it under the terms of the GNU General Public License as published by |
|
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94926
diff
changeset
|
11 the Free Software Foundation, either version 3 of the License, or |
|
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94926
diff
changeset
|
12 (at your option) any later version. |
| 90400 | 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 | |
|
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94926
diff
changeset
|
20 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 90400 | 21 |
| 22 #include <config.h> | |
| 23 #include <stdio.h> | |
| 24 #include <stdlib.h> | |
| 94926 | 25 #include <strings.h> |
| 90400 | 26 #include <ctype.h> |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
27 #ifdef HAVE_M17N_FLT |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
28 #include <m17n-flt.h> |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
29 #endif |
| 90400 | 30 |
| 31 #include "lisp.h" | |
| 32 #include "buffer.h" | |
| 33 #include "frame.h" | |
| 90541 | 34 #include "window.h" |
| 90400 | 35 #include "dispextern.h" |
| 36 #include "charset.h" | |
| 37 #include "character.h" | |
| 38 #include "composite.h" | |
| 39 #include "fontset.h" | |
| 40 #include "font.h" | |
| 41 | |
| 91909 | 42 #ifdef HAVE_X_WINDOWS |
| 43 #include "xterm.h" | |
| 44 #endif /* HAVE_X_WINDOWS */ | |
| 45 | |
| 46 #ifdef HAVE_NTGUI | |
| 47 #include "w32term.h" | |
| 48 #endif /* HAVE_NTGUI */ | |
| 49 | |
| 50 #ifdef MAC_OS | |
| 51 #include "macterm.h" | |
| 52 #endif /* MAC_OS */ | |
| 53 | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
54 #ifndef FONT_DEBUG |
| 90400 | 55 #define FONT_DEBUG |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
56 #endif |
| 90400 | 57 |
| 58 #ifdef FONT_DEBUG | |
| 59 #undef xassert | |
| 60 #define xassert(X) do {if (!(X)) abort ();} while (0) | |
| 61 #else | |
| 62 #define xassert(X) (void) 0 | |
| 63 #endif | |
| 64 | |
| 94926 | 65 Lisp_Object Qfont_spec, Qfont_entity, Qfont_object; |
| 90400 | 66 |
|
90677
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
67 Lisp_Object Qopentype; |
|
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
68 |
| 94926 | 69 /* Important character set strings. */ |
|
90622
bb9362e3a03b
(Qunicode_sip): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90590
diff
changeset
|
70 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
|
71 |
| 90400 | 72 /* Special vector of zero length. This is repeatedly used by (struct |
| 73 font_driver *)->list when a specified font is not found. */ | |
| 94926 | 74 static Lisp_Object null_vector; |
| 75 | |
| 76 /* Vector of 3 elements. Each element is a vector for one of font | |
| 77 style properties (weight, slant, width). The vector contains a | |
| 90400 | 78 mapping between symbolic property values (e.g. `medium' for weight) |
| 79 and numeric property values (e.g. 100). So, it looks like this: | |
| 94926 | 80 [[(ultra-light . 20) ... (black . 210)] |
| 81 [(reverse-oblique . 0) ... (oblique . 210)] | |
| 82 [(ultra-contains . 50) ... (wide . 200)]] */ | |
| 90400 | 83 static Lisp_Object font_style_table; |
| 84 | |
| 94926 | 85 extern Lisp_Object Qnormal; |
| 90400 | 86 |
| 87 /* Symbols representing keys of normal font properties. */ | |
| 88 extern Lisp_Object QCtype, QCfamily, QCweight, QCslant, QCwidth, QCsize, QCname; | |
| 94926 | 89 Lisp_Object QCfoundry, QCadstyle, QCregistry; |
| 90400 | 90 /* Symbols representing keys of font extra info. */ |
| 94926 | 91 Lisp_Object QCspacing, QCdpi, QCscalable, QCotf, QClang, QCscript, QCavgwidth; |
| 92 Lisp_Object QCantialias, QCfont_entity, QCfc_unknown_spec; | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
93 /* Symbols representing values of font spacing property. */ |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
94 Lisp_Object Qc, Qm, Qp, Qd; |
| 90400 | 95 |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
96 /* 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
|
97 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
|
98 Vfont_encoding_alist on demand. |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
99 |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
100 Eash element has the form: |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
101 (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
|
102 or |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
103 (REGISTRY . nil) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
104 |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
105 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
|
106 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
|
107 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
|
108 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
|
109 |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
110 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
|
111 retrieved. */ |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
112 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
|
113 |
|
91112
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
114 /* 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
|
115 register_font_driver in syms_of_XXXfont to register its font-driver |
| 90400 | 116 here. */ |
| 117 static struct font_driver_list *font_driver_list; | |
| 118 | |
| 94926 | 119 |
| 120 | |
| 121 /* Creaters of font-related Lisp object. */ | |
| 122 | |
| 123 Lisp_Object | |
| 124 font_make_spec () | |
| 125 { | |
| 126 Lisp_Object font_spec; | |
| 127 struct font_spec *spec | |
| 128 = ((struct font_spec *) | |
| 129 allocate_pseudovector (VECSIZE (struct font_spec), | |
| 130 FONT_SPEC_MAX, PVEC_FONT)); | |
| 131 XSETFONT (font_spec, spec); | |
| 132 return font_spec; | |
| 133 } | |
| 134 | |
| 135 Lisp_Object | |
| 136 font_make_entity () | |
| 137 { | |
| 138 Lisp_Object font_entity; | |
| 139 struct font_entity *entity | |
| 140 = ((struct font_entity *) | |
| 141 allocate_pseudovector (VECSIZE (struct font_entity), | |
| 142 FONT_ENTITY_MAX, PVEC_FONT)); | |
| 143 XSETFONT (font_entity, entity); | |
| 144 return font_entity; | |
| 145 } | |
| 146 | |
| 147 Lisp_Object | |
| 148 font_make_object (size) | |
| 149 int size; | |
| 150 { | |
| 151 Lisp_Object font_object; | |
| 152 struct font *font | |
| 153 = (struct font *) allocate_pseudovector (size, FONT_OBJECT_MAX, PVEC_FONT); | |
| 154 XSETFONT (font_object, font); | |
| 155 | |
| 156 return font_object; | |
| 157 } | |
| 158 | |
| 159 | |
| 160 | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
161 static int font_pixel_size P_ ((FRAME_PTR f, Lisp_Object)); |
| 94926 | 162 static Lisp_Object font_open_entity P_ ((FRAME_PTR, Lisp_Object, int)); |
| 163 static Lisp_Object font_matching_entity P_ ((FRAME_PTR, Lisp_Object *, | |
| 90400 | 164 Lisp_Object)); |
| 165 | |
| 166 /* Number of registered font drivers. */ | |
| 167 static int num_font_drivers; | |
| 168 | |
| 94926 | 169 |
| 170 /* Return a Lispy value of a font property value at STR and LEN bytes. | |
| 171 If STR is "*", it returns nil. | |
| 172 If all characters in STR are digits, it returns an integer. | |
| 173 Otherwise, it returns a symbol interned from STR. */ | |
| 174 | |
| 175 Lisp_Object | |
| 176 font_intern_prop (str, len) | |
| 177 char *str; | |
| 178 int len; | |
| 179 { | |
| 180 int i; | |
| 181 Lisp_Object tem, string; | |
| 182 Lisp_Object obarray; | |
| 183 | |
| 184 if (len == 1 && *str == '*') | |
| 185 return Qnil; | |
| 186 if (len >=1 && isdigit (*str)) | |
| 187 { | |
| 188 for (i = 1; i < len; i++) | |
| 189 if (! isdigit (str[i])) | |
| 190 break; | |
| 191 if (i == len) | |
| 192 return make_number (atoi (str)); | |
| 193 } | |
| 194 | |
| 195 /* The following code is copied from the function intern (in lread.c). */ | |
| 196 obarray = Vobarray; | |
| 197 if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0) | |
| 198 obarray = check_obarray (obarray); | |
| 199 tem = oblookup (obarray, str, len, len); | |
| 200 if (SYMBOLP (tem)) | |
| 201 return tem; | |
| 202 return Fintern (make_unibyte_string (str, len), obarray); | |
| 203 } | |
| 204 | |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
205 /* 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
|
206 |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
207 static int |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
208 font_pixel_size (f, spec) |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
209 FRAME_PTR f; |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
210 Lisp_Object spec; |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
211 { |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
212 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
|
213 double point_size; |
| 94926 | 214 int dpi, pixel_size; |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
215 Lisp_Object extra, val; |
|
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
216 |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
217 if (INTEGERP (size)) |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
218 return XINT (size); |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
219 if (NILP (size)) |
| 94926 | 220 return 0; xassert (FLOATP (size)); |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
221 point_size = XFLOAT_DATA (size); |
| 94926 | 222 val = AREF (spec, FONT_DPI_INDEX); |
| 223 if (INTEGERP (val)) | |
| 224 dpi = XINT (XCDR (val)); | |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
225 else |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
226 dpi = f->resy; |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
227 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
|
228 return pixel_size; |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
229 } |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
230 |
| 94926 | 231 |
| 232 /* Return a value of PROP's VAL (symbol or integer) to be stored in a | |
| 233 font vector. If VAL is not valid (i.e. not registered in | |
| 234 font_style_table), return -1 if NOERROR is zero, and return a | |
| 235 proper index if NOERROR is nonzero. In that case, register VAL in | |
| 236 font_style_table if VAL is a symbol, and return a closest index if | |
| 237 VAL is an integer. */ | |
| 238 | |
| 239 int | |
| 240 font_style_to_value (prop, val, noerror) | |
| 90400 | 241 enum font_property_index prop; |
| 94926 | 242 Lisp_Object val; |
| 243 int noerror; | |
| 90400 | 244 { |
| 94926 | 245 Lisp_Object table = AREF (font_style_table, prop - FONT_WEIGHT_INDEX); |
| 246 int len = ASIZE (table); | |
| 247 int i; | |
| 248 | |
| 249 if (SYMBOLP (val)) | |
| 90400 | 250 { |
| 94926 | 251 char *s; |
| 252 Lisp_Object args[2], elt; | |
| 253 | |
| 254 /* At first try exact match. */ | |
| 255 for (i = 0; i < len; i++) | |
| 256 if (EQ (val, XCAR (AREF (table, i)))) | |
| 257 return (XINT (XCDR (AREF (table, i))) << 8) | i; | |
| 258 /* Try also with case-folding match. */ | |
| 259 s = SDATA (SYMBOL_NAME (val)); | |
| 260 for (i = 0; i < len; i++) | |
| 90400 | 261 { |
| 94926 | 262 elt = XCAR (AREF (table, i)); |
| 263 if (strcasecmp (s, (char *) SDATA (SYMBOL_NAME (elt))) == 0) | |
| 264 return i; | |
| 90400 | 265 } |
| 94926 | 266 if (! noerror) |
| 267 return -1; | |
| 268 if (len == 255) | |
| 269 abort (); | |
| 270 args[0] = table; | |
| 271 args[1] = Fmake_vector (make_number (1), Fcons (val, make_number (255))); | |
| 272 ASET (font_style_table, prop - FONT_WEIGHT_INDEX, Fvconcat (2, args)); | |
| 273 return (255 << 8) | i; | |
| 90400 | 274 } |
| 94926 | 275 else |
| 276 { | |
| 277 int last_i, i, last_n; | |
| 278 int numeric = XINT (val); | |
| 279 | |
| 280 for (i = 1, last_i = last_n = -1; i < len;) | |
| 281 { | |
| 282 int n = XINT (XCDR (AREF (table, i))); | |
| 283 | |
| 284 if (numeric == n) | |
| 285 return (n << 8) | i; | |
| 286 if (numeric < n) | |
| 287 { | |
| 288 if (! noerror) | |
| 289 return -1; | |
| 290 return ((last_i < 0 || n - numeric < numeric - last_n) | |
| 291 ? (n << 8) | i : (last_n << 8 | last_i)); | |
| 292 } | |
| 293 last_i = i; | |
| 294 last_n = n; | |
| 295 for (i++; i < len && n == XINT (XCDR (AREF (table, i + 1))); i++); | |
| 296 } | |
| 297 if (! noerror) | |
| 298 return -1; | |
| 299 return (last_n << 8) | last_i; | |
| 300 } | |
| 90400 | 301 } |
| 302 | |
| 303 Lisp_Object | |
| 94926 | 304 font_style_symbolic (font, prop, for_face) |
| 305 Lisp_Object font; | |
| 306 enum font_property_index prop; | |
| 307 int for_face; | |
| 90400 | 308 { |
| 94926 | 309 Lisp_Object val = AREF (font, prop); |
| 310 Lisp_Object table; | |
| 311 int i, numeric; | |
| 312 | |
| 313 if (NILP (val)) | |
| 314 return Qnil; | |
| 315 table = AREF (font_style_table, prop - FONT_WEIGHT_INDEX); | |
| 316 if (! for_face) | |
| 317 return XCAR (AREF (table, XINT (val) & 0xFF)); | |
| 318 numeric = XINT (val) >> 8; | |
| 319 for (i = 0; i < ASIZE (table); i++) | |
| 320 if (XINT (XCDR (AREF (table, i))) == numeric) | |
| 321 return XCAR (AREF (table, i)); | |
| 322 abort (); | |
| 323 return Qnil; | |
| 90400 | 324 } |
| 325 | |
| 326 extern Lisp_Object Vface_alternative_font_family_alist; | |
| 327 | |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
328 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
|
329 |
| 94926 | 330 |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
331 /* 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
|
332 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
|
333 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
|
334 |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
335 int |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
336 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
|
337 Lisp_Object registry; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
338 struct charset **encoding, **repertory; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
339 { |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
340 Lisp_Object val; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
341 int encoding_id, repertory_id; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
342 |
| 94926 | 343 val = Fassoc_string (registry, font_charset_alist, Qt); |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
344 if (! NILP (val)) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
345 { |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
346 val = XCDR (val); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
347 if (NILP (val)) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
348 return -1; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
349 encoding_id = XINT (XCAR (val)); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
350 repertory_id = XINT (XCDR (val)); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
351 } |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
352 else |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
353 { |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
354 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
|
355 if (SYMBOLP (val) && CHARSETP (val)) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
356 { |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
357 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
|
358 } |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
359 else if (CONSP (val)) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
360 { |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
361 if (! CHARSETP (XCAR (val))) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
362 goto invalid_entry; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
363 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
|
364 if (NILP (XCDR (val))) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
365 repertory_id = -1; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
366 else |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
367 { |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
368 if (! CHARSETP (XCDR (val))) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
369 goto invalid_entry; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
370 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
|
371 } |
|
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
372 } |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
373 else |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
374 goto invalid_entry; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
375 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
|
376 font_charset_alist |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
377 = 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
|
378 } |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
379 |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
380 if (encoding) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
381 *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
|
382 if (repertory) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
383 *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
|
384 return 0; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
385 |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
386 invalid_entry: |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
387 font_charset_alist |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
388 = 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
|
389 return -1; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
390 } |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
391 |
| 90400 | 392 |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
393 /* 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
|
394 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
|
395 |
| 94926 | 396 static Lisp_Object font_prop_validate P_ ((int, Lisp_Object, Lisp_Object)); |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
397 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
|
398 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
|
399 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
|
400 static Lisp_Object font_prop_validate_spacing P_ ((Lisp_Object, Lisp_Object)); |
| 94926 | 401 static int get_font_prop_index P_ ((Lisp_Object)); |
| 90400 | 402 |
| 403 static Lisp_Object | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
404 font_prop_validate_symbol (prop, val) |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
405 Lisp_Object prop, val; |
| 90400 | 406 { |
| 407 if (STRINGP (val)) | |
| 94926 | 408 val = Fintern (val, Qnil); |
| 409 if (! SYMBOLP (val)) | |
| 410 val = Qerror; | |
| 411 else if (EQ (prop, QCregistry)) | |
| 412 val = Fintern (Fdowncase (SYMBOL_NAME (val)), Qnil); | |
| 413 return val; | |
| 414 } | |
| 415 | |
| 416 | |
| 417 static Lisp_Object | |
| 418 font_prop_validate_style (style, val) | |
| 419 Lisp_Object style, val; | |
| 420 { | |
| 421 enum font_property_index prop = (EQ (style, QCweight) ? FONT_WEIGHT_INDEX | |
| 422 : EQ (style, QCslant) ? FONT_SLANT_INDEX | |
| 423 : FONT_WIDTH_INDEX); | |
| 424 int n; | |
| 425 if (INTEGERP (val)) | |
| 426 { | |
| 427 n = XINT (val); | |
| 428 if ((n & 0xFF) | |
| 429 >= ASIZE (AREF (font_style_table, prop - FONT_WEIGHT_INDEX))) | |
| 430 val = Qerror; | |
| 431 else | |
| 432 { | |
| 433 Lisp_Object elt = AREF (AREF (font_style_table, prop - FONT_WEIGHT_INDEX), n & 0xFF); | |
| 434 if (XINT (XCDR (elt)) != (n >> 8)) | |
| 435 val = Qerror; | |
| 436 } | |
| 437 } | |
| 90400 | 438 else if (SYMBOLP (val)) |
| 439 { | |
| 94926 | 440 int n = font_style_to_value (prop, val, 0); |
| 441 | |
| 442 val = n >= 0 ? make_number (n) : Qerror; | |
| 90400 | 443 } |
| 444 else | |
| 445 val = Qerror; | |
| 446 return val; | |
| 447 } | |
| 448 | |
| 449 static Lisp_Object | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
450 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
|
451 Lisp_Object prop, val; |
| 90400 | 452 { |
| 453 return (NATNUMP (val) || (FLOATP (val) && XFLOAT_DATA (val) >= 0) | |
| 454 ? val : Qerror); | |
| 455 } | |
| 456 | |
| 457 static Lisp_Object | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
458 font_prop_validate_spacing (prop, val) |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
459 Lisp_Object prop, val; |
| 90400 | 460 { |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
461 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
|
462 return val; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
463 if (EQ (val, Qc)) |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
464 return make_number (FONT_SPACING_CHARCELL); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
465 if (EQ (val, Qm)) |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
466 return make_number (FONT_SPACING_MONO); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
467 if (EQ (val, Qp)) |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
468 return make_number (FONT_SPACING_PROPORTIONAL); |
| 94926 | 469 if (EQ (val, Qd)) |
| 470 return make_number (FONT_SPACING_DUAL); | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
471 return Qerror; |
| 90400 | 472 } |
| 473 | |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
474 static Lisp_Object |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
475 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
|
476 Lisp_Object prop, val; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
477 { |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
478 Lisp_Object tail, tmp; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
479 int i; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
480 |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
481 /* 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
|
482 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
|
483 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
|
484 if (! CONSP (val)) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
485 return Qerror; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
486 if (! SYMBOLP (XCAR (val))) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
487 return Qerror; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
488 tail = XCDR (val); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
489 if (NILP (tail)) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
490 return val; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
491 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
|
492 return Qerror; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
493 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
|
494 { |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
495 tail = XCDR (tail); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
496 if (NILP (tail)) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
497 return val; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
498 if (! CONSP (tail)) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
499 return Qerror; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
500 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
|
501 if (! SYMBOLP (XCAR (tmp))) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
502 return Qerror; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
503 if (! NILP (tmp)) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
504 return Qerror; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
505 } |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
506 return val; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
507 } |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
508 |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
509 /* 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
|
510 values. */ |
| 90400 | 511 struct |
| 512 { | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
513 /* Pointer to the key symbol. */ |
| 90400 | 514 Lisp_Object *key; |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
515 /* 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
|
516 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
|
517 and Qerror if not. */ |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
518 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
|
519 } font_property_table[] = |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
520 { { &QCtype, font_prop_validate_symbol }, |
| 90400 | 521 { &QCfoundry, font_prop_validate_symbol }, |
| 522 { &QCfamily, font_prop_validate_symbol }, | |
| 523 { &QCadstyle, font_prop_validate_symbol }, | |
| 524 { &QCregistry, font_prop_validate_symbol }, | |
| 525 { &QCweight, font_prop_validate_style }, | |
| 526 { &QCslant, font_prop_validate_style }, | |
| 527 { &QCwidth, font_prop_validate_style }, | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
528 { &QCsize, font_prop_validate_non_neg }, |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
529 { &QCdpi, font_prop_validate_non_neg }, |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
530 { &QCspacing, font_prop_validate_spacing }, |
| 94926 | 531 { &QCavgwidth, font_prop_validate_non_neg }, |
| 532 /* The order of the above entries must match with enum | |
| 533 font_property_index. */ | |
| 534 { &QClang, font_prop_validate_symbol }, | |
| 535 { &QCscript, font_prop_validate_symbol }, | |
| 536 { &QCotf, font_prop_validate_otf } | |
| 90400 | 537 }; |
| 538 | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
539 /* 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
|
540 #define FONT_PROPERTY_TABLE_SIZE \ |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
541 ((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
|
542 |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
543 /* Return an index number of font property KEY or -1 if KEY is not an |
| 94926 | 544 already known property. */ |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
545 |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
546 static int |
| 94926 | 547 get_font_prop_index (key) |
| 90400 | 548 Lisp_Object key; |
| 549 { | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
550 int i; |
| 94926 | 551 |
| 552 for (i = 0; i < FONT_PROPERTY_TABLE_SIZE; i++) | |
| 553 if (EQ (key, *font_property_table[i].key)) | |
| 554 return i; | |
| 555 return -1; | |
| 556 } | |
| 557 | |
| 558 /* Validate the font property. The property key is specified by the | |
| 559 symbol PROP, or the index IDX (if PROP is nil). If VAL is invalid, | |
| 560 signal an error. The value is VAL or the regularized one. */ | |
| 561 | |
| 562 static Lisp_Object | |
| 563 font_prop_validate (idx, prop, val) | |
| 564 int idx; | |
| 565 Lisp_Object prop, val; | |
| 566 { | |
| 567 Lisp_Object validated; | |
| 568 | |
|
94964
5ffc88767cc1
(font_prop_validate): Make nil a valid value.
Kenichi Handa <handa@m17n.org>
parents:
94963
diff
changeset
|
569 if (NILP (val)) |
|
5ffc88767cc1
(font_prop_validate): Make nil a valid value.
Kenichi Handa <handa@m17n.org>
parents:
94963
diff
changeset
|
570 return val; |
| 94926 | 571 if (NILP (prop)) |
| 572 prop = *font_property_table[idx].key; | |
| 573 else | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
574 { |
| 94926 | 575 idx = get_font_prop_index (prop); |
| 576 if (idx < 0) | |
| 577 return val; | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
578 } |
| 94926 | 579 validated = (font_property_table[idx].validater) (prop, val); |
| 580 if (EQ (validated, Qerror)) | |
| 581 signal_error ("invalid font property", Fcons (prop, val)); | |
| 582 return validated; | |
| 90400 | 583 } |
|
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
584 |
| 94926 | 585 |
| 586 /* Store VAL as a value of extra font property PROP in FONT while | |
| 587 keeping the sorting order. Don't check the validity of VAL. */ | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
588 |
|
90888
5f03b3602143
(font_put_extra): Expose externally.
Jason Rumney <jasonr@gnu.org>
parents:
90883
diff
changeset
|
589 Lisp_Object |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
590 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
|
591 Lisp_Object font, prop, val; |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
592 { |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
593 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
|
594 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
|
595 |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
596 if (NILP (slot)) |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
597 { |
| 94926 | 598 Lisp_Object prev = Qnil; |
| 599 | |
| 600 while (CONSP (extra) | |
| 601 && NILP (Fstring_lessp (prop, XCAR (XCAR (extra))))) | |
| 602 prev = extra, extra = XCDR (extra); | |
| 603 if (NILP (prev)) | |
| 604 ASET (font, FONT_EXTRA_INDEX, Fcons (Fcons (prop, val), extra)); | |
| 605 else | |
| 606 XSETCDR (prev, Fcons (Fcons (prop, val), extra)); | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
607 return val; |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
608 } |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
609 XSETCDR (slot, val); |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
610 return val; |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
611 } |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
612 |
| 90400 | 613 |
| 614 /* Font name parser and unparser */ | |
| 615 | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
616 static int parse_matrix P_ ((char *)); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
617 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
|
618 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
|
619 |
| 90400 | 620 /* An enumerator for each field of an XLFD font name. */ |
| 621 enum xlfd_field_index | |
| 622 { | |
| 623 XLFD_FOUNDRY_INDEX, | |
| 624 XLFD_FAMILY_INDEX, | |
| 625 XLFD_WEIGHT_INDEX, | |
| 626 XLFD_SLANT_INDEX, | |
| 627 XLFD_SWIDTH_INDEX, | |
| 628 XLFD_ADSTYLE_INDEX, | |
|
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
629 XLFD_PIXEL_INDEX, |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
630 XLFD_POINT_INDEX, |
| 90400 | 631 XLFD_RESX_INDEX, |
| 632 XLFD_RESY_INDEX, | |
| 633 XLFD_SPACING_INDEX, | |
| 634 XLFD_AVGWIDTH_INDEX, | |
| 635 XLFD_REGISTRY_INDEX, | |
| 636 XLFD_ENCODING_INDEX, | |
| 637 XLFD_LAST_INDEX | |
| 638 }; | |
| 639 | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
640 /* 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
|
641 enum xlfd_field_mask |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
642 { |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
643 XLFD_FOUNDRY_MASK = 0x0001, |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
644 XLFD_FAMILY_MASK = 0x0002, |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
645 XLFD_WEIGHT_MASK = 0x0004, |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
646 XLFD_SLANT_MASK = 0x0008, |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
647 XLFD_SWIDTH_MASK = 0x0010, |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
648 XLFD_ADSTYLE_MASK = 0x0020, |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
649 XLFD_PIXEL_MASK = 0x0040, |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
650 XLFD_POINT_MASK = 0x0080, |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
651 XLFD_RESX_MASK = 0x0100, |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
652 XLFD_RESY_MASK = 0x0200, |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
653 XLFD_SPACING_MASK = 0x0400, |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
654 XLFD_AVGWIDTH_MASK = 0x0800, |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
655 XLFD_REGISTRY_MASK = 0x1000, |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
656 XLFD_ENCODING_MASK = 0x2000 |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
657 }; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
658 |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
659 |
| 90400 | 660 /* Parse P pointing the pixel/point size field of the form |
| 661 `[A B C D]' which specifies a transformation matrix: | |
| 662 | |
| 663 A B 0 | |
| 664 C D 0 | |
| 665 0 0 1 | |
| 666 | |
| 667 by which all glyphs of the font are transformed. The spec says | |
| 668 that scalar value N for the pixel/point size is equivalent to: | |
| 669 A = N * resx/resy, B = C = 0, D = N. | |
| 670 | |
| 671 Return the scalar value N if the form is valid. Otherwise return | |
| 672 -1. */ | |
| 673 | |
| 674 static int | |
| 675 parse_matrix (p) | |
| 676 char *p; | |
| 677 { | |
| 678 double matrix[4]; | |
| 679 char *end; | |
| 680 int i; | |
| 681 | |
| 682 for (i = 0, p++; i < 4 && *p && *p != ']'; i++) | |
| 683 { | |
| 684 if (*p == '~') | |
| 685 matrix[i] = - strtod (p + 1, &end); | |
| 686 else | |
| 687 matrix[i] = strtod (p, &end); | |
| 688 p = end; | |
| 689 } | |
| 690 return (i == 4 ? (int) matrix[3] : -1); | |
| 691 } | |
| 692 | |
|
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
693 /* 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
|
694 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
|
695 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
|
696 |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
697 static int |
|
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
698 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
|
699 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
|
700 int n; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
701 { |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
702 /* Copy of FIELD. */ |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
703 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
|
704 /* 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
|
705 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
|
706 struct { |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
707 /* Minimum possible field. */ |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
708 int from; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
709 /* Maxinum possible field. */ |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
710 int to; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
711 /* 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
|
712 int mask; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
713 } range[XLFD_LAST_INDEX]; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
714 int i, j; |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
715 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
|
716 unsigned range_mask; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
717 |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
718 #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
|
719 | 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
|
720 #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
|
721 #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
|
722 | XLFD_AVGWIDTH_MASK) |
|
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
723 #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
|
724 |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
725 /* 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
|
726 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
|
727 following loop. */ |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
728 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
|
729 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
|
730 |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
731 /* 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
|
732 position-based retriction for FIELD[I]. */ |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
733 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
|
734 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
|
735 { |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
736 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
|
737 |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
738 tmp[i] = val; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
739 if (NILP (val)) |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
740 { |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
741 /* Wildcard. */ |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
742 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
|
743 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
|
744 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
|
745 } |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
746 else |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
747 { |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
748 /* 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
|
749 retriction for FIELD[I]. */ |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
750 int from, to; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
751 unsigned mask; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
752 |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
753 if (INTEGERP (val)) |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
754 { |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
755 int numeric = XINT (val); |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
756 |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
757 if (i + 1 == n) |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
758 from = to = XLFD_ENCODING_INDEX, |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
759 mask = XLFD_ENCODING_MASK; |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
760 else if (numeric == 0) |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
761 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
|
762 mask = XLFD_PIXEL_MASK | XLFD_LARGENUM_MASK; |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
763 else if (numeric <= 48) |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
764 from = to = XLFD_PIXEL_INDEX, |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
765 mask = XLFD_PIXEL_MASK; |
|
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
766 else |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
767 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
|
768 mask = XLFD_LARGENUM_MASK; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
769 } |
| 94926 | 770 else if (SBYTES (SYMBOL_NAME (val)) == 0) |
|
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
771 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
|
772 mask = XLFD_NULL_MASK; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
773 else if (i == 0) |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
774 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
|
775 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
|
776 { |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
777 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
|
778 |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
779 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
|
780 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
|
781 mask = XLFD_REGENC_MASK; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
782 else |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
783 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
|
784 mask = XLFD_ENCODING_MASK; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
785 } |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
786 else if (range_from <= XLFD_WEIGHT_INDEX |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
787 && range_to >= XLFD_WEIGHT_INDEX |
| 94926 | 788 && FONT_WEIGHT_NAME_NUMERIC (val) >= 0) |
|
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
789 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
|
790 else if (range_from <= XLFD_SLANT_INDEX |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
791 && range_to >= XLFD_SLANT_INDEX |
| 94926 | 792 && FONT_SLANT_NAME_NUMERIC (val) >= 0) |
|
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
793 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
|
794 else if (range_from <= XLFD_SWIDTH_INDEX |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
795 && range_to >= XLFD_SWIDTH_INDEX |
| 94926 | 796 && FONT_WIDTH_NAME_NUMERIC (val) >= 0) |
|
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
797 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
|
798 else |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
799 { |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
800 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
|
801 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
|
802 else |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
803 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
|
804 mask = XLFD_SYMBOL_MASK; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
805 } |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
806 |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
807 /* 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
|
808 mask &= range_mask; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
809 while (from < range_from) |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
810 mask &= ~(1 << from++); |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
811 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
|
812 from++; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
813 while (to > range_to) |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
814 mask &= ~(1 << to--); |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
815 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
|
816 to--; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
817 if (from > to) |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
818 return -1; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
819 range[i].from = from; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
820 range[i].to = to; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
821 range[i].mask = mask; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
822 |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
823 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
|
824 { |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
825 /* 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
|
826 Reflect it to the other fields. */ |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
827 |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
828 /* Following fields should be after FROM. */ |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
829 range_from = from; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
830 /* Preceding fields should be before TO. */ |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
831 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
|
832 { |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
833 /* Check FROM for non-wildcard field. */ |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
834 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
|
835 { |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
836 while (range[j].from < from) |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
837 range[j].mask &= ~(1 << range[j].from++); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
838 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
|
839 from++; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
840 range[j].from = from; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
841 } |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
842 else |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
843 from = range[j].from; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
844 if (range[j].to > to) |
|
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 while (range[j].to > to) |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
847 range[j].mask &= ~(1 << range[j].to--); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
848 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
|
849 to--; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
850 range[j].to = to; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
851 } |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
852 else |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
853 to = range[j].to; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
854 if (from > to) |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
855 return -1; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
856 } |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
857 } |
|
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
858 } |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
859 } |
|
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 /* 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
|
862 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
|
863 { |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
864 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
|
865 { |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
866 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
|
867 /* 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
|
868 return -1; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
869 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
|
870 field[j] = Qnil; |
|
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 field[j++] = tmp[i]; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
873 } |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
874 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
|
875 return -1; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
876 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
|
877 field[j] = Qnil; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
878 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
|
879 field[XLFD_ENCODING_INDEX] |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
880 = 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
|
881 return 0; |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
882 } |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
883 |
|
92113
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
884 |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
885 #ifdef ENABLE_CHECKING |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
886 /* 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
|
887 static int |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
888 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
|
889 { |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
890 while (*pattern && *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 if (*pattern == *name) |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
893 pattern++; |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
894 else if (*pattern == '*') |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
895 if (*name == pattern[1]) |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
896 pattern += 2; |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
897 else |
|
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 else |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
900 return 0; |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
901 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 return 1; |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
904 } |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
905 |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
906 /* 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
|
907 static int |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
908 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
|
909 { |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
910 char name_check[256]; |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
911 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
|
912 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
|
913 } |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
914 |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
915 #endif |
|
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
916 |
| 94926 | 917 |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
918 /* 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
|
919 (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
|
920 follows: |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
921 specified XLFD fields FONT property |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
922 --------------------- ------------- |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
923 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
|
924 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
|
925 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
|
926 |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
927 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
|
928 |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
929 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
|
930 X font backend driver, it is a font-entity. In that case, NAME is |
| 94926 | 931 a fully specified XLFD. */ |
| 90400 | 932 |
| 933 int | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
934 font_parse_xlfd (name, font) |
| 90400 | 935 char *name; |
| 936 Lisp_Object font; | |
| 937 { | |
| 938 int len = strlen (name); | |
| 94926 | 939 int i, j, n; |
|
90695
a1cd7344d6a2
(font_parse_xlfd): Fix the array size of `f'.
Kenichi Handa <handa@m17n.org>
parents:
90677
diff
changeset
|
940 char *f[XLFD_LAST_INDEX + 1]; |
| 90400 | 941 Lisp_Object val; |
|
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
942 char *p; |
| 90400 | 943 |
| 944 if (len > 255) | |
| 945 /* Maximum XLFD name length is 255. */ | |
| 946 return -1; | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
947 /* Accept "*-.." as a fully specified XLFD. */ |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
948 if (name[0] == '*' && name[1] == '-') |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
949 i = 1, f[XLFD_FOUNDRY_INDEX] = name; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
950 else |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
951 i = 0; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
952 for (p = name + i; *p; p++) |
| 94926 | 953 if (*p == '-') |
| 954 { | |
| 955 f[i++] = p + 1; | |
| 956 if (i == XLFD_LAST_INDEX) | |
| 957 break; | |
| 958 } | |
| 959 f[i] = name + len; | |
| 960 | |
| 961 #define INTERN_FIELD(N) font_intern_prop (f[N], f[(N) + 1] - 1 - f[N]) | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
962 |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
963 if (i == XLFD_LAST_INDEX) |
| 90400 | 964 { |
| 94926 | 965 /* Fully specified XLFD. */ |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
966 int pixel_size; |
| 94926 | 967 int spacing_char; |
| 968 | |
| 969 ASET (font, FONT_FOUNDRY_INDEX, INTERN_FIELD (XLFD_FOUNDRY_INDEX)); | |
| 970 ASET (font, FONT_FAMILY_INDEX, INTERN_FIELD (XLFD_FAMILY_INDEX)); | |
| 971 for (i = XLFD_WEIGHT_INDEX, j = FONT_WEIGHT_INDEX; | |
| 972 i <= XLFD_SWIDTH_INDEX; i++, j++) | |
| 90400 | 973 { |
| 94926 | 974 val = INTERN_FIELD (i); |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
975 if (! NILP (val)) |
|
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
976 { |
| 94926 | 977 if ((n = font_style_to_value (j, INTERN_FIELD (i), 0)) < 0) |
| 978 return -1; | |
| 979 ASET (font, j, make_number (n)); | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
980 } |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
981 } |
| 94926 | 982 ASET (font, FONT_ADSTYLE_INDEX, INTERN_FIELD (XLFD_ADSTYLE_INDEX)); |
| 983 if (strcmp (f[XLFD_REGISTRY_INDEX], "*-*") == 0) | |
| 984 ASET (font, FONT_REGISTRY_INDEX, Qnil); | |
| 985 else | |
| 986 ASET (font, FONT_REGISTRY_INDEX, | |
| 987 font_intern_prop (f[XLFD_REGISTRY_INDEX], | |
| 988 f[XLFD_LAST_INDEX] - f[XLFD_REGISTRY_INDEX])); | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
989 p = f[XLFD_PIXEL_INDEX]; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
990 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
|
991 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
|
992 else |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
993 { |
| 94926 | 994 val = INTERN_FIELD (XLFD_PIXEL_INDEX); |
| 995 if (INTEGERP (val)) | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
996 ASET (font, FONT_SIZE_INDEX, val); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
997 else |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
998 { |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
999 double point_size = -1; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1000 |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1001 xassert (FONT_SPEC_P (font)); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1002 p = f[XLFD_POINT_INDEX]; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1003 if (*p == '[') |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1004 point_size = parse_matrix (p); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1005 else if (isdigit (*p)) |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1006 point_size = atoi (p), point_size /= 10; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1007 if (point_size >= 0) |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1008 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
|
1009 } |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1010 } |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1011 |
| 94926 | 1012 ASET (font, FONT_DPI_INDEX, INTERN_FIELD (XLFD_RESY_INDEX)); |
| 1013 val = INTERN_FIELD (XLFD_SPACING_INDEX); | |
| 1014 if (! NILP (val)) | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1015 { |
| 94926 | 1016 val = font_prop_validate_spacing (QCspacing, val); |
| 1017 if (! INTEGERP (val)) | |
| 1018 return -1; | |
| 1019 ASET (font, FONT_SPACING_INDEX, val); | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1020 } |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1021 p = f[XLFD_AVGWIDTH_INDEX]; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1022 if (*p == '~') |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1023 p++; |
| 94926 | 1024 ASET (font, FONT_AVGWIDTH_INDEX, |
| 1025 font_intern_prop (p, f[XLFD_REGISTRY_INDEX] - 1 - p)); | |
|
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1026 } |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1027 else |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1028 { |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1029 int wild_card_found = 0; |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1030 Lisp_Object prop[XLFD_LAST_INDEX]; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1031 |
| 94926 | 1032 if (FONT_ENTITY_P (font)) |
| 1033 return -1; | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1034 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
|
1035 { |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1036 if (*f[j] == '*') |
|
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1037 { |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1038 if (f[j][1] && f[j][1] != '-') |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1039 return -1; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1040 prop[j] = Qnil; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1041 wild_card_found = 1; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1042 } |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1043 else if (j + 1 < i) |
| 94926 | 1044 prop[j] = INTERN_FIELD (j); |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1045 else |
| 94926 | 1046 prop[j] = font_intern_prop (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
|
1047 } |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1048 if (! wild_card_found) |
|
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1049 return -1; |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1050 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
|
1051 return -1; |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1052 |
| 94926 | 1053 ASET (font, FONT_FOUNDRY_INDEX, prop[XLFD_FOUNDRY_INDEX]); |
| 1054 ASET (font, FONT_FAMILY_INDEX, prop[XLFD_FAMILY_INDEX]); | |
| 1055 for (i = XLFD_WEIGHT_INDEX, j = FONT_WEIGHT_INDEX; | |
| 1056 i <= XLFD_SWIDTH_INDEX; i++, j++) | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1057 if (! NILP (prop[i])) |
| 94926 | 1058 { |
| 1059 if ((n = font_style_to_value (j, prop[i], 1)) < 0) | |
| 1060 return -1; | |
| 1061 ASET (font, j, make_number (n)); | |
| 1062 } | |
| 1063 ASET (font, FONT_ADSTYLE_INDEX, prop[XLFD_ADSTYLE_INDEX]); | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1064 val = prop[XLFD_REGISTRY_INDEX]; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1065 if (NILP (val)) |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1066 { |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1067 val = prop[XLFD_ENCODING_INDEX]; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1068 if (! NILP (val)) |
| 94926 | 1069 val = concat2 (build_string ("*-"), SYMBOL_NAME (val)); |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1070 } |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1071 else if (NILP (prop[XLFD_ENCODING_INDEX])) |
| 94926 | 1072 val = concat2 (SYMBOL_NAME (val), build_string ("-*")); |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1073 else |
| 94926 | 1074 val = concat3 (SYMBOL_NAME (val), build_string ("-"), |
| 1075 SYMBOL_NAME (prop[XLFD_ENCODING_INDEX])); | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1076 if (! NILP (val)) |
| 94926 | 1077 ASET (font, FONT_REGISTRY_INDEX, Fintern (val, Qnil)); |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1078 |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1079 if (INTEGERP (prop[XLFD_PIXEL_INDEX])) |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1080 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
|
1081 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
|
1082 { |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1083 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
|
1084 |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1085 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
|
1086 } |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1087 |
| 94926 | 1088 if (INTEGERP (prop[XLFD_RESX_INDEX])) |
| 1089 ASET (font, FONT_DPI_INDEX, prop[XLFD_RESY_INDEX]); | |
| 1090 if (! NILP (prop[XLFD_SPACING_INDEX])) | |
| 1091 { | |
| 1092 val = font_prop_validate_spacing (QCspacing, | |
| 1093 prop[XLFD_SPACING_INDEX]); | |
| 1094 if (! INTEGERP (val)) | |
| 1095 return -1; | |
| 1096 ASET (font, FONT_SPACING_INDEX, val); | |
| 1097 } | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1098 if (INTEGERP (prop[XLFD_AVGWIDTH_INDEX])) |
| 94926 | 1099 ASET (font, FONT_AVGWIDTH_INDEX, 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
|
1100 } |
| 90400 | 1101 |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1102 return 0; |
| 90400 | 1103 } |
| 1104 | |
| 1105 /* Store XLFD name of FONT (font-spec or font-entity) in NAME (NBYTES | |
| 1106 length), and return the name length. If FONT_SIZE_INDEX of FONT is | |
| 1107 0, use PIXEL_SIZE instead. */ | |
| 1108 | |
| 1109 int | |
| 1110 font_unparse_xlfd (font, pixel_size, name, nbytes) | |
| 1111 Lisp_Object font; | |
|
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1112 int pixel_size; |
| 90400 | 1113 char *name; |
| 1114 int nbytes; | |
| 1115 { | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1116 char *f[XLFD_REGISTRY_INDEX + 1]; |
| 90400 | 1117 Lisp_Object val; |
| 1118 int i, j, len = 0; | |
| 1119 | |
| 1120 xassert (FONTP (font)); | |
| 1121 | |
| 1122 for (i = FONT_FOUNDRY_INDEX, j = XLFD_FOUNDRY_INDEX; i <= FONT_REGISTRY_INDEX; | |
| 1123 i++, j++) | |
| 1124 { | |
| 1125 if (i == FONT_ADSTYLE_INDEX) | |
| 1126 j = XLFD_ADSTYLE_INDEX; | |
| 1127 else if (i == FONT_REGISTRY_INDEX) | |
| 1128 j = XLFD_REGISTRY_INDEX; | |
| 1129 val = AREF (font, i); | |
| 1130 if (NILP (val)) | |
|
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1131 { |
|
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1132 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
|
1133 f[j] = "*-*", len += 4; |
|
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1134 else |
|
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1135 f[j] = "*", len += 2; |
|
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1136 } |
| 90400 | 1137 else |
| 1138 { | |
| 1139 if (SYMBOLP (val)) | |
| 1140 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
|
1141 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
|
1142 && ! strchr ((char *) SDATA (val), '-')) |
|
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1143 { |
|
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1144 /* 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
|
1145 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
|
1146 { |
|
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1147 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
|
1148 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
|
1149 len += SBYTES (val) + 3; |
|
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1150 } |
|
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1151 else |
|
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1152 { |
|
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1153 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
|
1154 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
|
1155 len += SBYTES (val) + 4; |
|
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1156 } |
|
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 else |
|
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1159 f[j] = (char *) SDATA (val), len += SBYTES (val) + 1; |
| 90400 | 1160 } |
| 1161 } | |
| 1162 | |
| 1163 for (i = FONT_WEIGHT_INDEX, j = XLFD_WEIGHT_INDEX; i <= FONT_WIDTH_INDEX; | |
| 1164 i++, j++) | |
| 1165 { | |
| 94926 | 1166 val = font_style_symbolic (font, i, 0); |
| 90400 | 1167 if (NILP (val)) |
| 1168 f[j] = "*", len += 2; | |
| 1169 else | |
| 1170 { | |
| 94926 | 1171 val = SYMBOL_NAME (val); |
| 90400 | 1172 f[j] = (char *) SDATA (val), len += SBYTES (val) + 1; |
| 1173 } | |
| 1174 } | |
| 1175 | |
| 1176 val = AREF (font, FONT_SIZE_INDEX); | |
| 1177 xassert (NUMBERP (val) || NILP (val)); | |
| 1178 if (INTEGERP (val)) | |
| 1179 { | |
| 94926 | 1180 i = XINT (val); |
|
91943
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1181 if (i <= 0) |
|
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1182 i = pixel_size; |
| 90400 | 1183 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
|
1184 { |
|
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1185 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
|
1186 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
|
1187 } |
|
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1188 else |
|
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1189 f[XLFD_PIXEL_INDEX] = "*-*", len += 4; |
| 90400 | 1190 } |
| 1191 else if (FLOATP (val)) | |
| 1192 { | |
| 94926 | 1193 i = XFLOAT_DATA (val) * 10; |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1194 f[XLFD_PIXEL_INDEX] = alloca (12); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1195 len += sprintf (f[XLFD_PIXEL_INDEX], "*-%d", i) + 1; |
| 90400 | 1196 } |
| 1197 else | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1198 f[XLFD_PIXEL_INDEX] = "*-*", len += 4; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1199 |
| 94926 | 1200 if (INTEGERP (AREF (font, FONT_DPI_INDEX))) |
| 90400 | 1201 { |
| 94926 | 1202 i = XINT (AREF (font, FONT_DPI_INDEX)); |
| 1203 f[XLFD_RESX_INDEX] = alloca (22); | |
| 1204 len += sprintf (f[XLFD_RESX_INDEX], | |
| 1205 "%d-%d", i, i) + 1; | |
| 90400 | 1206 } |
| 1207 else | |
| 94926 | 1208 f[XLFD_RESX_INDEX] = "*-*", len += 4; |
| 1209 if (INTEGERP (AREF (font, FONT_SPACING_INDEX))) | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1210 { |
| 94926 | 1211 int spacing = XINT (AREF (font, FONT_SPACING_INDEX)); |
| 1212 | |
| 1213 f[XLFD_SPACING_INDEX] = (spacing <= FONT_SPACING_PROPORTIONAL ? "p" | |
| 1214 : spacing <= FONT_SPACING_DUAL ? "d" | |
| 1215 : spacing <= FONT_SPACING_MONO ? "m" | |
| 1216 : "c"); | |
| 1217 len += 2; | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1218 } |
| 94926 | 1219 else |
| 1220 f[XLFD_SPACING_INDEX] = "*", len += 2; | |
| 1221 if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX))) | |
| 1222 { | |
| 1223 f[XLFD_AVGWIDTH_INDEX] = alloca (11); | |
| 1224 len += sprintf (f[XLFD_AVGWIDTH_INDEX], | |
| 1225 "%d", XINT (AREF (font, FONT_AVGWIDTH_INDEX))) + 1; | |
| 1226 } | |
| 1227 else | |
| 1228 f[XLFD_AVGWIDTH_INDEX] = "*", len += 2; | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1229 len++; /* for terminating '\0'. */ |
| 90400 | 1230 if (len >= nbytes) |
| 1231 return -1; | |
| 94926 | 1232 return sprintf (name, "-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s", |
| 90400 | 1233 f[XLFD_FOUNDRY_INDEX], f[XLFD_FAMILY_INDEX], |
| 1234 f[XLFD_WEIGHT_INDEX], f[XLFD_SLANT_INDEX], | |
| 94926 | 1235 f[XLFD_SWIDTH_INDEX], f[XLFD_ADSTYLE_INDEX], |
| 1236 f[XLFD_PIXEL_INDEX], f[XLFD_RESX_INDEX], | |
| 1237 f[XLFD_SPACING_INDEX], f[XLFD_AVGWIDTH_INDEX], | |
| 1238 f[XLFD_REGISTRY_INDEX]); | |
| 90400 | 1239 } |
| 1240 | |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1241 /* 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
|
1242 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
|
1243 successfully parsed, return 0. Otherwise return -1. */ |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1244 |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1245 int |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1246 font_parse_fcname (name, font) |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1247 char *name; |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1248 Lisp_Object font; |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1249 { |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1250 char *p0, *p1; |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1251 int len = strlen (name); |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1252 char *copy; |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1253 |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1254 if (len == 0) |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1255 return -1; |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1256 /* It is assured that (name[0] && name[0] != '-'). */ |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1257 if (name[0] == ':') |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1258 p0 = name; |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1259 else |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1260 { |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1261 Lisp_Object family; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1262 double point_size; |
|
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 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
|
1265 if (*p0 == '\\' && p0[1]) |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1266 p0++; |
| 94926 | 1267 family = font_intern_prop (name, p0 - name); |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1268 if (*p0 == '-') |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1269 { |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1270 if (! isdigit (p0[1])) |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1271 return -1; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1272 point_size = strtod (p0 + 1, &p1); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1273 if (*p1 && *p1 != ':') |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1274 return -1; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1275 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
|
1276 p0 = p1; |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1277 } |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1278 ASET (font, FONT_FAMILY_INDEX, family); |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1279 } |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1280 |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1281 len -= p0 - name; |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1282 copy = alloca (len + 1); |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1283 if (! copy) |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1284 return -1; |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1285 name = copy; |
|
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
1286 |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1287 /* Now parse ":KEY=VAL" patterns. Store known keys and values in |
| 94926 | 1288 extra, copy unknown ones to COPY. It is stored in extra slot by |
| 1289 the key QCfc_unknown_spec. */ | |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1290 while (*p0) |
|
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 Lisp_Object key, val; |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1293 int prop; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1294 |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1295 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
|
1296 if (*p1 != '=') |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1297 { |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1298 /* Must be an enumerated value. */ |
| 94926 | 1299 val = font_intern_prop (p0 + 1, p1 - p0 - 1); |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1300 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
|
1301 || 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
|
1302 || 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
|
1303 || 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
|
1304 || memcmp (p0 + 1, "black", 5) == 0) |
| 94926 | 1305 FONT_SET_STYLE (font, FONT_WEIGHT_INDEX, val); |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1306 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
|
1307 || 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
|
1308 || memcmp (p0 + 1, "oblique", 7) == 0) |
| 94926 | 1309 FONT_SET_STYLE (font, FONT_SLANT_INDEX, val); |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1310 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
|
1311 || 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
|
1312 || 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
|
1313 { |
| 94926 | 1314 int spacing = (p0[1] == 'c' ? FONT_SPACING_CHARCELL |
| 1315 : p0[1] == 'm' ? FONT_SPACING_MONO | |
| 1316 : FONT_SPACING_PROPORTIONAL); | |
| 1317 ASET (font, FONT_SPACING_INDEX, make_number (spacing)); | |
| 1318 } | |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1319 else |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1320 { |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1321 /* unknown key */ |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1322 bcopy (p0, copy, p1 - p0); |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1323 copy += p1 - p0; |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1324 } |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1325 } |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1326 else |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1327 { |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1328 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
|
1329 prop = FONT_SIZE_INDEX; |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1330 else |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1331 { |
| 94926 | 1332 key = font_intern_prop (p0, p1 - p0); |
| 1333 prop = get_font_prop_index (key); | |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1334 } |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1335 p0 = p1 + 1; |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1336 for (p1 = p0; *p1 && *p1 != ':'; p1++); |
| 94926 | 1337 val = font_intern_prop (p0, p1 - p0); |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1338 if (! NILP (val)) |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1339 { |
| 94926 | 1340 if (prop >= FONT_FOUNDRY_INDEX && prop < FONT_EXTRA_INDEX) |
| 1341 ASET (font, prop, font_prop_validate (prop, Qnil, val)); | |
| 1342 else if (prop >= 0) | |
| 1343 Ffont_put (font, key, val); | |
|
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1344 else |
| 94926 | 1345 bcopy (p0 - 1, copy, p1 - p0 + 1); |
| 1346 copy += p1 - p0 + 1; | |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1347 } |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1348 } |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1349 p0 = p1; |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1350 } |
| 94926 | 1351 if (name != copy) |
| 1352 font_put_extra (font, QCfc_unknown_spec, | |
| 1353 make_unibyte_string (name, copy - name)); | |
|
91261
2e5bb6a0a787
(font_parse_fcname): Default weight and slant to normal.
Jason Rumney <jasonr@gnu.org>
parents:
91247
diff
changeset
|
1354 |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1355 return 0; |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1356 } |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1357 |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1358 /* 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
|
1359 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
|
1360 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
|
1361 |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1362 int |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1363 font_unparse_fcname (font, pixel_size, name, nbytes) |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1364 Lisp_Object font; |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1365 int pixel_size; |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1366 char *name; |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1367 int nbytes; |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1368 { |
| 94926 | 1369 Lisp_Object tail, val; |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1370 int point_size; |
| 94926 | 1371 int dpi, spacing, avgwidth; |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1372 int i, len = 1; |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1373 char *p; |
|
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1374 Lisp_Object styles[3]; |
|
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
1375 char *style_names[3] = { "weight", "slant", "width" }; |
| 94926 | 1376 char work[256]; |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1377 |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1378 val = AREF (font, FONT_FAMILY_INDEX); |
| 94926 | 1379 if (STRINGP (val)) |
| 1380 len += SBYTES (val); | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1381 |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1382 val = AREF (font, FONT_SIZE_INDEX); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1383 if (INTEGERP (val)) |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1384 { |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1385 if (XINT (val) != 0) |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1386 pixel_size = XINT (val); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1387 point_size = -1; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1388 len += 21; /* for ":pixelsize=NUM" */ |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1389 } |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1390 else if (FLOATP (val)) |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1391 { |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1392 pixel_size = -1; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1393 point_size = (int) XFLOAT_DATA (val); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1394 len += 11; /* for "-NUM" */ |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1395 } |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1396 |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1397 val = AREF (font, FONT_FOUNDRY_INDEX); |
| 94926 | 1398 if (STRINGP (val)) |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1399 /* ":foundry=NAME" */ |
| 94926 | 1400 len += 9 + SBYTES (val); |
| 1401 | |
| 1402 for (i = 0; i < 3; i++) | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1403 { |
| 94926 | 1404 int this_len; |
| 1405 | |
| 1406 styles[i] = font_style_symbolic (font, FONT_WEIGHT_INDEX + i, 0); | |
| 1407 if (! NILP (styles[i])) | |
| 1408 len += sprintf (work, ":%s=%s", style_names[i], | |
| 1409 SDATA (SYMBOL_NAME (styles[i]))); | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1410 } |
| 94926 | 1411 |
| 1412 if (INTEGERP (AREF (font, FONT_DPI_INDEX))) | |
| 1413 len += sprintf (work, ":dpi=%d", dpi); | |
| 1414 if (INTEGERP (AREF (font, FONT_SPACING_INDEX))) | |
| 1415 len += strlen (":spacing=100"); | |
| 1416 if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX))) | |
| 1417 len += strlen (":scalable=false"); /* or ":scalable=true" */ | |
| 1418 for (tail = AREF (font, FONT_EXTRA_INDEX); CONSP (tail); tail = XCDR (tail)) | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1419 { |
| 94926 | 1420 Lisp_Object key = XCAR (XCAR (tail)), val = XCDR (XCAR (tail)); |
| 1421 | |
| 1422 len += SBYTES (SYMBOL_NAME (key)) + 1; /* for :KEY= */ | |
| 1423 if (STRINGP (val)) | |
| 1424 len += SBYTES (val); | |
| 1425 else if (INTEGERP (val)) | |
| 1426 len += sprintf (work, "%d", XINT (val)); | |
| 1427 else if (SYMBOLP (val)) | |
| 1428 len += (NILP (val) ? 5 : 4); /* for "false" or "true" */ | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1429 } |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1430 |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1431 if (len > nbytes) |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1432 return -1; |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1433 p = name; |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1434 if (! NILP (AREF (font, FONT_FAMILY_INDEX))) |
| 94926 | 1435 p += sprintf(p, "%s", 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
|
1436 if (point_size > 0) |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1437 { |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1438 if (p == name) |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1439 p += sprintf (p, "%d", point_size); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1440 else |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1441 p += sprintf (p, "-%d", point_size); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1442 } |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1443 else if (pixel_size > 0) |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1444 p += sprintf (p, ":pixelsize=%d", pixel_size); |
| 94926 | 1445 if (! NILP (AREF (font, FONT_FOUNDRY_INDEX))) |
|
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1446 p += sprintf (p, ":foundry=%s", |
|
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1447 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
|
1448 for (i = 0; i < 3; i++) |
| 94926 | 1449 if (! NILP (styles[i])) |
|
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1450 p += sprintf (p, ":%s=%s", style_names[i], |
| 94926 | 1451 SDATA (SYMBOL_NAME (styles[i]))); |
| 1452 if (INTEGERP (AREF (font, FONT_DPI_INDEX))) | |
| 1453 p += sprintf (p, ":dpi=%d", XINT (AREF (font, FONT_DPI_INDEX))); | |
| 1454 if (INTEGERP (AREF (font, FONT_SPACING_INDEX))) | |
| 1455 p += sprintf (p, ":spacing=%d", XINT (AREF (font, FONT_SPACING_INDEX))); | |
| 1456 if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX))) | |
| 1457 { | |
| 1458 if (XINT (AREF (font, FONT_AVGWIDTH_INDEX)) == 0) | |
| 1459 p += sprintf (p, ":scalable=true"); | |
| 1460 else | |
| 1461 p += sprintf (p, ":scalable=false"); | |
| 1462 } | |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1463 return (p - name); |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1464 } |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1465 |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1466 /* 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
|
1467 (font-spec or font-entity). If NAME is successfully parsed, return |
| 94926 | 1468 0. Otherwise return -1. */ |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1469 |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1470 static int |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1471 font_parse_name (name, font) |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1472 char *name; |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1473 Lisp_Object font; |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1474 { |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1475 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
|
1476 return font_parse_xlfd (name, font); |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1477 return font_parse_fcname (name, font); |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1478 } |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1479 |
| 94926 | 1480 |
| 1481 /* Merge FAMILY and REGISTRY into FONT_SPEC. FAMILY may have the form | |
| 1482 "FAMILY-FOUNDRY". REGISTRY may not contain charset-encoding | |
| 1483 part. */ | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
1484 |
| 90400 | 1485 void |
| 94926 | 1486 font_parse_family_registry (family, registry, font_spec) |
| 1487 Lisp_Object family, registry, font_spec; | |
| 90400 | 1488 { |
| 94926 | 1489 int len; |
| 1490 char *p0, *p1; | |
| 1491 | |
| 1492 if (! NILP (family)) | |
| 90400 | 1493 { |
| 94926 | 1494 CHECK_STRING (family); |
| 1495 len = SBYTES (family); | |
| 1496 p0 = (char *) SDATA (family); | |
| 1497 p1 = index (p0, '-'); | |
| 1498 if (p1) | |
| 90400 | 1499 { |
| 94926 | 1500 if (*p0 != '*' || p1 - p0 > 1) |
| 1501 ASET (font_spec, FONT_FOUNDRY_INDEX, | |
| 1502 font_intern_prop (p0, p1 - p0)); | |
| 1503 p1++; | |
| 1504 len -= p1 - p0; | |
| 1505 ASET (font_spec, FONT_FAMILY_INDEX, font_intern_prop (p1, len)); | |
| 90400 | 1506 } |
| 94926 | 1507 else |
| 1508 ASET (font_spec, FONT_FAMILY_INDEX, Fintern (family, Qnil)); | |
| 1509 } | |
| 1510 if (! NILP (registry)) | |
| 1511 { | |
| 1512 /* Convert "XXX" and "XXX*" to "XXX*-*". */ | |
| 1513 CHECK_STRING (registry); | |
| 1514 len = SBYTES (registry); | |
| 1515 p0 = (char *) SDATA (registry); | |
| 1516 p1 = index (p0, '-'); | |
| 1517 if (! p1) | |
| 1518 { | |
| 1519 if (SDATA (registry)[len - 1] == '*') | |
| 1520 registry = concat2 (registry, build_string ("-*")); | |
| 1521 else | |
| 1522 registry = concat2 (registry, build_string ("*-*")); | |
| 1523 } | |
| 1524 registry = Fdowncase (registry); | |
| 1525 ASET (font_spec, FONT_REGISTRY_INDEX, Fintern (registry, Qnil)); | |
| 90400 | 1526 } |
| 1527 } | |
| 1528 | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
1529 |
| 94926 | 1530 /* This part (through the next ^L) is still experimental and not |
| 1531 tested much. We may drastically change codes. */ | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
1532 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
1533 /* OTF handler */ |
| 90541 | 1534 |
|
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1535 #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
|
1536 #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
|
1537 |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1538 static int |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1539 check_gstring (gstring) |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1540 Lisp_Object gstring; |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1541 { |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1542 Lisp_Object val; |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1543 int i, j; |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1544 |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1545 CHECK_VECTOR (gstring); |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1546 val = AREF (gstring, 0); |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1547 CHECK_VECTOR (val); |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1548 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
|
1549 goto err; |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1550 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
|
1551 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
|
1552 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
|
1553 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
|
1554 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
|
1555 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
|
1556 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
|
1557 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
|
1558 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
|
1559 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
|
1560 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
|
1561 |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1562 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
|
1563 { |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1564 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
|
1565 CHECK_VECTOR (val); |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1566 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
|
1567 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
|
1568 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
|
1569 break; |
|
91550
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1570 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
|
1571 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
|
1572 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
|
1573 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
|
1574 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
|
1575 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
|
1576 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
|
1577 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
|
1578 { |
|
91550
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1579 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
|
1580 CHECK_VECTOR (val); |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1581 if (ASIZE (val) < 3) |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1582 goto err; |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1583 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
|
1584 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
|
1585 } |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1586 } |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1587 return i; |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1588 err: |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1589 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
|
1590 return -1; |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1591 } |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1592 |
|
90823
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1593 static void |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1594 check_otf_features (otf_features) |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1595 Lisp_Object otf_features; |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1596 { |
| 94926 | 1597 Lisp_Object val; |
|
90823
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1598 |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1599 CHECK_CONS (otf_features); |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1600 CHECK_SYMBOL (XCAR (otf_features)); |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1601 otf_features = XCDR (otf_features); |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1602 CHECK_CONS (otf_features); |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1603 CHECK_SYMBOL (XCAR (otf_features)); |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1604 otf_features = XCDR (otf_features); |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1605 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
|
1606 { |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1607 CHECK_SYMBOL (Fcar (val)); |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1608 if (SBYTES (SYMBOL_NAME (XCAR (val))) > 4) |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1609 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
|
1610 } |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1611 otf_features = XCDR (otf_features); |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1612 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
|
1613 { |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1614 CHECK_SYMBOL (Fcar (val)); |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1615 if (SBYTES (SYMBOL_NAME (XCAR (val))) > 4) |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1616 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
|
1617 } |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1618 } |
|
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1619 |
| 90400 | 1620 #ifdef HAVE_LIBOTF |
| 1621 #include <otf.h> | |
| 1622 | |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1623 Lisp_Object otf_list; |
| 90400 | 1624 |
| 1625 static Lisp_Object | |
| 1626 otf_tag_symbol (tag) | |
| 1627 OTF_Tag tag; | |
| 1628 { | |
| 1629 char name[5]; | |
| 1630 | |
| 1631 OTF_tag_name (tag, name); | |
| 1632 return Fintern (make_unibyte_string (name, 4), Qnil); | |
| 1633 } | |
| 1634 | |
| 1635 static OTF * | |
| 94926 | 1636 otf_open (file) |
| 1637 Lisp_Object file; | |
| 90400 | 1638 { |
| 94926 | 1639 Lisp_Object val = Fassoc (file, otf_list); |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1640 OTF *otf; |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1641 |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1642 if (! NILP (val)) |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1643 otf = XSAVE_VALUE (XCDR (val))->pointer; |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1644 else |
| 90400 | 1645 { |
| 94926 | 1646 otf = STRINGP (file) ? OTF_open ((char *) SDATA (file)) : NULL; |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1647 val = make_save_value (otf, 0); |
| 94926 | 1648 otf_list = Fcons (Fcons (file, val), otf_list); |
| 90400 | 1649 } |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1650 return otf; |
| 90400 | 1651 } |
| 1652 | |
| 1653 | |
| 1654 /* Return a list describing which scripts/languages FONT supports by | |
| 1655 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
|
1656 (struct font_driver).otf_capability. */ |
| 90400 | 1657 |
| 1658 Lisp_Object | |
| 1659 font_otf_capability (font) | |
| 1660 struct font *font; | |
| 1661 { | |
| 1662 OTF *otf; | |
| 1663 Lisp_Object capability = Fcons (Qnil, Qnil); | |
| 1664 int i; | |
| 1665 | |
| 94926 | 1666 otf = otf_open (font->props[FONT_FILE_INDEX]); |
| 90400 | 1667 if (! otf) |
| 1668 return Qnil; | |
| 1669 for (i = 0; i < 2; i++) | |
| 1670 { | |
| 1671 OTF_GSUB_GPOS *gsub_gpos; | |
| 1672 Lisp_Object script_list = Qnil; | |
| 1673 int j; | |
| 1674 | |
| 1675 if (OTF_get_features (otf, i == 0) < 0) | |
| 1676 continue; | |
| 1677 gsub_gpos = i == 0 ? otf->gsub : otf->gpos; | |
| 1678 for (j = gsub_gpos->ScriptList.ScriptCount - 1; j >= 0; j--) | |
| 1679 { | |
| 1680 OTF_Script *script = gsub_gpos->ScriptList.Script + j; | |
| 1681 Lisp_Object langsys_list = Qnil; | |
| 1682 Lisp_Object script_tag = otf_tag_symbol (script->ScriptTag); | |
| 1683 int k; | |
| 1684 | |
| 1685 for (k = script->LangSysCount; k >= 0; k--) | |
| 1686 { | |
| 1687 OTF_LangSys *langsys; | |
| 1688 Lisp_Object feature_list = Qnil; | |
| 1689 Lisp_Object langsys_tag; | |
| 1690 int l; | |
| 1691 | |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1692 if (k == script->LangSysCount) |
| 90400 | 1693 { |
| 1694 langsys = &script->DefaultLangSys; | |
| 1695 langsys_tag = Qnil; | |
| 1696 } | |
| 1697 else | |
| 1698 { | |
| 1699 langsys = script->LangSys + k; | |
| 1700 langsys_tag | |
| 1701 = otf_tag_symbol (script->LangSysRecord[k].LangSysTag); | |
| 1702 } | |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1703 for (l = langsys->FeatureCount - 1; l >= 0; l--) |
| 90400 | 1704 { |
| 1705 OTF_Feature *feature | |
| 1706 = gsub_gpos->FeatureList.Feature + langsys->FeatureIndex[l]; | |
| 1707 Lisp_Object feature_tag | |
| 1708 = otf_tag_symbol (feature->FeatureTag); | |
| 1709 | |
| 1710 feature_list = Fcons (feature_tag, feature_list); | |
| 1711 } | |
| 1712 langsys_list = Fcons (Fcons (langsys_tag, feature_list), | |
| 1713 langsys_list); | |
| 1714 } | |
| 1715 script_list = Fcons (Fcons (script_tag, langsys_list), | |
| 1716 script_list); | |
| 1717 } | |
| 1718 | |
| 1719 if (i == 0) | |
| 1720 XSETCAR (capability, script_list); | |
| 1721 else | |
| 1722 XSETCDR (capability, script_list); | |
| 1723 } | |
| 1724 | |
| 1725 return capability; | |
| 1726 } | |
| 1727 | |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1728 /* 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
|
1729 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
|
1730 assured that the sufficient memory has already allocated for |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1731 FEATURES. */ |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1732 |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1733 static void |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1734 generate_otf_features (spec, features) |
| 90400 | 1735 Lisp_Object spec; |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1736 char *features; |
| 90400 | 1737 { |
| 1738 Lisp_Object val; | |
| 94926 | 1739 char *p; |
| 90400 | 1740 int asterisk; |
| 1741 | |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1742 p = features; |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1743 *p = '\0'; |
| 90400 | 1744 for (asterisk = 0; CONSP (spec); spec = XCDR (spec)) |
| 1745 { | |
| 1746 val = XCAR (spec); | |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1747 CHECK_SYMBOL (val); |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1748 if (p > features) |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1749 *p++ = ','; |
| 90400 | 1750 if (SREF (SYMBOL_NAME (val), 0) == '*') |
| 1751 { | |
| 1752 asterisk = 1; | |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1753 *p++ = '*'; |
| 90400 | 1754 } |
| 1755 else if (! asterisk) | |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1756 { |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1757 val = SYMBOL_NAME (val); |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1758 p += sprintf (p, "%s", SDATA (val)); |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1759 } |
| 90400 | 1760 else |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1761 { |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1762 val = SYMBOL_NAME (val); |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1763 p += sprintf (p, "~%s", SDATA (val)); |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1764 } |
| 90400 | 1765 } |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1766 if (CONSP (spec)) |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1767 error ("OTF spec too long"); |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1768 } |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1769 |
| 90400 | 1770 |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1771 Lisp_Object |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1772 font_otf_DeviceTable (device_table) |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1773 OTF_DeviceTable *device_table; |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1774 { |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1775 int len = device_table->StartSize - device_table->EndSize + 1; |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1776 |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1777 return Fcons (make_number (len), |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1778 make_unibyte_string (device_table->DeltaValue, len)); |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1779 } |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1780 |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1781 Lisp_Object |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1782 font_otf_ValueRecord (value_format, value_record) |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1783 int value_format; |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1784 OTF_ValueRecord *value_record; |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1785 { |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1786 Lisp_Object val = Fmake_vector (make_number (8), Qnil); |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1787 |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1788 if (value_format & OTF_XPlacement) |
| 91909 | 1789 ASET (val, 0, make_number (value_record->XPlacement)); |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1790 if (value_format & OTF_YPlacement) |
| 91909 | 1791 ASET (val, 1, make_number (value_record->YPlacement)); |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1792 if (value_format & OTF_XAdvance) |
| 91909 | 1793 ASET (val, 2, make_number (value_record->XAdvance)); |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1794 if (value_format & OTF_YAdvance) |
| 91909 | 1795 ASET (val, 3, make_number (value_record->YAdvance)); |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1796 if (value_format & OTF_XPlaDevice) |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1797 ASET (val, 4, font_otf_DeviceTable (&value_record->XPlaDevice)); |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1798 if (value_format & OTF_YPlaDevice) |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1799 ASET (val, 4, font_otf_DeviceTable (&value_record->YPlaDevice)); |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1800 if (value_format & OTF_XAdvDevice) |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1801 ASET (val, 4, font_otf_DeviceTable (&value_record->XAdvDevice)); |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1802 if (value_format & OTF_YAdvDevice) |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1803 ASET (val, 4, font_otf_DeviceTable (&value_record->YAdvDevice)); |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1804 return val; |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1805 } |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1806 |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1807 Lisp_Object |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1808 font_otf_Anchor (anchor) |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1809 OTF_Anchor *anchor; |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1810 { |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1811 Lisp_Object val; |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1812 |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1813 val = Fmake_vector (make_number (anchor->AnchorFormat + 1), Qnil); |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1814 ASET (val, 0, make_number (anchor->XCoordinate)); |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1815 ASET (val, 1, make_number (anchor->YCoordinate)); |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1816 if (anchor->AnchorFormat == 2) |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1817 ASET (val, 2, make_number (anchor->f.f1.AnchorPoint)); |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1818 else |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1819 { |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1820 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
|
1821 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
|
1822 } |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1823 return val; |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1824 } |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1825 |
| 90400 | 1826 #endif /* HAVE_LIBOTF */ |
| 1827 | |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1828 /* G-string (glyph string) handler */ |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1829 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1830 /* 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
|
1831 See the docstring of `font-make-gstring' for more detail. */ |
| 90400 | 1832 |
| 1833 struct font * | |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1834 font_prepare_composition (cmp, f) |
| 90400 | 1835 struct composition *cmp; |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1836 FRAME_PTR f; |
| 90400 | 1837 { |
| 1838 Lisp_Object gstring | |
| 1839 = AREF (XHASH_TABLE (composition_hash_table)->key_and_value, | |
| 1840 cmp->hash_index * 2); | |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1841 |
| 94926 | 1842 cmp->font = XFONT_OBJECT (LGSTRING_FONT (gstring)); |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1843 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
|
1844 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
|
1845 cmp->lbearing = LGSTRING_LBEARING (gstring); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1846 cmp->rbearing = LGSTRING_RBEARING (gstring); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1847 cmp->ascent = LGSTRING_ASCENT (gstring); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1848 cmp->descent = LGSTRING_DESCENT (gstring); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1849 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
|
1850 if (cmp->width == 0) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1851 cmp->width = 1; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1852 |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
1853 return cmp->font; |
| 90400 | 1854 } |
| 1855 | |
| 1856 | |
| 1857 /* Font sorting */ | |
| 1858 | |
| 94926 | 1859 static unsigned font_score P_ ((Lisp_Object, Lisp_Object *, Lisp_Object)); |
| 90400 | 1860 static int font_compare P_ ((const void *, const void *)); |
| 1861 static Lisp_Object font_sort_entites P_ ((Lisp_Object, Lisp_Object, | |
| 94926 | 1862 Lisp_Object, Lisp_Object, |
| 1863 int)); | |
| 90400 | 1864 |
| 1865 /* We sort fonts by scoring each of them against a specified | |
| 1866 font-spec. The score value is 32 bit (`unsigned'), and the smaller | |
| 1867 the value is, the closer the font is to the font-spec. | |
| 1868 | |
| 94926 | 1869 The highest 2 bits of the score is used for FAMILY. The exact |
| 1870 match is 0, match with one of face-font-family-alternatives is | |
| 1871 nonzero. | |
| 1872 | |
| 1873 The next 2 bits of the score is used for the atomic properties | |
| 1874 FOUNDRY and ADSTYLE respectively. | |
| 1875 | |
| 1876 Each 7-bit in the lower 28 bits are used for numeric properties | |
| 90400 | 1877 WEIGHT, SLANT, WIDTH, and SIZE. */ |
| 1878 | |
| 1879 /* How many bits to shift to store the difference value of each font | |
| 94926 | 1880 property in a score. Note that flots for FONT_TYPE_INDEX and |
| 1881 FONT_REGISTRY_INDEX are not used. */ | |
| 90400 | 1882 static int sort_shift_bits[FONT_SIZE_INDEX + 1]; |
| 1883 | |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1884 /* 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
|
1885 The return value indicates how different ENTITY is compared with |
| 94926 | 1886 SPEC_PROP. |
| 1887 | |
| 1888 ALTERNATE_FAMILIES, if non-nil, is a pre-calculated list of | |
| 1889 alternate family names for AREF (SPEC_PROP, FONT_FAMILY_INDEX). */ | |
| 90400 | 1890 |
| 1891 static unsigned | |
| 94926 | 1892 font_score (entity, spec_prop, alternate_families) |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1893 Lisp_Object entity, *spec_prop; |
| 94926 | 1894 Lisp_Object alternate_families; |
| 90400 | 1895 { |
| 1896 unsigned score = 0; | |
| 1897 int i; | |
| 94926 | 1898 |
| 1899 /* Score three atomic fields. Maximum difference is 1 (family is 3). */ | |
| 1900 for (i = FONT_FOUNDRY_INDEX; i <= FONT_ADSTYLE_INDEX; i++) | |
| 1901 if (i != FONT_REGISTRY_INDEX | |
| 1902 && ! NILP (spec_prop[i]) && ! EQ (AREF (entity, i), spec_prop[i])) | |
| 1903 { | |
| 1904 Lisp_Object entity_str = SYMBOL_NAME (AREF (entity, i)); | |
| 1905 Lisp_Object spec_str = SYMBOL_NAME (spec_prop[i]); | |
| 1906 | |
| 1907 if (strcasecmp (SDATA (spec_str), SDATA (entity_str))) | |
| 1908 { | |
| 1909 if (i == FONT_FAMILY_INDEX && CONSP (alternate_families)) | |
| 1910 { | |
| 1911 int j; | |
| 1912 | |
| 1913 for (j = 1; CONSP (alternate_families); | |
| 1914 j++, alternate_families = XCDR (alternate_families)) | |
| 1915 { | |
| 1916 spec_str = XCAR (alternate_families); | |
| 1917 if (strcasecmp (SDATA (spec_str), SDATA (entity_str)) == 0) | |
| 1918 break; | |
| 1919 | |
| 1920 } | |
| 1921 if (j > 3) | |
| 1922 j = 3; | |
| 1923 score |= j << sort_shift_bits[i]; | |
| 1924 } | |
| 1925 else | |
| 1926 score |= 1 << sort_shift_bits[i]; | |
| 1927 } | |
| 1928 } | |
| 1929 | |
| 1930 /* Score three style numeric fields. Maximum difference is 127. */ | |
| 1931 for (i = FONT_WEIGHT_INDEX; i <= FONT_WIDTH_INDEX; i++) | |
| 1932 if (! NILP (spec_prop[i]) && ! EQ (AREF (entity, i), spec_prop[i])) | |
| 1933 { | |
| 1934 int diff = (XINT (AREF (entity, i)) >> 8) - (XINT (spec_prop[i]) >> 8); | |
| 1935 | |
| 1936 if (diff < 0) | |
| 1937 diff = - diff; | |
| 1938 /* This is to prefer the exact symbol style. */ | |
| 1939 diff++; | |
| 1940 score |= min (diff, 127) << sort_shift_bits[i]; | |
| 1941 } | |
| 1942 | |
| 1943 /* Score the size. Maximum difference is 127. */ | |
| 1944 i = FONT_SIZE_INDEX; | |
| 1945 if (! NILP (spec_prop[i]) && ! EQ (AREF (entity, i), spec_prop[i]) | |
| 1946 && XINT (AREF (entity, i)) > 0) | |
| 90400 | 1947 { |
| 94926 | 1948 /* We use the higher 6-bit for the actual size difference. The |
| 1949 lowest bit is set if the DPI is different. */ | |
| 1950 int diff = XINT (spec_prop[i]) - XINT (AREF (entity, i)); | |
| 1951 | |
| 1952 if (diff < 0) | |
| 1953 diff = - diff; | |
| 1954 diff << 1; | |
| 1955 if (! NILP (spec_prop[FONT_DPI_INDEX]) | |
| 1956 && ! EQ (spec_prop[FONT_DPI_INDEX], AREF (entity, FONT_DPI_INDEX))) | |
| 1957 diff |= 1; | |
| 1958 score |= min (diff, 127) << sort_shift_bits[FONT_SIZE_INDEX]; | |
| 90400 | 1959 } |
| 1960 | |
| 1961 return score; | |
| 1962 } | |
| 1963 | |
| 1964 | |
| 1965 /* The comparison function for qsort. */ | |
| 1966 | |
| 1967 static int | |
| 1968 font_compare (d1, d2) | |
| 1969 const void *d1, *d2; | |
| 1970 { | |
| 94926 | 1971 return (*(unsigned *) d1 - *(unsigned *) d2); |
| 90400 | 1972 } |
| 1973 | |
| 1974 | |
| 1975 /* The structure for elements being sorted by qsort. */ | |
| 1976 struct font_sort_data | |
| 1977 { | |
| 1978 unsigned score; | |
| 1979 Lisp_Object entity; | |
| 1980 }; | |
| 1981 | |
| 1982 | |
| 1983 /* Sort font-entities in vector VEC by closeness to font-spec PREFER. | |
| 1984 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
|
1985 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
|
1986 of FRAME before sorting. If SPEC is not nil, it is a font-spec to |
| 94926 | 1987 get the font-entities in VEC. |
| 1988 | |
| 1989 If BEST-ONLY is nonzero, return the best matching entity. Otherwise, | |
| 1990 return the sorted VEC. */ | |
| 90400 | 1991 |
| 1992 static Lisp_Object | |
| 94926 | 1993 font_sort_entites (vec, prefer, frame, spec, best_only) |
| 90400 | 1994 Lisp_Object vec, prefer, frame, spec; |
| 94926 | 1995 int best_only; |
| 90400 | 1996 { |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1997 Lisp_Object prefer_prop[FONT_SPEC_MAX]; |
| 90400 | 1998 int len, i; |
| 1999 struct font_sort_data *data; | |
| 94926 | 2000 Lisp_Object alternate_families = Qnil; |
| 2001 unsigned best_score; | |
| 2002 Lisp_Object best_entity; | |
| 90400 | 2003 USE_SAFE_ALLOCA; |
| 2004 | |
| 2005 len = ASIZE (vec); | |
| 2006 if (len <= 1) | |
| 94926 | 2007 return best_only ? AREF (vec, 0) : vec; |
| 2008 | |
| 2009 for (i = FONT_FOUNDRY_INDEX; i <= FONT_DPI_INDEX; i++) | |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2010 prefer_prop[i] = AREF (prefer, i); |
| 90400 | 2011 |
| 2012 if (! NILP (spec)) | |
| 2013 { | |
| 94926 | 2014 /* A font driver may return a font that has a property value |
| 2015 different from the value specified in SPEC if the driver | |
| 2016 thinks they are the same. That happens, for instance, such a | |
| 2017 generic family name as "serif" is specified. So, to ignore | |
| 2018 such a difference, for all properties specified in SPEC, set | |
| 2019 the corresponding properties in PREFER_PROP to nil. */ | |
| 2020 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
|
2021 if (! NILP (AREF (spec, i))) |
| 94926 | 2022 prefer_prop[i] = Qnil; |
| 90400 | 2023 } |
| 2024 | |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2025 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
|
2026 prefer_prop[FONT_SIZE_INDEX] |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2027 = make_number (font_pixel_size (XFRAME (frame), prefer)); |
| 94926 | 2028 if (! NILP (prefer_prop[FONT_FAMILY_INDEX])) |
| 2029 { | |
| 2030 alternate_families | |
| 2031 = Fassoc_string (prefer_prop[FONT_FAMILY_INDEX], | |
| 2032 Vface_alternative_font_family_alist, Qt); | |
| 2033 if (CONSP (alternate_families)) | |
| 2034 alternate_families = XCDR (alternate_families); | |
| 2035 } | |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2036 |
| 90400 | 2037 /* Scoring and sorting. */ |
| 2038 SAFE_ALLOCA (data, struct font_sort_data *, (sizeof *data) * len); | |
| 94926 | 2039 best_score = 0xFFFFFFFF; |
| 2040 best_entity = Qnil; | |
| 90400 | 2041 for (i = 0; i < len; i++) |
| 2042 { | |
| 2043 data[i].entity = AREF (vec, i); | |
| 94926 | 2044 data[i].score = font_score (data[i].entity, prefer_prop, |
| 2045 alternate_families); | |
| 2046 if (best_only && best_score > data[i].score) | |
| 2047 { | |
| 2048 best_score = data[i].score; | |
| 2049 best_entity = data[i].entity; | |
| 2050 if (best_score == 0) | |
| 2051 break; | |
| 2052 } | |
| 90400 | 2053 } |
| 94926 | 2054 if (NILP (best_entity)) |
| 2055 { | |
| 2056 qsort (data, len, sizeof *data, font_compare); | |
| 2057 for (i = 0; i < len; i++) | |
| 2058 ASET (vec, i, data[i].entity); | |
| 2059 } | |
| 2060 else | |
| 2061 vec = best_entity; | |
| 90400 | 2062 SAFE_FREE (); |
| 2063 | |
| 2064 return vec; | |
| 2065 } | |
| 2066 | |
| 2067 | |
| 2068 /* API of Font Service Layer. */ | |
| 2069 | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2070 /* 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
|
2071 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
|
2072 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
|
2073 |
| 90400 | 2074 void |
| 2075 font_update_sort_order (order) | |
| 2076 int *order; | |
| 2077 { | |
| 94926 | 2078 int i, shift_bits; |
| 2079 | |
| 2080 for (i = 0, shift_bits = 21; i < 4; i++, shift_bits -= 7) | |
| 90400 | 2081 { |
| 2082 int xlfd_idx = order[i]; | |
| 2083 | |
| 2084 if (xlfd_idx == XLFD_WEIGHT_INDEX) | |
| 2085 sort_shift_bits[FONT_WEIGHT_INDEX] = shift_bits; | |
| 2086 else if (xlfd_idx == XLFD_SLANT_INDEX) | |
| 2087 sort_shift_bits[FONT_SLANT_INDEX] = shift_bits; | |
| 2088 else if (xlfd_idx == XLFD_SWIDTH_INDEX) | |
| 2089 sort_shift_bits[FONT_WIDTH_INDEX] = shift_bits; | |
| 2090 else | |
| 2091 sort_shift_bits[FONT_SIZE_INDEX] = shift_bits; | |
| 2092 } | |
| 2093 } | |
| 2094 | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2095 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2096 /* 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
|
2097 |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2098 int |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2099 font_match_p (spec, entity) |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2100 Lisp_Object spec, entity; |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2101 { |
| 94926 | 2102 Lisp_Object prefer_prop[FONT_SPEC_MAX]; |
| 2103 Lisp_Object alternate_families = Qnil; | |
| 2104 int prefer_style[3]; | |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2105 int i; |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2106 |
| 94926 | 2107 for (i = FONT_FOUNDRY_INDEX; i <= FONT_SIZE_INDEX; i++) |
| 2108 prefer_prop[i] = AREF (spec, i); | |
| 2109 if (FLOATP (prefer_prop[FONT_SIZE_INDEX])) | |
| 2110 prefer_prop[FONT_SIZE_INDEX] | |
| 2111 = make_number (font_pixel_size (XFRAME (selected_frame), spec)); | |
| 2112 if (! NILP (prefer_prop[FONT_FAMILY_INDEX])) | |
| 2113 { | |
| 2114 alternate_families | |
| 2115 = Fassoc_string (prefer_prop[FONT_FAMILY_INDEX], | |
| 2116 Vface_alternative_font_family_alist, Qt); | |
| 2117 if (CONSP (alternate_families)) | |
| 2118 alternate_families = XCDR (alternate_families); | |
| 2119 } | |
| 2120 | |
| 2121 return (font_score (entity, prefer_prop, alternate_families) == 0); | |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2122 } |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2123 |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2124 |
| 94926 | 2125 /* CHeck a lispy font object corresponding to FONT. */ |
| 2126 | |
| 2127 int | |
| 2128 font_check_object (font) | |
| 90400 | 2129 struct font *font; |
| 2130 { | |
| 2131 Lisp_Object tail, elt; | |
| 2132 | |
| 94926 | 2133 for (tail = font->props[FONT_OBJLIST_INDEX]; CONSP (tail); |
| 90400 | 2134 tail = XCDR (tail)) |
| 2135 { | |
| 2136 elt = XCAR (tail); | |
| 94926 | 2137 if (font == XFONT_OBJECT (elt)) |
| 2138 return 1; | |
| 90400 | 2139 } |
| 94926 | 2140 return 0; |
| 90400 | 2141 } |
| 2142 | |
|
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2143 |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2144 /* Font cache |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2145 |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2146 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
|
2147 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
|
2148 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
|
2149 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
|
2150 |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2151 ((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
|
2152 |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2153 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
|
2154 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
|
2155 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
|
2156 |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2157 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
|
2158 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
|
2159 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
|
2160 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
|
2161 struct font_driver *)); |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2162 |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2163 static void |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2164 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
|
2165 FRAME_PTR f; |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2166 struct font_driver *driver; |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2167 { |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2168 Lisp_Object cache, val; |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2169 |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2170 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
|
2171 val = XCDR (cache); |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2172 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
|
2173 val = XCDR (val); |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2174 if (NILP (val)) |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2175 { |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2176 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
|
2177 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
|
2178 } |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2179 else |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2180 { |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2181 val = XCDR (XCAR (val)); |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2182 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
|
2183 } |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2184 } |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2185 |
| 91909 | 2186 |
|
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2187 static void |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2188 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
|
2189 FRAME_PTR f; |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2190 struct font_driver *driver; |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2191 { |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2192 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
|
2193 |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2194 |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2195 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
|
2196 val = XCDR (cache); |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2197 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
|
2198 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
|
2199 xassert (! NILP (val)); |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2200 tmp = XCDR (XCAR (val)); |
| 91909 | 2201 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
|
2202 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
|
2203 { |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2204 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
|
2205 XSETCDR (cache, XCDR (val)); |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2206 } |
|
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 |
| 91909 | 2209 |
|
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2210 static Lisp_Object |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2211 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
|
2212 FRAME_PTR f; |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2213 struct font_driver *driver; |
|
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 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
|
2216 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
|
2217 |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2218 xassert (CONSP (val)); |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2219 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
|
2220 xassert (CONSP (val)); |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2221 /* 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
|
2222 val = XCDR (XCAR (val)); |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2223 return val; |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2224 } |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2225 |
| 91909 | 2226 static int num_fonts; |
| 2227 | |
|
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2228 static void |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2229 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
|
2230 FRAME_PTR f; |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2231 Lisp_Object cache; |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2232 struct font_driver *driver; |
|
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 Lisp_Object tail, elt; |
|
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
2235 |
|
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2236 /* 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
|
2237 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
|
2238 { |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2239 elt = XCAR (tail); |
|
94968
e87ef440216b
(font_clear_cache): Check if the cached vector of entities is nil
Kenichi Handa <handa@m17n.org>
parents:
94964
diff
changeset
|
2240 if (CONSP (elt) && FONT_SPEC_P (XCAR (elt)) && VECTORP (XCDR (elt))) |
|
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2241 { |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2242 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
|
2243 int i; |
|
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 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
|
2246 { |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2247 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
|
2248 |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2249 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
|
2250 { |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2251 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
|
2252 |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2253 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
|
2254 { |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2255 Lisp_Object val = XCAR (objlist); |
| 94926 | 2256 struct font *font = XFONT_OBJECT (val); |
|
91247
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 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
|
2259 driver->close (f, font); |
| 91909 | 2260 num_fonts--; |
|
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2261 } |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2262 if (driver->free_entity) |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2263 driver->free_entity (entity); |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2264 } |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2265 } |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2266 } |
|
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 XSETCDR (cache, Qnil); |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2269 } |
|
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 |
| 90400 | 2272 static Lisp_Object scratch_font_spec, scratch_font_prefer; |
| 2273 | |
| 94926 | 2274 Lisp_Object |
| 2275 font_delete_unmatched (list, spec, size) | |
| 2276 Lisp_Object list, spec; | |
| 2277 int size; | |
| 2278 { | |
| 2279 Lisp_Object entity, prev, tail; | |
| 2280 enum font_property_index prop; | |
| 2281 | |
| 2282 for (tail = list, prev = Qnil; CONSP (tail); ) | |
| 2283 { | |
| 2284 entity = XCAR (tail); | |
| 2285 for (prop = FONT_WEIGHT_INDEX; prop < FONT_SIZE_INDEX; prop++) | |
| 2286 if (INTEGERP (AREF (spec, prop)) | |
| 2287 && ((XINT (AREF (spec, prop)) >> 8) | |
| 2288 != (XINT (AREF (entity, prop)) >> 8))) | |
| 2289 prop = FONT_SPEC_MAX; | |
| 2290 if (prop++ <= FONT_SIZE_INDEX | |
| 2291 && size | |
| 2292 && XINT (AREF (entity, FONT_SIZE_INDEX)) > 0) | |
| 2293 { | |
| 2294 int diff = XINT (AREF (entity, FONT_SIZE_INDEX)) - size; | |
| 2295 | |
| 2296 if (diff != 0 | |
| 2297 && (diff < 0 ? -diff > FONT_PIXEL_SIZE_QUANTUM | |
| 2298 : diff > FONT_PIXEL_SIZE_QUANTUM)) | |
| 2299 prop = FONT_SPEC_MAX; | |
| 2300 } | |
| 2301 if (prop < FONT_SPEC_MAX | |
| 2302 && INTEGERP (AREF (spec, FONT_SPACING_INDEX)) | |
| 2303 && ! EQ (AREF (spec, FONT_SPACING_INDEX), | |
| 2304 AREF (entity, FONT_SPACING_INDEX))) | |
| 2305 prop = FONT_SPEC_MAX; | |
| 2306 if (prop < FONT_SPEC_MAX) | |
| 2307 prev = tail, tail = XCDR (tail); | |
| 2308 else if (NILP (prev)) | |
| 2309 list = tail = XCDR (tail); | |
| 2310 else | |
| 2311 tail = XCDR (tail), XSETCDR (prev, tail); | |
| 2312 } | |
| 2313 return list; | |
| 2314 } | |
| 2315 | |
| 2316 | |
| 2317 /* Return a vector of font-entities matching with SPEC on FRAME. */ | |
| 2318 | |
| 2319 Lisp_Object | |
| 90400 | 2320 font_list_entities (frame, spec) |
| 2321 Lisp_Object frame, spec; | |
| 2322 { | |
| 2323 FRAME_PTR f = XFRAME (frame); | |
| 2324 struct font_driver_list *driver_list = f->font_driver_list; | |
| 94926 | 2325 Lisp_Object ftype, family, alternate_familes; |
| 2326 Lisp_Object *vec; | |
| 2327 int size; | |
| 2328 int need_filtering = 0; | |
| 2329 int n_family = 1; | |
| 90400 | 2330 int i; |
| 2331 | |
| 94926 | 2332 xassert (FONT_SPEC_P (spec)); |
| 90400 | 2333 |
| 2334 family = AREF (spec, FONT_FAMILY_INDEX); | |
| 2335 if (NILP (family)) | |
| 2336 alternate_familes = Qnil; | |
| 2337 else | |
| 2338 { | |
| 94926 | 2339 alternate_familes = Fassoc_string (family, |
| 2340 Vface_alternative_font_family_alist, | |
| 2341 Qt); | |
| 90400 | 2342 if (! NILP (alternate_familes)) |
| 2343 alternate_familes = XCDR (alternate_familes); | |
| 94926 | 2344 n_family += XINT (Flength (alternate_familes)); |
| 90400 | 2345 } |
| 94926 | 2346 |
| 2347 if (INTEGERP (AREF (spec, FONT_SIZE_INDEX))) | |
| 2348 size = XINT (AREF (spec, FONT_SIZE_INDEX)); | |
| 2349 else if (FLOATP (AREF (spec, FONT_SIZE_INDEX))) | |
| 2350 size = font_pixel_size (f, spec); | |
| 2351 else | |
| 2352 size = 0; | |
| 2353 | |
| 90400 | 2354 ftype = AREF (spec, FONT_TYPE_INDEX); |
| 94926 | 2355 for (i = 0; i <= FONT_REGISTRY_INDEX; i++) |
| 2356 ASET (scratch_font_spec, i, AREF (spec, i)); | |
| 2357 for (; i < FONT_EXTRA_INDEX; i++) | |
| 2358 { | |
| 2359 ASET (scratch_font_spec, i, Qnil); | |
| 2360 if (! NILP (AREF (spec, i))) | |
| 2361 need_filtering = 1; | |
| 2362 } | |
| 2363 ASET (scratch_font_spec, FONT_EXTRA_INDEX, AREF (spec, FONT_EXTRA_INDEX)); | |
| 2364 | |
| 2365 vec = alloca (sizeof (Lisp_Object) * num_font_drivers * n_family); | |
| 2366 if (! vec) | |
| 2367 return null_vector; | |
|
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
2368 |
| 90400 | 2369 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
|
2370 if (driver_list->on |
|
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
2371 && (NILP (ftype) || EQ (driver_list->driver->type, ftype))) |
| 90400 | 2372 { |
|
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2373 Lisp_Object cache = font_get_cache (f, driver_list->driver); |
| 90400 | 2374 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
|
2375 |
| 90400 | 2376 while (1) |
| 2377 { | |
| 94926 | 2378 Lisp_Object val = assoc_no_quit (scratch_font_spec, XCDR (cache)); |
| 2379 | |
| 2380 if (CONSP (val) && VECTORP (XCDR (val))) | |
| 90400 | 2381 val = XCDR (val); |
| 2382 else | |
| 2383 { | |
| 94926 | 2384 Lisp_Object copy; |
| 2385 | |
| 2386 val = driver_list->driver->list (frame, scratch_font_spec); | |
| 2387 if (! NILP (val) && need_filtering) | |
| 2388 val = font_delete_unmatched (val, spec, size); | |
| 2389 copy = Fcopy_font_spec (scratch_font_spec); | |
| 2390 XSETCDR (cache, Fcons (Fcons (copy, val), XCDR (cache))); | |
| 90400 | 2391 } |
| 94926 | 2392 if (! NILP (val)) |
| 90400 | 2393 { |
| 2394 vec[i++] = val; | |
| 2395 break; | |
| 2396 } | |
| 2397 if (NILP (tail)) | |
| 2398 break; | |
| 94926 | 2399 ASET (scratch_font_spec, FONT_FAMILY_INDEX, |
| 2400 Fintern (XCAR (tail), Qnil)); | |
| 90400 | 2401 tail = XCDR (tail); |
| 2402 } | |
| 2403 } | |
| 94926 | 2404 |
| 90400 | 2405 return (i > 0 ? Fvconcat (i, vec) : null_vector); |
| 2406 } | |
| 2407 | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2408 |
| 94926 | 2409 /* Return a font entity matching with SPEC on FRAME. ATTRS, if non |
| 2410 nil, is an array of face's attributes, which specifies preferred | |
| 2411 font-related attributes. */ | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2412 |
|
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2413 static Lisp_Object |
| 94926 | 2414 font_matching_entity (f, attrs, spec) |
| 2415 FRAME_PTR f; | |
| 2416 Lisp_Object *attrs, spec; | |
|
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2417 { |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2418 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
|
2419 Lisp_Object ftype, size, entity; |
| 94926 | 2420 Lisp_Object frame; |
| 2421 | |
| 2422 XSETFRAME (frame, f); | |
|
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2423 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
|
2424 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
|
2425 if (FLOATP (size)) |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2426 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
|
2427 entity = Qnil; |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2428 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
|
2429 if (driver_list->on |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2430 && (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
|
2431 { |
|
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2432 Lisp_Object cache = font_get_cache (f, driver_list->driver); |
|
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2433 |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2434 ASET (spec, FONT_TYPE_INDEX, driver_list->driver->type); |
| 94926 | 2435 entity = assoc_no_quit (spec, XCDR (cache)); |
| 2436 if (CONSP (entity) && ! VECTORP (XCDR (entity))) | |
|
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2437 entity = XCDR (entity); |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2438 else |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2439 { |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2440 entity = driver_list->driver->match (frame, spec); |
| 94926 | 2441 XSETCDR (cache, Fcons (Fcons (Fcopy_font_spec (spec), entity), |
| 2442 XCDR (cache))); | |
|
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2443 } |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2444 if (! NILP (entity)) |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2445 break; |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2446 } |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2447 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
|
2448 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
|
2449 return entity; |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2450 } |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2451 |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2452 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2453 /* 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
|
2454 opened font object. */ |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2455 |
| 90400 | 2456 static Lisp_Object |
| 2457 font_open_entity (f, entity, pixel_size) | |
| 2458 FRAME_PTR f; | |
| 2459 Lisp_Object entity; | |
| 2460 int pixel_size; | |
| 2461 { | |
| 2462 struct font_driver_list *driver_list; | |
| 91909 | 2463 Lisp_Object objlist, size, val, font_object; |
| 90400 | 2464 struct font *font; |
| 94926 | 2465 int min_width; |
| 2466 | |
| 2467 xassert (FONT_ENTITY_P (entity)); | |
| 90400 | 2468 size = AREF (entity, FONT_SIZE_INDEX); |
| 2469 if (XINT (size) != 0) | |
| 2470 pixel_size = XINT (size); | |
| 2471 | |
| 2472 for (objlist = AREF (entity, FONT_OBJLIST_INDEX); CONSP (objlist); | |
| 2473 objlist = XCDR (objlist)) | |
| 94926 | 2474 if (XFONT_OBJECT (XCAR (objlist))->pixel_size == pixel_size) |
| 2475 return XCAR (objlist); | |
| 2476 | |
| 2477 val = AREF (entity, FONT_TYPE_INDEX); | |
| 2478 for (driver_list = f->font_driver_list; | |
| 2479 driver_list && ! EQ (driver_list->driver->type, val); | |
| 2480 driver_list = driver_list->next); | |
| 2481 if (! driver_list) | |
| 2482 return Qnil; | |
| 2483 | |
| 2484 font_object = driver_list->driver->open (f, entity, pixel_size); | |
| 91909 | 2485 if (NILP (font_object)) |
| 94926 | 2486 return Qnil; |
| 2487 ASET (entity, FONT_OBJLIST_INDEX, | |
| 2488 Fcons (font_object, AREF (entity, FONT_OBJLIST_INDEX))); | |
| 2489 ASET (font_object, FONT_OBJLIST_INDEX, AREF (entity, FONT_OBJLIST_INDEX)); | |
| 2490 num_fonts++; | |
| 2491 | |
| 2492 font = XFONT_OBJECT (font_object); | |
| 2493 min_width = (font->min_width ? font->min_width | |
| 2494 : font->average_width ? font->average_width | |
| 2495 : font->space_width ? font->space_width | |
| 2496 : 1); | |
| 2497 FRAME_X_DISPLAY_INFO (f)->n_fonts++; | |
| 2498 if (FRAME_X_DISPLAY_INFO (f)->n_fonts == 1) | |
| 91909 | 2499 { |
| 94926 | 2500 FRAME_SMALLEST_CHAR_WIDTH (f) = min_width; |
| 2501 FRAME_SMALLEST_FONT_HEIGHT (f) = font->height; | |
| 2502 fonts_changed_p = 1; | |
| 91909 | 2503 } |
| 94926 | 2504 else |
| 2505 { | |
| 2506 if (FRAME_SMALLEST_CHAR_WIDTH (f) > min_width) | |
| 2507 FRAME_SMALLEST_CHAR_WIDTH (f) = min_width, fonts_changed_p = 1; | |
| 2508 if (FRAME_SMALLEST_FONT_HEIGHT (f) > font->height) | |
| 2509 FRAME_SMALLEST_FONT_HEIGHT (f) = font->height, fonts_changed_p = 1; | |
| 2510 } | |
| 91909 | 2511 |
| 2512 return font_object; | |
| 90400 | 2513 } |
| 2514 | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2515 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2516 /* 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
|
2517 |
| 90400 | 2518 void |
| 2519 font_close_object (f, font_object) | |
| 2520 FRAME_PTR f; | |
| 2521 Lisp_Object font_object; | |
| 2522 { | |
| 94926 | 2523 struct font *font = XFONT_OBJECT (font_object); |
| 90541 | 2524 Lisp_Object objlist; |
| 90400 | 2525 Lisp_Object tail, prev = Qnil; |
| 2526 | |
| 94926 | 2527 objlist = AREF (font_object, FONT_OBJLIST_INDEX); |
| 90400 | 2528 for (prev = Qnil, tail = objlist; CONSP (tail); |
| 2529 prev = tail, tail = XCDR (tail)) | |
| 2530 if (EQ (font_object, XCAR (tail))) | |
| 2531 { | |
| 94926 | 2532 xassert (FRAME_X_DISPLAY_INFO (f)->n_fonts); |
| 2533 font->driver->close (f, font); | |
| 2534 FRAME_X_DISPLAY_INFO (f)->n_fonts--; | |
| 90541 | 2535 if (NILP (prev)) |
| 94926 | 2536 ASET (font_object, FONT_OBJLIST_INDEX, XCDR (objlist)); |
| 90541 | 2537 else |
| 2538 XSETCDR (prev, XCDR (objlist)); | |
| 91909 | 2539 num_fonts--; |
| 90541 | 2540 return; |
| 90400 | 2541 } |
| 90541 | 2542 abort (); |
| 90400 | 2543 } |
| 2544 | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2545 |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2546 /* 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
|
2547 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
|
2548 |
| 90400 | 2549 int |
|
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2550 font_has_char (f, font, c) |
| 90400 | 2551 FRAME_PTR f; |
|
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2552 Lisp_Object font; |
| 90400 | 2553 int c; |
| 2554 { | |
|
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2555 struct font *fontp; |
|
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2556 |
|
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2557 if (FONT_ENTITY_P (font)) |
|
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2558 { |
|
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2559 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
|
2560 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
|
2561 |
|
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2562 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
|
2563 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
|
2564 driver_list = driver_list->next); |
|
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2565 if (! driver_list) |
|
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2566 return 0; |
|
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2567 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
|
2568 return -1; |
|
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2569 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
|
2570 } |
|
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 xassert (FONT_OBJECT_P (font)); |
| 94926 | 2573 fontp = XFONT_OBJECT (font); |
|
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2574 if (fontp->driver->has_char) |
|
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2575 { |
| 94926 | 2576 int result = fontp->driver->has_char (font, c); |
|
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2577 |
|
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2578 if (result >= 0) |
|
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2579 return result; |
|
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2580 } |
|
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2581 return (fontp->driver->encode_char (fontp, c) != FONT_INVALID_CODE); |
| 90400 | 2582 } |
| 2583 | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2584 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2585 /* 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
|
2586 |
| 90400 | 2587 unsigned |
| 2588 font_encode_char (font_object, c) | |
| 2589 Lisp_Object font_object; | |
| 2590 int c; | |
| 2591 { | |
| 94926 | 2592 struct font *font; |
| 2593 | |
| 2594 xassert (FONT_OBJECT_P (font_object)); | |
| 2595 font = XFONT_OBJECT (font_object); | |
| 90400 | 2596 return font->driver->encode_char (font, c); |
| 2597 } | |
| 2598 | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2599 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2600 /* 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
|
2601 |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2602 Lisp_Object |
| 90400 | 2603 font_get_name (font_object) |
| 2604 Lisp_Object font_object; | |
| 2605 { | |
| 94926 | 2606 Lisp_Object name; |
| 2607 | |
| 2608 xassert (FONT_OBJECT_P (font_object)); | |
| 2609 return AREF (font_object, FONT_NAME_INDEX); | |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2610 } |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2611 |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2612 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2613 /* 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
|
2614 |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2615 Lisp_Object |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2616 font_get_spec (font_object) |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2617 Lisp_Object font_object; |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2618 { |
| 94926 | 2619 Lisp_Object spec = font_make_spec (); |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2620 int i; |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2621 |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2622 for (i = 0; i < FONT_SIZE_INDEX; i++) |
| 94926 | 2623 ASET (spec, i, AREF (font_object, i)); |
| 2624 ASET (spec, FONT_SIZE_INDEX, | |
| 2625 make_number (XFONT_OBJECT (font_object)->pixel_size)); | |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2626 return spec; |
| 90400 | 2627 } |
| 2628 | |
| 2629 Lisp_Object | |
| 94926 | 2630 font_spec_from_name (font_name) |
| 2631 Lisp_Object font_name; | |
| 2632 { | |
| 2633 Lisp_Object args[2]; | |
| 2634 | |
| 2635 args[0] = QCname; | |
| 2636 args[1] = font_name; | |
| 2637 return Ffont_spec (2, args); | |
| 2638 } | |
| 2639 | |
| 2640 | |
| 2641 void | |
| 2642 font_clear_prop (attrs, prop) | |
| 2643 Lisp_Object *attrs; | |
| 2644 enum font_property_index prop; | |
| 2645 { | |
| 2646 Lisp_Object font = attrs[LFACE_FONT_INDEX]; | |
| 2647 Lisp_Object extra, prev; | |
| 2648 | |
| 2649 if (! FONTP (font)) | |
| 2650 return; | |
| 2651 if (NILP (AREF (font, prop)) | |
| 2652 && prop != FONT_FAMILY_INDEX && prop != FONT_FAMILY_INDEX) | |
| 2653 return; | |
| 2654 font = Fcopy_font_spec (font); | |
| 2655 ASET (font, prop, Qnil); | |
| 2656 if (prop == FONT_FAMILY_INDEX) | |
| 2657 { | |
| 2658 ASET (font, FONT_FOUNDRY_INDEX, Qnil); | |
| 2659 ASET (font, FONT_ADSTYLE_INDEX, Qnil); | |
| 2660 ASET (font, FONT_SIZE_INDEX, Qnil); | |
| 2661 ASET (font, FONT_DPI_INDEX, Qnil); | |
| 2662 ASET (font, FONT_SPACING_INDEX, Qnil); | |
| 2663 ASET (font, FONT_AVGWIDTH_INDEX, Qnil); | |
| 2664 } | |
| 2665 else if (prop == FONT_SIZE_INDEX) | |
| 2666 { | |
| 2667 ASET (font, FONT_DPI_INDEX, Qnil); | |
| 2668 ASET (font, FONT_SPACING_INDEX, Qnil); | |
| 2669 ASET (font, FONT_AVGWIDTH_INDEX, Qnil); | |
| 2670 } | |
| 2671 attrs[LFACE_FONT_INDEX] = font; | |
| 2672 } | |
| 2673 | |
| 2674 void | |
| 2675 font_update_lface (f, attrs) | |
| 2676 FRAME_PTR f; | |
| 2677 Lisp_Object *attrs; | |
| 90400 | 2678 { |
| 94926 | 2679 Lisp_Object spec, val; |
| 2680 int n; | |
| 2681 | |
| 2682 spec = attrs[LFACE_FONT_INDEX]; | |
| 2683 if (! FONT_SPEC_P (spec)) | |
| 2684 return; | |
| 2685 | |
| 2686 if (! NILP (AREF (spec, FONT_FOUNDRY_INDEX)) | |
| 2687 || ! NILP (AREF (spec, FONT_FAMILY_INDEX))) | |
| 2688 { | |
| 2689 Lisp_Object family; | |
| 2690 | |
| 2691 if (NILP (AREF (spec, FONT_FOUNDRY_INDEX))) | |
| 2692 family = AREF (spec, FONT_FAMILY_INDEX); | |
| 2693 else if (NILP (AREF (spec, FONT_FAMILY_INDEX))) | |
| 2694 family = concat2 (SYMBOL_NAME (AREF (spec, FONT_FOUNDRY_INDEX)), | |
| 2695 build_string ("-*")); | |
| 2696 else | |
| 2697 family = concat3 (SYMBOL_NAME (AREF (spec, FONT_FOUNDRY_INDEX)), | |
| 2698 build_string ("-"), | |
| 2699 SYMBOL_NAME (AREF (spec, FONT_FAMILY_INDEX))); | |
| 2700 attrs[LFACE_FAMILY_INDEX] = family; | |
| 2701 } | |
| 2702 if (! NILP (AREF (spec, FONT_WEIGHT_INDEX))) | |
| 2703 attrs[LFACE_WEIGHT_INDEX] = FONT_WEIGHT_FOR_FACE (spec); | |
| 2704 if (! NILP (AREF (spec, FONT_SLANT_INDEX))) | |
| 2705 attrs[LFACE_SLANT_INDEX] = FONT_SLANT_FOR_FACE (spec);; | |
| 2706 if (! NILP (AREF (spec, FONT_WIDTH_INDEX))) | |
| 2707 attrs[LFACE_SWIDTH_INDEX] = FONT_WIDTH_FOR_FACE (spec); | |
| 2708 if (! NILP (AREF (spec, FONT_SIZE_INDEX))) | |
| 2709 { | |
| 2710 int point; | |
| 2711 | |
| 2712 if (INTEGERP (AREF (spec, FONT_SIZE_INDEX))) | |
| 2713 { | |
| 2714 Lisp_Object val; | |
| 2715 int dpi = f->resy; | |
| 2716 | |
| 2717 val = Ffont_get (spec, QCdpi); | |
| 2718 if (! NILP (val)) | |
| 2719 dpi = XINT (val); | |
| 2720 point = PIXEL_TO_POINT (XINT (AREF (spec, FONT_SIZE_INDEX)) * 10, | |
| 2721 dpi); | |
| 2722 } | |
| 2723 else if (FLOATP (AREF (spec, FONT_SIZE_INDEX))) | |
| 2724 point = XFLOAT_DATA (AREF (spec, FONT_SIZE_INDEX)) * 10; | |
| 2725 attrs[LFACE_HEIGHT_INDEX] = make_number (point); | |
| 2726 } | |
| 90400 | 2727 } |
| 2728 | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2729 |
| 94926 | 2730 /* Return a font-entity satisfying SPEC and best matching with face's |
| 2731 font related attributes in ATTRS. C, if not negative, is a | |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2732 character that the entity must support. */ |
| 90400 | 2733 |
| 2734 Lisp_Object | |
| 94926 | 2735 font_find_for_lface (f, attrs, spec, c) |
| 90400 | 2736 FRAME_PTR f; |
| 94926 | 2737 Lisp_Object *attrs; |
| 90400 | 2738 Lisp_Object spec; |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2739 int c; |
| 90400 | 2740 { |
| 94926 | 2741 Lisp_Object frame, entities, val, props[FONT_REGISTRY_INDEX + 1] ; |
| 2742 Lisp_Object size; | |
|
91353
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
2743 int i, result; |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2744 |
| 94926 | 2745 if (c >= 0) |
| 2746 { | |
| 2747 Lisp_Object registry = AREF (spec, FONT_REGISTRY_INDEX); | |
| 2748 struct charset *encoding, *repertory; | |
| 2749 | |
| 2750 if (font_registry_charsets (registry, &encoding, &repertory) < 0) | |
| 2751 return Qnil; | |
| 2752 if (repertory) | |
| 2753 { | |
| 2754 if (ENCODE_CHAR (repertory, c) == CHARSET_INVALID_CODE (repertory)) | |
| 2755 return Qnil; | |
| 2756 /* Any font of this registry support C. So, let's | |
| 2757 suppress the further checking. */ | |
| 2758 c = -1; | |
| 2759 } | |
| 2760 else if (c > encoding->max_char) | |
| 2761 return Qnil; | |
| 2762 } | |
| 2763 | |
|
90507
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2764 XSETFRAME (frame, f); |
| 94926 | 2765 size = AREF (spec, FONT_SIZE_INDEX); |
| 2766 ASET (spec, FONT_SIZE_INDEX, Qnil); | |
| 2767 entities = font_list_entities (frame, spec); | |
| 2768 ASET (spec, FONT_SIZE_INDEX, size); | |
| 2769 if (ASIZE (entities) == 0) | |
| 2770 return Qnil; | |
| 2771 if (ASIZE (entities) == 1) | |
|
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2772 { |
| 94926 | 2773 if (c < 0) |
| 2774 return AREF (entities, 0); | |
|
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2775 } |
|
90507
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2776 else |
| 90400 | 2777 { |
|
90507
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2778 /* 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
|
2779 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
|
2780 double pt; |
| 94926 | 2781 for (i = 0; i < FONT_EXTRA_INDEX; i++) |
| 2782 ASET (prefer, i, AREF (spec, i)); | |
|
95013
125a7ecf00db
(font_find_for_lface): Reflect LFACE_FONT in the font
Kenichi Handa <handa@m17n.org>
parents:
94968
diff
changeset
|
2783 if (FONTP (attrs[LFACE_FONT_INDEX])) |
|
125a7ecf00db
(font_find_for_lface): Reflect LFACE_FONT in the font
Kenichi Handa <handa@m17n.org>
parents:
94968
diff
changeset
|
2784 { |
|
125a7ecf00db
(font_find_for_lface): Reflect LFACE_FONT in the font
Kenichi Handa <handa@m17n.org>
parents:
94968
diff
changeset
|
2785 Lisp_Object face_font = attrs[LFACE_FONT_INDEX]; |
|
125a7ecf00db
(font_find_for_lface): Reflect LFACE_FONT in the font
Kenichi Handa <handa@m17n.org>
parents:
94968
diff
changeset
|
2786 |
|
125a7ecf00db
(font_find_for_lface): Reflect LFACE_FONT in the font
Kenichi Handa <handa@m17n.org>
parents:
94968
diff
changeset
|
2787 for (i = 0; i < FONT_EXTRA_INDEX; i++) |
|
125a7ecf00db
(font_find_for_lface): Reflect LFACE_FONT in the font
Kenichi Handa <handa@m17n.org>
parents:
94968
diff
changeset
|
2788 if (NILP (AREF (prefer, i))) |
|
125a7ecf00db
(font_find_for_lface): Reflect LFACE_FONT in the font
Kenichi Handa <handa@m17n.org>
parents:
94968
diff
changeset
|
2789 ASET (prefer, i, AREF (face_font, i)); |
|
125a7ecf00db
(font_find_for_lface): Reflect LFACE_FONT in the font
Kenichi Handa <handa@m17n.org>
parents:
94968
diff
changeset
|
2790 } |
| 94926 | 2791 if (NILP (AREF (prefer, FONT_FAMILY_INDEX))) |
| 2792 font_parse_family_registry (attrs[LFACE_FAMILY_INDEX], Qnil, prefer); | |
| 2793 if (NILP (AREF (prefer, FONT_WEIGHT_INDEX))) | |
| 2794 FONT_SET_STYLE (prefer, FONT_WEIGHT_INDEX, attrs[LFACE_WEIGHT_INDEX]); | |
| 2795 if (NILP (AREF (prefer, FONT_SLANT_INDEX))) | |
| 2796 FONT_SET_STYLE (prefer, FONT_SLANT_INDEX, attrs[LFACE_SLANT_INDEX]); | |
| 2797 if (NILP (AREF (prefer, FONT_WIDTH_INDEX))) | |
| 2798 FONT_SET_STYLE (prefer, FONT_WIDTH_INDEX, attrs[LFACE_SWIDTH_INDEX]); | |
| 2799 if (INTEGERP (size)) | |
| 2800 ASET (prefer, FONT_SIZE_INDEX, size); | |
| 2801 else if (FLOATP (size)) | |
| 2802 ASET (prefer, FONT_SIZE_INDEX, make_number (font_pixel_size (f, spec))); | |
| 2803 else | |
| 2804 { | |
| 2805 double pt = XINT (attrs[LFACE_HEIGHT_INDEX]); | |
| 2806 int pixel_size = POINT_TO_PIXEL (pt / 10, f->resy); | |
| 2807 ASET (prefer, FONT_SIZE_INDEX, make_number (pixel_size)); | |
| 2808 } | |
| 2809 ASET (spec, FONT_SIZE_INDEX, Qnil); | |
| 2810 entities = font_sort_entites (entities, prefer, frame, spec, c < 0); | |
| 2811 ASET (spec, FONT_SIZE_INDEX, size); | |
| 90400 | 2812 } |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2813 if (c < 0) |
| 94926 | 2814 return entities; |
| 2815 | |
| 2816 for (i = 0; i < ASIZE (entities); i++) | |
| 2817 { | |
| 2818 int j; | |
| 2819 | |
| 2820 val = AREF (entities, i); | |
| 2821 if (i > 0) | |
| 2822 { | |
| 2823 for (j = FONT_FOUNDRY_INDEX; j <= FONT_REGISTRY_INDEX; j++) | |
| 2824 if (! EQ (AREF (val, j), props[j])) | |
| 2825 break; | |
| 2826 if (j > FONT_REGISTRY_INDEX) | |
| 2827 continue; | |
| 2828 } | |
| 2829 for (j = FONT_FOUNDRY_INDEX; j <= FONT_REGISTRY_INDEX; j++) | |
| 2830 props[j] = AREF (val, j); | |
| 2831 result = font_has_char (f, val, c); | |
| 2832 if (result > 0) | |
| 2833 return val; | |
| 2834 if (result == 0) | |
| 2835 return Qnil; | |
| 2836 val = font_open_for_lface (f, val, attrs, spec); | |
| 2837 if (NILP (val)) | |
| 2838 continue; | |
| 2839 result = font_has_char (f, val, c); | |
| 2840 font_close_object (f, val); | |
| 2841 if (result > 0) | |
| 2842 return AREF (entities, i); | |
| 2843 } | |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2844 return Qnil; |
| 90400 | 2845 } |
| 2846 | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2847 |
| 90400 | 2848 Lisp_Object |
| 94926 | 2849 font_open_for_lface (f, entity, attrs, spec) |
| 90400 | 2850 FRAME_PTR f; |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2851 Lisp_Object entity; |
| 94926 | 2852 Lisp_Object *attrs; |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2853 Lisp_Object spec; |
| 90400 | 2854 { |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2855 int size; |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2856 |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2857 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
|
2858 size = XINT (AREF (spec, FONT_SIZE_INDEX)); |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2859 else |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2860 { |
| 94926 | 2861 double pt = XINT (attrs[LFACE_HEIGHT_INDEX]); |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2862 |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2863 pt /= 10; |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2864 size = POINT_TO_PIXEL (pt, f->resy); |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2865 } |
| 90400 | 2866 return font_open_entity (f, entity, size); |
| 2867 } | |
| 2868 | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2869 |
| 94926 | 2870 /* Find a font satisfying SPEC and best matching with face's |
| 2871 attributes in ATTRS on FRAME, and return the opened | |
| 2872 font-object. */ | |
| 2873 | |
| 2874 Lisp_Object | |
| 2875 font_load_for_lface (f, attrs, spec) | |
| 90400 | 2876 FRAME_PTR f; |
| 94926 | 2877 Lisp_Object *attrs, spec; |
| 90400 | 2878 { |
| 94926 | 2879 Lisp_Object entity; |
| 2880 | |
| 2881 entity = font_find_for_lface (f, attrs, spec, -1); | |
| 2882 if (NILP (entity)) | |
|
91350
9673276f310c
(font_load_for_face): Handle the case that the font in
Kenichi Handa <handa@m17n.org>
parents:
91337
diff
changeset
|
2883 { |
| 94926 | 2884 /* No font is listed for SPEC, but each font-backend may have |
| 2885 the different criteria about "font matching". So, try | |
| 2886 it. */ | |
| 2887 entity = font_matching_entity (f, attrs, spec); | |
| 2888 if (NILP (entity)) | |
| 2889 return Qnil; | |
|
91350
9673276f310c
(font_load_for_face): Handle the case that the font in
Kenichi Handa <handa@m17n.org>
parents:
91337
diff
changeset
|
2890 } |
| 94926 | 2891 return font_open_for_lface (f, entity, attrs, spec); |
| 90400 | 2892 } |
| 2893 | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2894 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2895 /* 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
|
2896 |
| 90400 | 2897 void |
| 2898 font_prepare_for_face (f, face) | |
| 2899 FRAME_PTR f; | |
| 2900 struct face *face; | |
| 2901 { | |
| 94926 | 2902 if (face->font->driver->prepare_face) |
| 2903 face->font->driver->prepare_face (f, face); | |
| 90400 | 2904 } |
| 2905 | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2906 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2907 /* 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
|
2908 |
| 90400 | 2909 void |
| 2910 font_done_for_face (f, face) | |
| 2911 FRAME_PTR f; | |
| 2912 struct face *face; | |
| 2913 { | |
| 94926 | 2914 if (face->font->driver->done_face) |
| 2915 face->font->driver->done_face (f, face); | |
| 90400 | 2916 face->extra = NULL; |
| 2917 } | |
| 2918 | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2919 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2920 /* 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
|
2921 is found, return Qnil. */ |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2922 |
| 90400 | 2923 Lisp_Object |
| 2924 font_open_by_name (f, name) | |
| 2925 FRAME_PTR f; | |
| 2926 char *name; | |
| 2927 { | |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2928 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
|
2929 Lisp_Object spec, prefer, size, entity, entity_list; |
| 90400 | 2930 Lisp_Object frame; |
|
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2931 int i; |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2932 int pixel_size; |
| 90400 | 2933 |
| 2934 XSETFRAME (frame, f); | |
|
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2935 |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2936 args[0] = QCname; |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2937 args[1] = make_unibyte_string (name, strlen (name)); |
|
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2938 spec = Ffont_spec (2, args); |
|
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2939 prefer = scratch_font_prefer; |
| 94926 | 2940 for (i = 0; i < FONT_SPEC_MAX; i++) |
| 2941 { | |
| 2942 ASET (prefer, i, AREF (spec, i)); | |
| 2943 if (NILP (AREF (prefer, i)) | |
| 2944 && i >= FONT_WEIGHT_INDEX && i <= FONT_WIDTH_INDEX) | |
| 2945 FONT_SET_STYLE (prefer, i, make_number (100)); | |
| 2946 } | |
|
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2947 size = AREF (spec, FONT_SIZE_INDEX); |
|
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2948 if (NILP (size)) |
|
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2949 pixel_size = 0; |
| 94926 | 2950 else |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2951 { |
| 94926 | 2952 if (INTEGERP (size)) |
| 2953 pixel_size = XINT (size); | |
| 2954 else /* FLOATP (size) */ | |
| 2955 { | |
| 2956 double pt = XFLOAT_DATA (size); | |
| 2957 | |
| 2958 pixel_size = POINT_TO_PIXEL (pt, f->resy); | |
| 2959 } | |
| 2960 if (pixel_size == 0) | |
| 2961 ASET (spec, FONT_SIZE_INDEX, Qnil); | |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2962 } |
|
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2963 if (pixel_size == 0) |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2964 { |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2965 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
|
2966 size = make_number (pixel_size); |
| 94926 | 2967 ASET (prefer, FONT_SIZE_INDEX, size); |
|
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2968 } |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2969 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
|
2970 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
|
2971 |
|
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2972 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
|
2973 if (NILP (entity_list)) |
| 94926 | 2974 entity = font_matching_entity (f, NULL, spec); |
|
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2975 else |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2976 entity = XCAR (entity_list); |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2977 return (NILP (entity) |
|
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
2978 ? Qnil |
|
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2979 : font_open_entity (f, entity, pixel_size)); |
| 90400 | 2980 } |
| 2981 | |
| 2982 | |
| 2983 /* Register font-driver DRIVER. This function is used in two ways. | |
| 2984 | |
|
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
2985 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
|
2986 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
|
2987 (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
|
2988 an available font-driver. |
| 90400 | 2989 |
| 2990 The second is with frame F NULL. In this case, DRIVER is globally | |
| 2991 registered in the variable `font_driver_list'. All font-driver | |
| 2992 implementations must call this function in its syms_of_XXXX | |
| 2993 (e.g. syms_of_xfont). */ | |
| 2994 | |
| 2995 void | |
| 2996 register_font_driver (driver, f) | |
| 2997 struct font_driver *driver; | |
| 2998 FRAME_PTR f; | |
| 2999 { | |
| 3000 struct font_driver_list *root = f ? f->font_driver_list : font_driver_list; | |
| 3001 struct font_driver_list *prev, *list; | |
| 3002 | |
| 3003 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
|
3004 error ("Unusable font driver for a frame: %s", |
| 90400 | 3005 SDATA (SYMBOL_NAME (driver->type))); |
| 3006 | |
| 3007 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
|
3008 if (EQ (list->driver->type, driver->type)) |
| 90400 | 3009 error ("Duplicated font driver: %s", SDATA (SYMBOL_NAME (driver->type))); |
| 3010 | |
| 3011 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
|
3012 list->on = 0; |
| 90400 | 3013 list->driver = driver; |
| 3014 list->next = NULL; | |
| 3015 if (prev) | |
| 3016 prev->next = list; | |
| 3017 else if (f) | |
| 3018 f->font_driver_list = list; | |
| 3019 else | |
| 3020 font_driver_list = list; | |
| 3021 num_font_drivers++; | |
| 3022 } | |
| 3023 | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3024 |
| 90400 | 3025 /* Free font-driver list on frame F. It doesn't free font-drivers |
| 3026 themselves. */ | |
| 3027 | |
| 3028 void | |
| 3029 free_font_driver_list (f) | |
| 3030 FRAME_PTR f; | |
| 3031 { | |
| 3032 while (f->font_driver_list) | |
| 3033 { | |
| 3034 struct font_driver_list *next = f->font_driver_list->next; | |
| 3035 | |
| 3036 free (f->font_driver_list); | |
| 3037 f->font_driver_list = next; | |
| 3038 } | |
| 3039 } | |
| 3040 | |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3041 |
|
91112
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3042 /* 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
|
3043 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
|
3044 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
|
3045 |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3046 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
|
3047 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
|
3048 F. */ |
|
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3049 |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3050 Lisp_Object |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3051 font_update_drivers (f, new_drivers) |
|
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3052 FRAME_PTR f; |
|
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3053 Lisp_Object new_drivers; |
|
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3054 { |
|
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3055 Lisp_Object active_drivers = Qnil; |
|
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3056 struct font_driver_list *list; |
|
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3057 |
|
91112
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3058 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
|
3059 if (list->on) |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3060 { |
|
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3061 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
|
3062 && 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
|
3063 { |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3064 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
|
3065 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
|
3066 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
|
3067 list->on = 0; |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3068 } |
|
91112
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3069 } |
|
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3070 else |
|
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3071 { |
|
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3072 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
|
3073 || ! 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
|
3074 { |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3075 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
|
3076 || 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
|
3077 { |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3078 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
|
3079 list->on = 1; |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3080 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
|
3081 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
|
3082 } |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3083 } |
|
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3084 } |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3085 |
|
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3086 return active_drivers; |
|
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3087 } |
|
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3088 |
|
91112
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3089 int |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3090 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
|
3091 FRAME_PTR f; |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3092 struct font_driver *driver; |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3093 void *data; |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3094 { |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3095 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
|
3096 |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3097 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
|
3098 prev = list, list = list->next) |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3099 if (list->driver == driver) |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3100 break; |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3101 if (! data) |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3102 { |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3103 if (list) |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3104 { |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3105 if (prev) |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3106 prev->next = list->next; |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3107 else |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3108 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
|
3109 free (list); |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3110 } |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3111 return 0; |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3112 } |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3113 |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3114 if (! list) |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3115 { |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3116 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
|
3117 if (! list) |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3118 return -1; |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3119 list->driver = driver; |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3120 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
|
3121 f->font_data_list = list; |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3122 } |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3123 list->data = data; |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3124 return 0; |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3125 } |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3126 |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3127 |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3128 void * |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3129 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
|
3130 FRAME_PTR f; |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3131 struct font_driver *driver; |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3132 { |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3133 struct font_data_list *list; |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3134 |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3135 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
|
3136 if (list->driver == driver) |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3137 break; |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3138 if (! list) |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3139 return NULL; |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3140 return list->data; |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3141 } |
|
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3142 |
|
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3143 |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3144 /* 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
|
3145 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
|
3146 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
|
3147 STRING. */ |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3148 |
| 90541 | 3149 Lisp_Object |
|
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3150 font_at (c, pos, face, w, string) |
| 90541 | 3151 int c; |
| 3152 EMACS_INT pos; | |
| 3153 struct face *face; | |
| 3154 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
|
3155 Lisp_Object string; |
| 90541 | 3156 { |
| 3157 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
|
3158 int multibyte; |
| 94926 | 3159 Lisp_Object font_object; |
|
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3160 |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3161 if (c < 0) |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3162 { |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3163 if (NILP (string)) |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3164 { |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3165 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
|
3166 if (multibyte) |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3167 { |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3168 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
|
3169 |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3170 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
|
3171 } |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3172 else |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3173 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
|
3174 } |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3175 else |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3176 { |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3177 unsigned char *str; |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3178 |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3179 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
|
3180 if (multibyte) |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3181 { |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3182 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
|
3183 |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3184 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
|
3185 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
|
3186 } |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3187 else |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3188 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
|
3189 } |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3190 } |
| 90541 | 3191 |
| 3192 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
|
3193 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
|
3194 return Qnil; |
| 90541 | 3195 if (! face) |
| 3196 { | |
|
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3197 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
|
3198 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
|
3199 |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3200 if (STRINGP (string)) |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3201 face_id = face_at_string_position (w, string, pos, 0, -1, -1, &endptr, |
| 90541 | 3202 DEFAULT_FACE_ID, 0); |
| 3203 else | |
|
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3204 face_id = face_at_buffer_position (w, pos, -1, -1, &endptr, |
| 90541 | 3205 pos + 100, 0); |
| 3206 face = FACE_FROM_ID (f, face_id); | |
| 3207 } | |
|
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3208 if (multibyte) |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3209 { |
|
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3210 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
|
3211 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
|
3212 } |
| 94926 | 3213 if (! face->font) |
| 90541 | 3214 return Qnil; |
| 94926 | 3215 |
| 3216 xassert (font_check_object ((struct font *) face->font)); | |
| 3217 XSETFONT (font_object, face->font); | |
| 3218 return font_object; | |
| 3219 } | |
| 3220 | |
| 3221 | |
| 3222 /* Check how many characters after POS (at most to LIMIT) can be | |
| 3223 displayed by the same font. FACE is the face selected for the | |
| 3224 character as POS on frame F. STRING, if not nil, is the string to | |
| 3225 check instead of the current buffer. | |
| 3226 | |
| 3227 The return value is the position of the character that is displayed | |
| 3228 by the differnt font than that of the character as POS. */ | |
| 3229 | |
| 3230 EMACS_INT | |
| 3231 font_range (pos, limit, face, f, string) | |
| 3232 EMACS_INT pos, limit; | |
| 3233 struct face *face; | |
| 3234 FRAME_PTR f; | |
| 3235 Lisp_Object string; | |
| 3236 { | |
| 3237 int multibyte; | |
| 3238 EMACS_INT pos_byte; | |
| 3239 int c; | |
| 3240 struct font *font; | |
| 3241 int first = 1; | |
| 3242 | |
| 3243 if (NILP (string)) | |
| 3244 { | |
| 3245 multibyte = ! NILP (current_buffer->enable_multibyte_characters); | |
| 3246 pos_byte = CHAR_TO_BYTE (pos); | |
| 3247 } | |
| 3248 else | |
| 3249 { | |
| 3250 multibyte = STRING_MULTIBYTE (string); | |
| 3251 pos_byte = string_char_to_byte (string, pos); | |
| 3252 } | |
| 3253 | |
| 3254 if (! multibyte) | |
| 3255 /* All unibyte character are displayed by the same font. */ | |
| 3256 return limit; | |
| 3257 | |
| 3258 while (pos < limit) | |
| 3259 { | |
| 3260 int face_id; | |
| 3261 | |
| 3262 if (NILP (string)) | |
| 3263 FETCH_CHAR_ADVANCE_NO_CHECK (c, pos, pos_byte); | |
| 3264 else | |
| 3265 FETCH_STRING_CHAR_ADVANCE_NO_CHECK (c, string, pos, pos_byte); | |
| 3266 face_id = FACE_FOR_CHAR (f, face, c, pos, string); | |
| 3267 face = FACE_FROM_ID (f, face_id); | |
| 3268 if (first) | |
| 3269 { | |
| 3270 font = face->font; | |
| 3271 first = 0; | |
| 3272 continue; | |
| 3273 } | |
| 3274 else if (font != face->font) | |
| 3275 { | |
| 3276 pos--; | |
| 3277 break; | |
| 3278 } | |
| 3279 } | |
| 3280 return pos; | |
| 90541 | 3281 } |
| 3282 | |
| 90400 | 3283 |
| 3284 /* Lisp API */ | |
| 3285 | |
| 94926 | 3286 DEFUN ("fontp", Ffontp, Sfontp, 1, 2, 0, |
|
91353
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
3287 doc: /* Return t if OBJECT is a font-spec, font-entity, or font-object. |
| 94926 | 3288 Return nil otherwise. |
| 3289 Optional 2nd argument EXTRA-TYPE, if non-nil, specifies to check | |
| 3290 which kind of font it is. It must be one of `font-spec', `font-entity' | |
| 3291 `font-object'. */) | |
| 3292 (object, extra_type) | |
| 3293 Lisp_Object object, extra_type; | |
| 90400 | 3294 { |
| 94926 | 3295 if (NILP (extra_type)) |
| 3296 return (FONTP (object) ? Qt : Qnil); | |
| 3297 if (EQ (extra_type, Qfont_spec)) | |
| 3298 return (FONT_SPEC_P (object) ? Qt : Qnil); | |
| 3299 if (EQ (extra_type, Qfont_entity)) | |
| 3300 return (FONT_ENTITY_P (object) ? Qt : Qnil); | |
| 3301 if (EQ (extra_type, Qfont_object)) | |
| 3302 return (FONT_OBJECT_P (object) ? Qt : Qnil); | |
| 3303 wrong_type_argument (intern ("font-extra-type"), extra_type); | |
| 90400 | 3304 } |
| 3305 | |
| 3306 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
|
3307 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
|
3308 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3309 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
|
3310 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
|
3311 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3312 `:family', `:weight', `:slant', `:width' |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3313 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3314 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
|
3315 `set-face-attribute'. |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3316 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3317 `:foundry' |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3318 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3319 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
|
3320 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3321 `:adstyle' |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3322 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3323 VALUE must be a string or a symbol specifying the additional |
| 94926 | 3324 typographic style information of a font, e.g. ``sans''. |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3325 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3326 `:registry' |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3327 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3328 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
|
3329 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
|
3330 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3331 `:size' |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3332 |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3333 VALUE must be a non-negative integer or a floating point number |
| 94926 | 3334 specifying the font size. It specifies the font size in pixels |
|
91112
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3335 (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
|
3336 usage: (font-spec ARGS ...) */) |
| 90400 | 3337 (nargs, args) |
| 3338 int nargs; | |
| 3339 Lisp_Object *args; | |
| 3340 { | |
| 94926 | 3341 Lisp_Object spec = font_make_spec (); |
| 90400 | 3342 int i; |
| 3343 | |
| 3344 for (i = 0; i < nargs; i += 2) | |
| 3345 { | |
| 3346 Lisp_Object key = args[i], val = args[i + 1]; | |
| 3347 | |
| 94926 | 3348 if (EQ (key, QCname)) |
| 3349 { | |
| 3350 CHECK_STRING (val); | |
| 3351 font_parse_name ((char *) SDATA (val), spec); | |
| 3352 font_put_extra (spec, key, val); | |
| 3353 } | |
| 3354 else if (EQ (key, QCfamily)) | |
| 3355 { | |
| 3356 CHECK_STRING (val); | |
| 3357 font_parse_family_registry (val, Qnil, spec); | |
| 3358 } | |
| 90400 | 3359 else |
|
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
3360 { |
| 94926 | 3361 int idx = get_font_prop_index (key); |
| 3362 | |
| 3363 if (idx >= 0) | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
3364 { |
| 94926 | 3365 val = font_prop_validate (idx, Qnil, val); |
| 3366 if (idx < FONT_EXTRA_INDEX) | |
| 3367 ASET (spec, idx, val); | |
| 3368 else | |
| 3369 font_put_extra (spec, key, val); | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
3370 } |
| 94926 | 3371 else |
| 3372 font_put_extra (spec, key, font_prop_validate (0, key, val)); | |
|
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
3373 } |
|
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3374 } |
| 90400 | 3375 return spec; |
| 3376 } | |
| 3377 | |
| 94926 | 3378 DEFUN ("copy-font-spec", Fcopy_font_spec, Scopy_font_spec, 1, 1, 0, |
| 3379 doc: /* Return a copy of FONT as a font-spec. */) | |
| 3380 (font) | |
| 3381 Lisp_Object font; | |
| 3382 { | |
| 3383 Lisp_Object new_spec, tail, extra; | |
| 3384 int i; | |
| 3385 | |
| 3386 CHECK_FONT (font); | |
| 3387 new_spec = font_make_spec (); | |
| 3388 for (i = 1; i < FONT_EXTRA_INDEX; i++) | |
| 3389 ASET (new_spec, i, AREF (font, i)); | |
| 3390 extra = Qnil; | |
| 3391 for (tail = AREF (font, FONT_EXTRA_INDEX); CONSP (tail); tail = XCDR (tail)) | |
| 3392 { | |
| 3393 if (! EQ (XCAR (XCAR (tail)), QCfont_entity)) | |
| 3394 extra = Fcons (Fcons (XCAR (XCAR (tail)), XCDR (XCAR (tail))), extra); | |
| 3395 } | |
| 3396 ASET (new_spec, FONT_EXTRA_INDEX, extra); | |
| 3397 return new_spec; | |
| 3398 } | |
| 3399 | |
| 3400 DEFUN ("merge-font-spec", Fmerge_font_spec, Smerge_font_spec, 2, 2, 0, | |
| 3401 doc: /* Merge font-specs FROM and TO, and return a new font-spec. | |
| 3402 Every specified properties in FROM override the corresponding | |
| 3403 properties in TO. */) | |
| 3404 (from, to) | |
| 3405 Lisp_Object from, to; | |
| 3406 { | |
| 3407 Lisp_Object extra, tail; | |
| 3408 int i; | |
| 3409 | |
| 3410 CHECK_FONT (from); | |
| 3411 CHECK_FONT (to); | |
| 3412 to = Fcopy_font_spec (to); | |
| 3413 for (i = 0; i < FONT_EXTRA_INDEX; i++) | |
| 3414 ASET (to, i, AREF (from, i)); | |
| 3415 extra = AREF (to, FONT_EXTRA_INDEX); | |
| 3416 for (tail = AREF (from, FONT_EXTRA_INDEX); CONSP (tail); tail = XCDR (tail)) | |
| 3417 if (! EQ (XCAR (XCAR (tail)), Qfont_entity)) | |
| 3418 { | |
| 3419 Lisp_Object slot = assq_no_quit (XCAR (XCAR (tail)), extra); | |
| 3420 | |
| 3421 if (! NILP (slot)) | |
| 3422 XSETCDR (slot, XCDR (XCAR (tail))); | |
| 3423 else | |
| 3424 extra = Fcons (Fcons (XCAR (XCAR (tail)), XCDR (XCAR (tail))), extra); | |
| 3425 } | |
| 3426 ASET (to, FONT_EXTRA_INDEX, extra); | |
| 3427 return to; | |
| 3428 } | |
| 90400 | 3429 |
| 3430 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
|
3431 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
|
3432 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
|
3433 (font, key) |
|
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3434 Lisp_Object font, key; |
| 90400 | 3435 { |
| 94926 | 3436 int idx; |
| 3437 | |
| 3438 CHECK_FONT (font); | |
| 3439 CHECK_SYMBOL (key); | |
| 3440 | |
| 3441 idx = get_font_prop_index (key); | |
| 3442 if (idx >= 0 && idx < FONT_EXTRA_INDEX) | |
| 90400 | 3443 return AREF (font, idx); |
| 94926 | 3444 return Fcdr (Fassq (key, AREF (font, FONT_EXTRA_INDEX))); |
| 90400 | 3445 } |
| 3446 | |
| 3447 | |
| 3448 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
|
3449 doc: /* Set one property of FONT-SPEC: give property PROP value VAL. */) |
| 90400 | 3450 (font_spec, prop, val) |
| 3451 Lisp_Object font_spec, prop, val; | |
| 3452 { | |
| 94926 | 3453 int idx; |
| 90400 | 3454 Lisp_Object extra, slot; |
| 3455 | |
| 3456 CHECK_FONT_SPEC (font_spec); | |
| 94926 | 3457 idx = get_font_prop_index (prop); |
| 3458 if (idx >= 0 && idx < FONT_EXTRA_INDEX) | |
| 3459 { | |
| 3460 if (idx == FONT_FAMILY_INDEX | |
| 3461 && STRINGP (val)) | |
| 3462 font_parse_family_registry (val, Qnil, font_spec); | |
| 3463 else | |
| 3464 ASET (font_spec, idx, font_prop_validate (idx, Qnil, val)); | |
| 3465 } | |
| 90400 | 3466 else |
| 94926 | 3467 font_put_extra (font_spec, prop, font_prop_validate (0, prop, val)); |
| 90400 | 3468 return val; |
| 3469 } | |
| 3470 | |
| 3471 DEFUN ("list-fonts", Flist_fonts, Slist_fonts, 1, 4, 0, | |
| 3472 doc: /* List available fonts matching FONT-SPEC on the current frame. | |
| 3473 Optional 2nd argument FRAME specifies the target frame. | |
| 3474 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
|
3475 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
|
3476 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
|
3477 how they are close to PREFER. */) |
| 90400 | 3478 (font_spec, frame, num, prefer) |
| 3479 Lisp_Object font_spec, frame, num, prefer; | |
| 3480 { | |
| 3481 Lisp_Object vec, list, tail; | |
| 3482 int n = 0, i, len; | |
| 3483 | |
| 3484 if (NILP (frame)) | |
| 3485 frame = selected_frame; | |
| 3486 CHECK_LIVE_FRAME (frame); | |
| 94926 | 3487 CHECK_FONT_SPEC (font_spec); |
| 90400 | 3488 if (! NILP (num)) |
| 3489 { | |
| 3490 CHECK_NUMBER (num); | |
| 3491 n = XINT (num); | |
| 3492 if (n <= 0) | |
| 3493 return Qnil; | |
| 3494 } | |
| 3495 if (! NILP (prefer)) | |
| 94926 | 3496 CHECK_FONT_SPEC (prefer); |
| 90400 | 3497 |
| 3498 vec = font_list_entities (frame, font_spec); | |
| 3499 len = ASIZE (vec); | |
| 3500 if (len == 0) | |
| 3501 return Qnil; | |
| 3502 if (len == 1) | |
| 3503 return Fcons (AREF (vec, 0), Qnil); | |
| 3504 | |
| 3505 if (! NILP (prefer)) | |
| 94926 | 3506 vec = font_sort_entites (vec, prefer, frame, font_spec, 0); |
| 90400 | 3507 |
| 3508 list = tail = Fcons (AREF (vec, 0), Qnil); | |
| 3509 if (n == 0 || n > len) | |
| 3510 n = len; | |
| 3511 for (i = 1; i < n; i++) | |
| 3512 { | |
| 3513 Lisp_Object val = Fcons (AREF (vec, i), Qnil); | |
| 3514 | |
| 3515 XSETCDR (tail, val); | |
| 3516 tail = val; | |
| 3517 } | |
| 3518 return list; | |
| 3519 } | |
| 3520 | |
| 94926 | 3521 DEFUN ("font-family-list", Ffont_family_list, Sfont_family_list, 0, 1, 0, |
| 90400 | 3522 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
|
3523 Optional argument FRAME specifies the target frame. */) |
| 90400 | 3524 (frame) |
| 3525 Lisp_Object frame; | |
| 3526 { | |
| 3527 FRAME_PTR f; | |
| 3528 struct font_driver_list *driver_list; | |
| 3529 Lisp_Object list; | |
| 3530 | |
| 3531 if (NILP (frame)) | |
| 3532 frame = selected_frame; | |
| 3533 CHECK_LIVE_FRAME (frame); | |
| 3534 f = XFRAME (frame); | |
| 3535 list = Qnil; | |
| 3536 for (driver_list = f->font_driver_list; driver_list; | |
| 3537 driver_list = driver_list->next) | |
| 3538 if (driver_list->driver->list_family) | |
| 3539 { | |
| 3540 Lisp_Object val = driver_list->driver->list_family (frame); | |
| 3541 | |
| 3542 if (NILP (list)) | |
| 3543 list = val; | |
| 3544 else | |
| 3545 { | |
| 3546 Lisp_Object tail = list; | |
| 3547 | |
| 3548 for (; CONSP (val); val = XCDR (val)) | |
| 3549 if (NILP (Fmemq (XCAR (val), tail))) | |
| 3550 list = Fcons (XCAR (val), list); | |
| 3551 } | |
| 3552 } | |
| 3553 return list; | |
| 3554 } | |
| 3555 | |
| 3556 DEFUN ("find-font", Ffind_font, Sfind_font, 1, 2, 0, | |
| 3557 doc: /* Return a font-entity matching with FONT-SPEC on the current frame. | |
| 3558 Optional 2nd argument FRAME, if non-nil, specifies the target frame. */) | |
| 3559 (font_spec, frame) | |
| 3560 Lisp_Object font_spec, frame; | |
| 3561 { | |
| 3562 Lisp_Object val = Flist_fonts (font_spec, frame, make_number (1), Qnil); | |
| 3563 | |
| 3564 if (CONSP (val)) | |
| 3565 val = XCAR (val); | |
| 3566 return val; | |
| 3567 } | |
| 3568 | |
| 3569 DEFUN ("font-xlfd-name", Ffont_xlfd_name, Sfont_xlfd_name, 1, 1, 0, | |
| 3570 doc: /* Return XLFD name of FONT. | |
| 3571 FONT is a font-spec, font-entity, or font-object. | |
| 3572 If the name is too long for XLFD (maximum 255 chars), return nil. */) | |
| 3573 (font) | |
| 3574 Lisp_Object font; | |
| 3575 { | |
| 3576 char name[256]; | |
| 3577 int pixel_size = 0; | |
| 3578 | |
| 94926 | 3579 CHECK_FONT (font); |
| 3580 | |
| 3581 if (FONT_OBJECT_P (font)) | |
| 90400 | 3582 { |
| 94926 | 3583 Lisp_Object font_name = AREF (font, FONT_NAME_INDEX); |
| 3584 | |
| 3585 if (STRINGP (font_name) | |
| 3586 && SDATA (font_name)[0] == '-') | |
| 3587 return font_name; | |
| 3588 pixel_size = XFONT_OBJECT (font)->pixel_size; | |
| 90400 | 3589 } |
| 3590 if (font_unparse_xlfd (font, pixel_size, name, 256) < 0) | |
| 3591 return Qnil; | |
| 3592 return build_string (name); | |
| 3593 } | |
| 3594 | |
| 3595 DEFUN ("clear-font-cache", Fclear_font_cache, Sclear_font_cache, 0, 0, 0, | |
| 3596 doc: /* Clear font cache. */) | |
| 3597 () | |
| 3598 { | |
| 3599 Lisp_Object list, frame; | |
| 3600 | |
| 3601 FOR_EACH_FRAME (list, frame) | |
| 3602 { | |
| 3603 FRAME_PTR f = XFRAME (frame); | |
| 3604 struct font_driver_list *driver_list = f->font_driver_list; | |
| 3605 | |
| 3606 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
|
3607 if (driver_list->on) |
|
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3608 { |
|
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3609 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
|
3610 Lisp_Object val; |
|
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3611 |
|
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3612 val = XCDR (cache); |
| 91909 | 3613 while (! NILP (val) |
| 3614 && ! 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
|
3615 val = XCDR (val); |
| 91909 | 3616 xassert (! NILP (val)); |
|
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3617 val = XCDR (XCAR (val)); |
|
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3618 if (XINT (XCAR (val)) == 0) |
|
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3619 { |
|
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3620 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
|
3621 XSETCDR (cache, XCDR (val)); |
|
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3622 } |
|
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3623 } |
| 90400 | 3624 } |
| 3625 | |
| 3626 return Qnil; | |
| 3627 } | |
| 3628 | |
| 3629 DEFUN ("internal-set-font-style-table", Finternal_set_font_style_table, | |
| 94926 | 3630 Sinternal_set_font_style_table, 3, 3, 0, |
| 3631 doc: /* Setup font style table from WEIGHT, SLANT, and WIDTH tables. | |
| 3632 WEIGHT, SLANT, WIDTH must be `font-weight-table', `font-slant-table', | |
| 3633 `font-width-table' respectivly. | |
| 3634 This function is called after those tables are initialized. */) | |
| 3635 (weight, slant, width) | |
| 3636 Lisp_Object weight, slant, width; | |
| 90400 | 3637 { |
| 94926 | 3638 Lisp_Object tables[3]; |
| 3639 int i; | |
| 3640 | |
| 3641 tables[0] = weight, tables[1] = slant, tables[2] = width; | |
| 3642 | |
| 3643 font_style_table = Fmake_vector (make_number (3), Qnil); | |
| 3644 /* In the following loop, we don't use XCAR and XCDR until assuring | |
| 3645 the argument is a cons cell so that the error in the tables can | |
| 3646 be detected. */ | |
| 3647 for (i = 0; i < 3; i++) | |
| 90400 | 3648 { |
| 94926 | 3649 Lisp_Object tail, elt, list, val; |
| 3650 | |
| 3651 for (tail = tables[i], list = Qnil; CONSP (tail); tail = XCDR (tail)) | |
| 3652 { | |
| 3653 int numeric = -1; | |
| 3654 | |
| 3655 elt = Fcar (tail); | |
| 3656 CHECK_SYMBOL (Fcar (elt)); | |
| 3657 val = Fcons (XCAR (elt), Qnil); | |
| 3658 elt = XCDR (elt); | |
| 3659 CHECK_NATNUM (Fcar (elt)); | |
| 3660 if (numeric >= XINT (XCAR (elt))) | |
| 3661 error ("Numeric values not unique nor sorted in %s", | |
| 3662 (i == 0 ? "font-weight-table" | |
| 3663 : i == 1 ? "font-slant-table" | |
| 3664 : "font-width-table")); | |
| 3665 numeric = XINT (XCAR (elt)); | |
| 3666 XSETCDR (val, XCAR (elt)); | |
| 3667 list = Fcons (val, list); | |
| 3668 for (elt = XCDR (elt); CONSP (elt); elt = XCDR (elt)) | |
| 3669 { | |
| 3670 val = XCAR (elt); | |
| 3671 CHECK_SYMBOL (val); | |
| 3672 list = Fcons (Fcons (XCAR (elt), make_number (numeric)), list); | |
| 3673 } | |
| 3674 } | |
| 3675 list = Fnreverse (list); | |
| 3676 ASET (font_style_table, i, Fvconcat (1, &list)); | |
| 90400 | 3677 } |
| 94926 | 3678 |
| 90400 | 3679 return Qnil; |
| 3680 } | |
|
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3681 |
|
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3682 /* 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
|
3683 |
| 90400 | 3684 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
|
3685 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
|
3686 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
|
3687 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3688 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
|
3689 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
|
3690 [ HEADER GLYPH ... ] |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3691 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
|
3692 [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
|
3693 where |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3694 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
|
3695 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
|
3696 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
|
3697 [ 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
|
3698 [ [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
|
3699 where |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3700 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
|
3701 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
|
3702 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
|
3703 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
|
3704 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
|
3705 WADJUST is the adjustment to the normal width of the glyph. */) |
| 90400 | 3706 (font_object, num) |
| 3707 Lisp_Object font_object, num; | |
| 3708 { | |
| 3709 Lisp_Object gstring, g; | |
| 3710 int len; | |
| 3711 int i; | |
| 3712 | |
| 3713 if (! NILP (font_object)) | |
| 3714 CHECK_FONT_OBJECT (font_object); | |
| 3715 CHECK_NATNUM (num); | |
| 3716 | |
| 3717 len = XINT (num) + 1; | |
| 3718 gstring = Fmake_vector (make_number (len), Qnil); | |
| 3719 g = Fmake_vector (make_number (6), Qnil); | |
| 3720 ASET (g, 0, font_object); | |
| 3721 ASET (gstring, 0, g); | |
| 3722 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
|
3723 ASET (gstring, i, Fmake_vector (make_number (10), Qnil)); |
| 90400 | 3724 return gstring; |
| 3725 } | |
| 3726 | |
| 3727 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
|
3728 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
|
3729 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
|
3730 If optional 5rd argument OBJECT is non-nil, it is a buffer or a string from |
| 90400 | 3731 where to extract characters. |
| 3732 FONT-OBJECT may be nil if GSTRING already already contains one. */) | |
| 3733 (gstring, font_object, start, end, object) | |
| 3734 Lisp_Object gstring, font_object, start, end, object; | |
| 3735 { | |
| 3736 int len, i, c; | |
| 3737 unsigned code; | |
| 3738 struct font *font; | |
| 3739 | |
| 3740 CHECK_VECTOR (gstring); | |
| 3741 if (NILP (font_object)) | |
| 90541 | 3742 font_object = LGSTRING_FONT (gstring); |
| 94926 | 3743 font = XFONT_OBJECT (font_object); |
| 90400 | 3744 |
| 3745 if (STRINGP (object)) | |
| 3746 { | |
| 3747 const unsigned char *p; | |
| 3748 | |
| 3749 CHECK_NATNUM (start); | |
| 3750 CHECK_NATNUM (end); | |
| 3751 if (XINT (start) > XINT (end) | |
| 3752 || XINT (end) > ASIZE (object) | |
| 90541 | 3753 || 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
|
3754 args_out_of_range_3 (object, start, end); |
| 90400 | 3755 |
| 3756 len = XINT (end) - XINT (start); | |
| 3757 p = SDATA (object) + string_char_to_byte (object, XINT (start)); | |
| 3758 for (i = 0; i < len; i++) | |
| 3759 { | |
| 3760 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
|
3761 /* 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
|
3762 MOST_POSITIVE_FIXNUM below. */ |
|
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3763 EMACS_INT cod; |
| 90400 | 3764 |
| 3765 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
|
3766 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
|
3767 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
|
3768 break; |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3769 LGLYPH_SET_FROM (g, i); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3770 LGLYPH_SET_TO (g, i); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3771 LGLYPH_SET_CHAR (g, c); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3772 LGLYPH_SET_CODE (g, code); |
| 90400 | 3773 } |
| 3774 } | |
| 3775 else | |
| 3776 { | |
| 3777 int pos, pos_byte; | |
| 3778 | |
| 3779 if (! NILP (object)) | |
| 3780 Fset_buffer (object); | |
| 3781 validate_region (&start, &end); | |
| 90541 | 3782 if (XINT (end) - XINT (start) > LGSTRING_LENGTH (gstring)) |
| 90400 | 3783 args_out_of_range (start, end); |
| 3784 len = XINT (end) - XINT (start); | |
| 3785 pos = XINT (start); | |
| 3786 pos_byte = CHAR_TO_BYTE (pos); | |
| 3787 for (i = 0; i < len; i++) | |
| 3788 { | |
| 3789 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
|
3790 /* 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
|
3791 MOST_POSITIVE_FIXNUM below. */ |
|
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3792 EMACS_INT cod; |
| 90400 | 3793 |
| 3794 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
|
3795 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
|
3796 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
|
3797 break; |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3798 LGLYPH_SET_FROM (g, i); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3799 LGLYPH_SET_TO (g, i); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3800 LGLYPH_SET_CHAR (g, c); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3801 LGLYPH_SET_CODE (g, code); |
| 90400 | 3802 } |
| 3803 } | |
|
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3804 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
|
3805 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
|
3806 return Qnil; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3807 } |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3808 |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3809 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
|
3810 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
|
3811 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
|
3812 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
|
3813 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
|
3814 FONT-OBJECT. */) |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3815 (from, to, font_object, string) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3816 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
|
3817 { |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3818 struct font *font; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3819 struct font_metrics metrics; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3820 EMACS_INT start, end; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3821 Lisp_Object gstring, n; |
| 94926 | 3822 int len, i; |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3823 |
|
92183
275e5e980fc4
If the font driver doesn't have `shape' function, return Qnil.
Kenichi Handa <handa@m17n.org>
parents:
92113
diff
changeset
|
3824 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
|
3825 return Qnil; |
| 94926 | 3826 font = XFONT_OBJECT (font_object); |
|
92183
275e5e980fc4
If the font driver doesn't have `shape' function, return Qnil.
Kenichi Handa <handa@m17n.org>
parents:
92113
diff
changeset
|
3827 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
|
3828 return Qnil; |
|
275e5e980fc4
If the font driver doesn't have `shape' function, return Qnil.
Kenichi Handa <handa@m17n.org>
parents:
92113
diff
changeset
|
3829 |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3830 if (NILP (string)) |
| 90541 | 3831 { |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3832 validate_region (&from, &to); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3833 start = XFASTINT (from); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3834 end = XFASTINT (to); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3835 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
|
3836 } |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3837 else |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3838 { |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3839 CHECK_STRING (string); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3840 start = XINT (from); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3841 end = XINT (to); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3842 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
|
3843 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
|
3844 } |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3845 |
|
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3846 len = end - start; |
|
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3847 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
|
3848 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
|
3849 |
|
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3850 /* 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
|
3851 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
|
3852 { |
|
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3853 Lisp_Object args[2]; |
|
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3854 |
|
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3855 n = font->driver->shape (gstring); |
|
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3856 if (INTEGERP (n)) |
|
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3857 break; |
|
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3858 args[0] = gstring; |
|
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3859 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
|
3860 gstring = Fvconcat (2, args); |
|
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3861 } |
|
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3862 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
|
3863 return Qnil; |
|
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3864 len = XINT (n); |
|
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3865 |
|
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3866 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
|
3867 { |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3868 Lisp_Object gstr; |
| 90541 | 3869 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
|
3870 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
|
3871 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
|
3872 int j, k; |
|
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3873 int need_composition = 0; |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3874 |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3875 metrics.lbearing = LGLYPH_LBEARING (g); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3876 metrics.rbearing = LGLYPH_RBEARING (g); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3877 metrics.ascent = LGLYPH_ASCENT (g); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3878 metrics.descent = LGLYPH_DESCENT (g); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3879 if (NILP (LGLYPH_ADJUSTMENT (g))) |
|
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3880 { |
|
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3881 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
|
3882 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
|
3883 need_composition = 1; |
|
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3884 } |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3885 else |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3886 { |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3887 metrics.width = LGLYPH_WADJUST (g); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3888 metrics.lbearing += LGLYPH_XOFF (g); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3889 metrics.rbearing += LGLYPH_XOFF (g); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3890 metrics.ascent -= LGLYPH_YOFF (g); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3891 metrics.descent += LGLYPH_YOFF (g); |
|
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3892 need_composition = 1; |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3893 } |
|
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3894 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
|
3895 { |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3896 int x; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3897 |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3898 g = LGSTRING_GLYPH (gstring, j); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3899 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
|
3900 break; |
|
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3901 need_composition = 1; |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3902 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
|
3903 if (metrics.lbearing > x) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3904 metrics.lbearing = x; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3905 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
|
3906 if (metrics.rbearing < x) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3907 metrics.rbearing = x; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3908 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
|
3909 if (metrics.ascent < x) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3910 metrics.ascent = x; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3911 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
|
3912 if (metrics.descent < x) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3913 metrics.descent = x; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3914 if (NILP (LGLYPH_ADJUSTMENT (g))) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3915 metrics.width += LGLYPH_WIDTH (g); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3916 else |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3917 metrics.width += LGLYPH_WADJUST (g); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3918 } |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3919 |
|
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3920 if (need_composition) |
|
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3921 { |
|
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3922 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
|
3923 LGSTRING_SET_WIDTH (gstr, metrics.width); |
|
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3924 LGSTRING_SET_LBEARING (gstr, metrics.lbearing); |
|
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3925 LGSTRING_SET_RBEARING (gstr, metrics.rbearing); |
|
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3926 LGSTRING_SET_ASCENT (gstr, metrics.ascent); |
|
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3927 LGSTRING_SET_DESCENT (gstr, metrics.descent); |
|
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3928 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
|
3929 { |
|
0afaa00ae397
(Ffont_shape_text): If the font driver doesn't have a
Kenichi Handa <handa@m17n.org>
parents:
91273
diff
changeset
|
3930 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
|
3931 |
|
0afaa00ae397
(Ffont_shape_text): If the font driver doesn't have a
Kenichi Handa <handa@m17n.org>
parents:
91273
diff
changeset
|
3932 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
|
3933 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
|
3934 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
|
3935 } |
|
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3936 from = make_number (start + this_from); |
|
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3937 to = make_number (start + this_to); |
|
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3938 if (NILP (string)) |
|
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3939 Fcompose_region_internal (from, to, gstr, Qnil); |
|
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3940 else |
|
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3941 Fcompose_string_internal (string, from, to, gstr, Qnil); |
|
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3942 } |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3943 else |
|
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
3944 i = j; |
| 90541 | 3945 } |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3946 |
|
91192
bcad98389aeb
(Ffont_shape_text): Fix the return value.
Kenichi Handa <handa@m17n.org>
parents:
91174
diff
changeset
|
3947 return to; |
| 90400 | 3948 } |
| 3949 | |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3950 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
|
3951 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
|
3952 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
|
3953 (SCRIPT LANGSYS GSUB GPOS) |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3954 where |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3955 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
|
3956 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
|
3957 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
|
3958 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3959 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
|
3960 |
|
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3961 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
|
3962 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
|
3963 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
|
3964 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
|
3965 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
|
3966 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3967 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
|
3968 the glyph-string GSTRING-IN. |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3969 |
|
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3970 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
|
3971 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
|
3972 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
|
3973 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3974 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
|
3975 the value is 0. |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3976 |
|
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3977 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
|
3978 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
|
3979 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3980 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
|
3981 glyph-string. */) |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3982 (otf_features, gstring_in, from, to, gstring_out, index) |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3983 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
|
3984 { |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3985 Lisp_Object font_object = LGSTRING_FONT (gstring_in); |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3986 Lisp_Object val; |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3987 struct font *font; |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3988 int len, num; |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3989 |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3990 check_otf_features (otf_features); |
| 94926 | 3991 CHECK_FONT_OBJECT (font_object); |
| 3992 font = XFONT_OBJECT (font_object); | |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3993 if (! font->driver->otf_drive) |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3994 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
|
3995 SDATA (SYMBOL_NAME (font->driver->type))); |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3996 CHECK_CONS (otf_features); |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3997 CHECK_SYMBOL (XCAR (otf_features)); |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3998 val = XCDR (otf_features); |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3999 CHECK_SYMBOL (XCAR (val)); |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4000 val = XCDR (otf_features); |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4001 if (! NILP (val)) |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4002 CHECK_CONS (val); |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4003 len = check_gstring (gstring_in); |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4004 CHECK_VECTOR (gstring_out); |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4005 CHECK_NATNUM (from); |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4006 CHECK_NATNUM (to); |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4007 CHECK_NATNUM (index); |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4008 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4009 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
|
4010 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
|
4011 if (XINT (index) >= ASIZE (gstring_out)) |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4012 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
|
4013 num = font->driver->otf_drive (font, otf_features, |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4014 gstring_in, XINT (from), XINT (to), |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4015 gstring_out, XINT (index), 0); |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4016 if (num < 0) |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4017 return Qnil; |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4018 return make_number (num); |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4019 } |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4020 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4021 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
|
4022 3, 3, 0, |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4023 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
|
4024 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
|
4025 in this format: |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4026 (SCRIPT LANGSYS FEATURE ...) |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4027 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
|
4028 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4029 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
|
4030 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
|
4031 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
|
4032 corresponding character. */) |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4033 (font_object, character, otf_features) |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4034 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
|
4035 { |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4036 struct font *font; |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4037 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
|
4038 Lisp_Object alternates; |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4039 int i, num; |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4040 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4041 CHECK_FONT_GET_OBJECT (font_object, font); |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4042 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
|
4043 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
|
4044 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
|
4045 CHECK_CHARACTER (character); |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4046 CHECK_CONS (otf_features); |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4047 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4048 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
|
4049 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
|
4050 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
|
4051 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
|
4052 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
|
4053 gstring_out, 0, 1)) < 0) |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4054 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
|
4055 make_number (ASIZE (gstring_out) * 2)); |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4056 alternates = Qnil; |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4057 for (i = 0; i < num; i++) |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4058 { |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4059 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
|
4060 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
|
4061 unsigned code = LGLYPH_CODE (g); |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4062 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4063 alternates = Fcons (Fcons (make_number (code), |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4064 c > 0 ? make_number (c) : Qnil), |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4065 alternates); |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4066 } |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4067 return Fnreverse (alternates); |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4068 } |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4069 |
| 90400 | 4070 |
| 4071 #ifdef FONT_DEBUG | |
| 4072 | |
| 4073 DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0, | |
| 4074 doc: /* Open FONT-ENTITY. */) | |
| 4075 (font_entity, size, frame) | |
| 4076 Lisp_Object font_entity; | |
| 4077 Lisp_Object size; | |
| 4078 Lisp_Object frame; | |
| 4079 { | |
| 4080 int isize; | |
| 4081 | |
| 4082 CHECK_FONT_ENTITY (font_entity); | |
| 4083 if (NILP (frame)) | |
| 4084 frame = selected_frame; | |
| 4085 CHECK_LIVE_FRAME (frame); | |
|
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4086 |
| 94926 | 4087 if (NILP (size)) |
| 4088 isize = XINT (AREF (font_entity, FONT_SIZE_INDEX)); | |
| 4089 else | |
| 4090 { | |
| 4091 CHECK_NUMBER_OR_FLOAT (size); | |
| 4092 if (FLOATP (size)) | |
| 4093 isize = POINT_TO_PIXEL (- isize, XFRAME (frame)->resy); | |
| 4094 else | |
| 4095 isize = XINT (size); | |
| 4096 if (isize == 0) | |
| 4097 isize = 120; | |
| 4098 } | |
| 90400 | 4099 return font_open_entity (XFRAME (frame), font_entity, isize); |
| 4100 } | |
| 4101 | |
| 4102 DEFUN ("close-font", Fclose_font, Sclose_font, 1, 2, 0, | |
| 4103 doc: /* Close FONT-OBJECT. */) | |
| 4104 (font_object, frame) | |
| 4105 Lisp_Object font_object, frame; | |
| 4106 { | |
| 4107 CHECK_FONT_OBJECT (font_object); | |
| 4108 if (NILP (frame)) | |
| 4109 frame = selected_frame; | |
| 4110 CHECK_LIVE_FRAME (frame); | |
| 4111 font_close_object (XFRAME (frame), font_object); | |
| 4112 return Qnil; | |
| 4113 } | |
| 4114 | |
| 4115 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
|
4116 doc: /* Return information about FONT-OBJECT. |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4117 The value is a vector: |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4118 [ 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
|
4119 CAPABILITY ] |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4120 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4121 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
|
4122 provide a name). |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4123 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4124 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
|
4125 doesn't provide a file name). |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4126 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4127 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
|
4128 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4129 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
|
4130 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4131 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
|
4132 pixel. |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4133 |
|
90677
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4134 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
|
4135 font format \(x, opentype, truetype, type1, pcf, or bdf) and the |
|
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4136 remaining elements describes a detail of the font capability. |
|
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4137 |
|
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4138 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
|
4139 \(opentype GSUB GPOS) |
|
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4140 where GSUB shows which "GSUB" features the font supports, and GPOS |
|
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4141 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
|
4142 lists of the format: |
|
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4143 \((SCRIPT (LANGSYS FEATURE ...) ...) ...) |
|
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4144 |
|
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4145 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
|
4146 one. |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4147 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4148 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
|
4149 |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4150 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
|
4151 representing the default langsys. |
|
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4152 |
|
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4153 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
|
4154 |
|
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4155 If the font is not OpenType font, CAPABILITY is nil. */) |
| 90400 | 4156 (font_object) |
| 4157 Lisp_Object font_object; | |
| 4158 { | |
| 4159 struct font *font; | |
| 4160 Lisp_Object val; | |
| 4161 | |
| 4162 CHECK_FONT_GET_OBJECT (font_object, font); | |
| 4163 | |
| 4164 val = Fmake_vector (make_number (9), Qnil); | |
| 94926 | 4165 ASET (val, 0, AREF (font_object, FONT_NAME_INDEX)); |
| 4166 ASET (val, 1, AREF (font_object, FONT_FILE_INDEX)); | |
| 90400 | 4167 ASET (val, 2, make_number (font->pixel_size)); |
| 94926 | 4168 ASET (val, 3, make_number (font->max_width)); |
| 90400 | 4169 ASET (val, 4, make_number (font->ascent)); |
| 4170 ASET (val, 5, make_number (font->descent)); | |
| 94926 | 4171 ASET (val, 6, make_number (font->space_width)); |
| 4172 ASET (val, 7, make_number (font->average_width)); | |
| 90400 | 4173 if (font->driver->otf_capability) |
|
90677
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4174 ASET (val, 8, Fcons (Qopentype, font->driver->otf_capability (font))); |
| 90400 | 4175 return val; |
| 4176 } | |
| 4177 | |
| 4178 DEFUN ("get-font-glyphs", Fget_font_glyphs, Sget_font_glyphs, 2, 2, 0, | |
| 4179 doc: /* Return a vector of glyphs of FONT-OBJECT for drawing STRING. | |
| 4180 Each element is a vector [GLYPH-CODE LBEARING RBEARING WIDTH ASCENT DESCENT]. */) | |
| 4181 (font_object, string) | |
| 4182 Lisp_Object font_object, string; | |
| 4183 { | |
| 4184 struct font *font; | |
| 4185 int i, len; | |
| 4186 Lisp_Object vec; | |
| 4187 | |
| 4188 CHECK_FONT_GET_OBJECT (font_object, font); | |
| 4189 CHECK_STRING (string); | |
| 4190 len = SCHARS (string); | |
| 4191 vec = Fmake_vector (make_number (len), Qnil); | |
| 4192 for (i = 0; i < len; i++) | |
| 4193 { | |
| 4194 Lisp_Object ch = Faref (string, make_number (i)); | |
| 4195 Lisp_Object val; | |
| 4196 int c = XINT (ch); | |
| 4197 unsigned code; | |
|
91871
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
4198 EMACS_INT cod; |
| 90400 | 4199 struct font_metrics metrics; |
| 4200 | |
|
91871
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
4201 cod = code = font->driver->encode_char (font, c); |
| 90400 | 4202 if (code == FONT_INVALID_CODE) |
| 4203 continue; | |
| 4204 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
|
4205 if (cod <= MOST_POSITIVE_FIXNUM) |
| 90400 | 4206 ASET (val, 0, make_number (code)); |
| 4207 else | |
| 4208 ASET (val, 0, Fcons (make_number (code >> 16), | |
| 4209 make_number (code & 0xFFFF))); | |
|
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4210 font->driver->text_extents (font, &code, 1, &metrics); |
| 90400 | 4211 ASET (val, 1, make_number (metrics.lbearing)); |
| 4212 ASET (val, 2, make_number (metrics.rbearing)); | |
| 4213 ASET (val, 3, make_number (metrics.width)); | |
| 4214 ASET (val, 4, make_number (metrics.ascent)); | |
| 4215 ASET (val, 5, make_number (metrics.descent)); | |
| 4216 ASET (vec, i, val); | |
| 4217 } | |
| 4218 return vec; | |
| 4219 } | |
| 4220 | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4221 DEFUN ("font-match-p", Ffont_match_p, Sfont_match_p, 2, 2, 0, |
|
94745
a995b289585f
(Ffont_match_p): Don't use `iff' in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94394
diff
changeset
|
4222 doc: /* Return t if and only if font-spec SPEC matches with FONT. |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4223 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
|
4224 (spec, font) |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4225 Lisp_Object spec, font; |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4226 { |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4227 CHECK_FONT_SPEC (spec); |
| 94926 | 4228 CHECK_FONT (font); |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4229 |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4230 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
|
4231 } |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4232 |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4233 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
|
4234 doc: /* Return a font-object for displaying a character at POSITION. |
| 90541 | 4235 Optional second arg WINDOW, if non-nil, is a window displaying |
| 4236 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
|
4237 (position, window, string) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4238 Lisp_Object position, window, string; |
| 90541 | 4239 { |
| 4240 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
|
4241 EMACS_INT pos; |
| 90541 | 4242 |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4243 if (NILP (string)) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4244 { |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4245 CHECK_NUMBER_COERCE_MARKER (position); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4246 pos = XINT (position); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4247 if (pos < BEGV || pos >= ZV) |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4248 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
|
4249 } |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4250 else |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4251 { |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4252 CHECK_NUMBER (position); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4253 CHECK_STRING (string); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4254 pos = XINT (position); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4255 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
|
4256 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
|
4257 } |
| 90541 | 4258 if (NILP (window)) |
| 4259 window = selected_window; | |
| 4260 CHECK_LIVE_WINDOW (window); | |
|
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4261 w = XWINDOW (window); |
|
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4262 |
|
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4263 return font_at (-1, pos, NULL, w, string); |
| 90541 | 4264 } |
| 4265 | |
| 90400 | 4266 #if 0 |
| 4267 DEFUN ("draw-string", Fdraw_string, Sdraw_string, 2, 2, 0, | |
| 4268 doc: /* Draw STRING by FONT-OBJECT on the top left corner of the current frame. | |
| 4269 The value is a number of glyphs drawn. | |
| 4270 Type C-l to recover what previously shown. */) | |
| 4271 (font_object, string) | |
| 4272 Lisp_Object font_object, string; | |
| 4273 { | |
| 4274 Lisp_Object frame = selected_frame; | |
| 4275 FRAME_PTR f = XFRAME (frame); | |
| 4276 struct font *font; | |
| 4277 struct face *face; | |
| 4278 int i, len, width; | |
| 4279 unsigned *code; | |
| 4280 | |
| 4281 CHECK_FONT_GET_OBJECT (font_object, font); | |
| 4282 CHECK_STRING (string); | |
| 4283 len = SCHARS (string); | |
| 4284 code = alloca (sizeof (unsigned) * len); | |
| 4285 for (i = 0; i < len; i++) | |
| 4286 { | |
| 4287 Lisp_Object ch = Faref (string, make_number (i)); | |
| 4288 Lisp_Object val; | |
| 4289 int c = XINT (ch); | |
| 4290 | |
| 4291 code[i] = font->driver->encode_char (font, c); | |
| 4292 if (code[i] == FONT_INVALID_CODE) | |
| 4293 break; | |
| 4294 } | |
| 4295 face = FACE_FROM_ID (f, DEFAULT_FACE_ID); | |
| 4296 face->fontp = font; | |
| 4297 if (font->driver->prepare_face) | |
| 4298 font->driver->prepare_face (f, face); | |
| 4299 width = font->driver->text_extents (font, code, i, NULL); | |
| 4300 len = font->driver->draw_text (f, face, 0, font->ascent, code, i, width); | |
| 4301 if (font->driver->done_face) | |
| 4302 font->driver->done_face (f, face); | |
| 4303 face->fontp = NULL; | |
| 4304 return make_number (len); | |
| 4305 } | |
| 4306 #endif | |
| 4307 | |
| 4308 #endif /* FONT_DEBUG */ | |
| 4309 | |
| 4310 | |
| 4311 extern void syms_of_ftfont P_ (()); | |
| 4312 extern void syms_of_xfont P_ (()); | |
| 4313 extern void syms_of_xftfont P_ (()); | |
| 4314 extern void syms_of_ftxfont P_ (()); | |
| 4315 extern void syms_of_bdffont P_ (()); | |
| 4316 extern void syms_of_w32font P_ (()); | |
| 4317 extern void syms_of_atmfont P_ (()); | |
| 4318 | |
| 4319 void | |
| 4320 syms_of_font () | |
| 4321 { | |
| 4322 sort_shift_bits[FONT_SLANT_INDEX] = 0; | |
| 4323 sort_shift_bits[FONT_WEIGHT_INDEX] = 7; | |
| 4324 sort_shift_bits[FONT_SIZE_INDEX] = 14; | |
| 4325 sort_shift_bits[FONT_WIDTH_INDEX] = 21; | |
| 4326 sort_shift_bits[FONT_ADSTYLE_INDEX] = 28; | |
| 4327 sort_shift_bits[FONT_FOUNDRY_INDEX] = 29; | |
| 4328 sort_shift_bits[FONT_FAMILY_INDEX] = 30; | |
| 94926 | 4329 /* Note that sort_shift_bits[FONT_SORT_TYPE] and |
| 4330 sort_shift_bits[FONT_SORT_REGISTRY] are never used. */ | |
| 90400 | 4331 |
| 4332 staticpro (&font_style_table); | |
| 4333 font_style_table = Fmake_vector (make_number (3), Qnil); | |
| 4334 | |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4335 staticpro (&font_charset_alist); |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4336 font_charset_alist = Qnil; |
|
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4337 |
| 94926 | 4338 DEFSYM (Qfont_spec, "font-spec"); |
| 4339 DEFSYM (Qfont_entity, "font-entity"); | |
| 4340 DEFSYM (Qfont_object, "font-object"); | |
| 4341 | |
|
90677
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4342 DEFSYM (Qopentype, "opentype"); |
| 90400 | 4343 |
|
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
4344 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
|
4345 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
|
4346 DEFSYM (Qunicode_bmp, "unicode-bmp"); |
|
90622
bb9362e3a03b
(Qunicode_sip): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90590
diff
changeset
|
4347 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
|
4348 |
| 90400 | 4349 DEFSYM (QCotf, ":otf"); |
| 94926 | 4350 DEFSYM (QClang, ":lang"); |
| 90400 | 4351 DEFSYM (QCscript, ":script"); |
|
91125
6c9a19ff6c55
(Qfontp): Remove unused symbol.
Jason Rumney <jasonr@gnu.org>
parents:
91112
diff
changeset
|
4352 DEFSYM (QCantialias, ":antialias"); |
| 90400 | 4353 |
| 4354 DEFSYM (QCfoundry, ":foundry"); | |
| 4355 DEFSYM (QCadstyle, ":adstyle"); | |
| 4356 DEFSYM (QCregistry, ":registry"); | |
|
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
4357 DEFSYM (QCspacing, ":spacing"); |
|
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
4358 DEFSYM (QCdpi, ":dpi"); |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4359 DEFSYM (QCscalable, ":scalable"); |
| 94926 | 4360 DEFSYM (QCavgwidth, ":avgwidth"); |
| 4361 DEFSYM (QCfont_entity, ":font-entity"); | |
| 4362 DEFSYM (QCfc_unknown_spec, ":fc-unknown-spec"); | |
| 90400 | 4363 |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4364 DEFSYM (Qc, "c"); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4365 DEFSYM (Qm, "m"); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4366 DEFSYM (Qp, "p"); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4367 DEFSYM (Qd, "d"); |
|
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4368 |
| 90400 | 4369 staticpro (&null_vector); |
| 4370 null_vector = Fmake_vector (make_number (0), Qnil); | |
| 4371 | |
| 4372 staticpro (&scratch_font_spec); | |
| 4373 scratch_font_spec = Ffont_spec (0, NULL); | |
| 4374 staticpro (&scratch_font_prefer); | |
| 4375 scratch_font_prefer = Ffont_spec (0, NULL); | |
| 4376 | |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4377 #ifdef HAVE_LIBOTF |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4378 staticpro (&otf_list); |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4379 otf_list = Qnil; |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4380 #endif |
|
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4381 |
| 90400 | 4382 defsubr (&Sfontp); |
| 4383 defsubr (&Sfont_spec); | |
| 4384 defsubr (&Sfont_get); | |
| 4385 defsubr (&Sfont_put); | |
| 4386 defsubr (&Slist_fonts); | |
| 94926 | 4387 defsubr (&Sfont_family_list); |
| 90400 | 4388 defsubr (&Sfind_font); |
| 4389 defsubr (&Sfont_xlfd_name); | |
| 4390 defsubr (&Sclear_font_cache); | |
| 4391 defsubr (&Sinternal_set_font_style_table); | |
| 4392 defsubr (&Sfont_make_gstring); | |
| 4393 defsubr (&Sfont_fill_gstring); | |
|
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4394 defsubr (&Sfont_shape_text); |
|
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4395 defsubr (&Sfont_drive_otf); |
|
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4396 defsubr (&Sfont_otf_alternates); |
| 90400 | 4397 |
| 4398 #ifdef FONT_DEBUG | |
| 4399 defsubr (&Sopen_font); | |
| 4400 defsubr (&Sclose_font); | |
| 4401 defsubr (&Squery_font); | |
| 4402 defsubr (&Sget_font_glyphs); | |
|
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4403 defsubr (&Sfont_match_p); |
| 90541 | 4404 defsubr (&Sfont_at); |
| 90400 | 4405 #if 0 |
| 4406 defsubr (&Sdraw_string); | |
| 4407 #endif | |
| 4408 #endif /* FONT_DEBUG */ | |
| 4409 | |
| 4410 #ifdef HAVE_FREETYPE | |
| 94926 | 4411 syms_of_ftfont (); |
| 90400 | 4412 #ifdef HAVE_X_WINDOWS |
| 94926 | 4413 syms_of_xfont (); |
| 4414 syms_of_ftxfont (); | |
| 90400 | 4415 #ifdef HAVE_XFT |
| 94926 | 4416 syms_of_xftfont (); |
| 90400 | 4417 #endif /* HAVE_XFT */ |
| 4418 #endif /* HAVE_X_WINDOWS */ | |
| 4419 #else /* not HAVE_FREETYPE */ | |
| 4420 #ifdef HAVE_X_WINDOWS | |
| 94926 | 4421 syms_of_xfont (); |
| 90400 | 4422 #endif /* HAVE_X_WINDOWS */ |
| 4423 #endif /* not HAVE_FREETYPE */ | |
| 4424 #ifdef HAVE_BDFFONT | |
| 94926 | 4425 syms_of_bdffont (); |
| 90400 | 4426 #endif /* HAVE_BDFFONT */ |
| 4427 #ifdef WINDOWSNT | |
| 94926 | 4428 syms_of_w32font (); |
| 90400 | 4429 #endif /* WINDOWSNT */ |
| 4430 #ifdef MAC_OS | |
| 94926 | 4431 syms_of_atmfont (); |
| 90400 | 4432 #endif /* MAC_OS */ |
| 4433 } | |
| 90427 | 4434 |
| 4435 /* arch-tag: 74c9475d-5976-4c93-a327-942ae3072846 | |
| 4436 (do not change this comment) */ |
