Commit | Line | Data |
---|---|---|
c2f5bfd6 | 1 | /* font.h -- Interface definition for font handling. |
7ecf3dcb GM |
2 | Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. |
3 | Copyright (C) 2006, 2007, 2008 | |
c2f5bfd6 KH |
4 | National Institute of Advanced Industrial Science and Technology (AIST) |
5 | Registration Number H13PRO009 | |
6 | ||
7 | This file is part of GNU Emacs. | |
8 | ||
9 | GNU Emacs is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
76860cbb | 11 | the Free Software Foundation; either version 3, or (at your option) |
c2f5bfd6 KH |
12 | any later version. |
13 | ||
14 | GNU Emacs is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with GNU Emacs; see the file COPYING. If not, write to | |
21 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
22 | Boston, MA 02110-1301, USA. */ | |
23 | ||
24 | #ifndef EMACS_FONT_H | |
25 | #define EMACS_FONT_H | |
26 | ||
27 | #include "ccl.h" | |
28 | ||
29 | /* We have three types of Lisp objects related to font. | |
30 | ||
31 | FONT-SPEC | |
32 | ||
33 | Vector (length FONT_SPEC_MAX) of font properties. Some | |
34 | properties can be left unspecified (i.e. nil). Emacs asks | |
35 | font-drivers to find a font by FONT-SPEC. A fontset entry | |
36 | specifies requisite properties whereas a face specifies just | |
37 | preferable properties. This object is fully modifiable by | |
38 | Lisp. | |
39 | ||
40 | FONT-ENTITY | |
41 | ||
42 | Vector (length FONT_ENTITY_MAX) of fully specified font | |
43 | properties that a font-driver returns upon a request of | |
44 | FONT-SPEC. | |
45 | ||
46 | Note: Only the method `list' of a font-driver can create this | |
47 | object, and should never be modified by Lisp. In that sense, | |
48 | it may be cleaner to implement it as a Lisp object of a new | |
49 | type (e.g. struct Lisp_Font). | |
50 | ||
51 | FONT-OBJECT | |
52 | ||
53 | Lisp object of type Lisp_Misc_Save_Value encapsulating a | |
54 | pointer to "struct font". This corresponds to an opened font. | |
55 | ||
56 | Note: The note for FONT-ENTITY also applies to this. | |
57 | */ | |
58 | ||
59 | ||
60 | struct font_driver; | |
61 | struct font; | |
62 | ||
63 | /* An enumerator for each font property. This is used as an index to | |
64 | the vector of FONT-SPEC and FONT-ENTITY. | |
65 | ||
66 | Note: The order is important and should not be changed. */ | |
67 | ||
68 | enum font_property_index | |
69 | { | |
70 | /* FONT-TYPE is a symbol indicating a font backend; currently `x', | |
db9b8a15 JR |
71 | `xft', `ftx', `freetype' are available on X and gdi on Windows. |
72 | For Windows, we `bdf' and `uniscribe' backends are in progress. | |
73 | For Mac OS X, we need `atm'. */ | |
c2f5bfd6 KH |
74 | FONT_TYPE_INDEX, |
75 | ||
76 | /* FONT-FOUNDRY is a foundry name (symbol). */ | |
77 | FONT_FOUNDRY_INDEX, | |
78 | ||
79 | /* FONT-FAMILY is a family name (symbol). */ | |
80 | FONT_FAMILY_INDEX, | |
81 | ||
82 | /* FONT-ADSTYLE is an additional style name (symbol). */ | |
83 | FONT_ADSTYLE_INDEX, | |
84 | ||
85 | /* FONT-REGISTRY is a combination of a charset-registry and | |
86 | charset0encoding name (symbol). */ | |
87 | FONT_REGISTRY_INDEX, | |
88 | ||
89 | /* FONT-WEIGHT is a numeric value of weight (e.g. medium, bold) of | |
90 | the font. The value is what defined by FC_WEIGHT_* in | |
91 | fontconfig. */ | |
92 | FONT_WEIGHT_INDEX, | |
93 | ||
94 | /* FONT-SLANT is a numeric value of slant (e.g. r, i, o) of the | |
95 | font. The value is what defined by FC_SLANT_* in | |
96 | fontconfig plus 100. */ | |
97 | FONT_SLANT_INDEX, | |
98 | ||
99 | /* FONT-WIDTH is a numeric value of setwidth (e.g. normal, | |
100 | condensed) of the font. The value is what defined by | |
101 | FC_WIDTH_* in fontconfig. */ | |
102 | FONT_WIDTH_INDEX, | |
103 | ||
104 | /* FONT-SIZE is a size of the font. If integer, it is a pixel | |
105 | size. For a font-spec, the value can be float specifying a | |
106 | point size. For a font-entity, the value can be zero meaning | |
107 | that the font is scalable. */ | |
108 | FONT_SIZE_INDEX, | |
109 | ||
110 | /* In a font-spec, the value is an alist of extra information of a | |
111 | font such as name, OpenType features, and language coverage. | |
112 | In a font-entity, the value is an extra infomation for | |
113 | identifying a font (font-driver dependent). */ | |
114 | FONT_EXTRA_INDEX, /* alist alist */ | |
115 | ||
116 | /* This value is the length of font-spec vector. */ | |
117 | FONT_SPEC_MAX, | |
118 | ||
119 | /* The followings are used only for a font-entity. */ | |
120 | ||
121 | /* Frame on which the font is found. The value is nil if the font | |
122 | can be opend on any frame. */ | |
123 | FONT_FRAME_INDEX = FONT_SPEC_MAX, | |
124 | ||
4b4836de KH |
125 | /* List of font-objects opened from the font-entity. The value is |
126 | nil if no font can be opened for this font-entity. */ | |
c2f5bfd6 KH |
127 | FONT_OBJLIST_INDEX, |
128 | ||
129 | /* This value is the length of font-entity vector. */ | |
130 | FONT_ENTITY_MAX | |
131 | }; | |
132 | ||
a46bb06e | 133 | extern Lisp_Object QCspacing, QCdpi, QCscalable, QCotf, QClanguage, QCscript; |
c2f5bfd6 | 134 | |
3223c449 | 135 | /* Important character set symbols. */ |
32d497b1 | 136 | extern Lisp_Object Qiso8859_1, Qiso10646_1, Qunicode_bmp, Qunicode_sip; |
3223c449 | 137 | |
c2f5bfd6 KH |
138 | extern Lisp_Object null_string; |
139 | extern Lisp_Object null_vector; | |
140 | ||
141 | /* Structure for an opened font. We can safely cast this structure to | |
4fe8e188 | 142 | "struct font_info". */ |
c2f5bfd6 KH |
143 | |
144 | struct font | |
145 | { | |
146 | struct font_info font; | |
147 | ||
148 | /* From which font-entity the font is opened. */ | |
149 | Lisp_Object entity; | |
150 | ||
151 | /* By which pixel size the font is opened. */ | |
152 | int pixel_size; | |
153 | ||
154 | /* Font-driver for the font. */ | |
155 | struct font_driver *driver; | |
156 | ||
c6666169 KH |
157 | /* Symbol of font font; x, ttf, pcf, etc, */ |
158 | Lisp_Object format; | |
159 | ||
c2f5bfd6 KH |
160 | /* File name of the font, or NULL if the font is not associated with |
161 | a file. */ | |
162 | char *file_name; | |
163 | ||
64c9fe54 KH |
164 | /* Charset to encode a character code into a glyph code of the font. |
165 | -1 means that the font doesn't require this information to encode | |
166 | a character. */ | |
c2f5bfd6 KH |
167 | int encoding_charset; |
168 | ||
169 | /* Charset to check if a character code is supported by the font. | |
170 | -1 means that the contents of the font must be looked up to | |
64c9fe54 | 171 | determine it. */ |
e2a3f5b2 | 172 | int repertory_charset; |
c2f5bfd6 KH |
173 | |
174 | /* Minimum glyph width (in pixels). */ | |
175 | int min_width; | |
176 | ||
177 | /* Ascent and descent of the font (in pixels). */ | |
178 | int ascent, descent; | |
179 | ||
e2873d13 KH |
180 | /* 1 iff the font is scalable. */ |
181 | int scalable; | |
182 | ||
c2f5bfd6 KH |
183 | /* There will be more to this structure, but they are private to a |
184 | font-driver. */ | |
185 | }; | |
186 | ||
f8657b39 KH |
187 | enum font_spacing |
188 | { | |
189 | FONT_SPACING_PROPORTIONAL = 0, | |
190 | FONT_SPACING_DUAL = 90, | |
191 | FONT_SPACING_MONO = 100, | |
192 | FONT_SPACING_CHARCELL = 110 | |
193 | }; | |
194 | ||
c2f5bfd6 KH |
195 | struct font_metrics |
196 | { | |
197 | short lbearing, rbearing, width, ascent, descent; | |
198 | }; | |
199 | ||
200 | struct font_bitmap | |
201 | { | |
5a74d0e5 | 202 | int bits_per_pixel; |
c2f5bfd6 KH |
203 | int rows; |
204 | int width; | |
205 | int pitch; | |
206 | unsigned char *buffer; | |
207 | int left; | |
208 | int top; | |
209 | int advance; | |
210 | void *extra; | |
211 | }; | |
212 | ||
213 | /* Predicates to check various font-related objects. */ | |
214 | ||
c2f5bfd6 KH |
215 | #define FONT_SPEC_P(x) \ |
216 | (VECTORP (x) && ASIZE (x) == FONT_SPEC_MAX) | |
217 | #define FONT_ENTITY_P(x) \ | |
218 | (VECTORP (x) && ASIZE (x) == FONT_ENTITY_MAX) | |
219 | #define FONT_OBJECT_P(x) \ | |
220 | (XTYPE (x) == Lisp_Misc && XMISCTYPE (x) == Lisp_Misc_Save_Value) | |
23c8bcbf KH |
221 | #define FONTP(x) \ |
222 | ((VECTORP (x) && (ASIZE (x) == FONT_SPEC_MAX \ | |
223 | || ASIZE (x) == FONT_ENTITY_MAX)) \ | |
224 | || FONT_OBJECT_P (x)) | |
c2f5bfd6 | 225 | |
4b4836de KH |
226 | #define FONT_ENTITY_NOT_LOADABLE(entity) \ |
227 | EQ (AREF (entity, FONT_OBJLIST_INDEX), Qt) | |
228 | ||
229 | #define FONT_ENTITY_SET_NOT_LOADABLE(entity) \ | |
230 | ASET (entity, FONT_OBJLIST_INDEX, Qt) | |
231 | ||
c2f5bfd6 KH |
232 | |
233 | /* Check macros for various font-related objects. */ | |
234 | ||
235 | #define CHECK_FONT(x) \ | |
02dfeba8 | 236 | do { if (! FONTP (x)) wrong_type_argument (Qfont, x); } while (0) |
c2f5bfd6 | 237 | #define CHECK_FONT_SPEC(x) \ |
02dfeba8 | 238 | do { if (! FONT_SPEC_P (x)) wrong_type_argument (Qfont, x); } while (0) |
c2f5bfd6 | 239 | #define CHECK_FONT_ENTITY(x) \ |
02dfeba8 | 240 | do { if (! FONT_ENTITY_P (x)) wrong_type_argument (Qfont, x); } while (0) |
c2f5bfd6 | 241 | #define CHECK_FONT_OBJECT(x) \ |
02dfeba8 | 242 | do { if (! FONT_OBJECT_P (x)) wrong_type_argument (Qfont, x); } while (0) |
c2f5bfd6 KH |
243 | |
244 | #define CHECK_FONT_GET_OBJECT(x, font) \ | |
245 | do { \ | |
02dfeba8 | 246 | if (! FONT_OBJECT_P (x)) wrong_type_argument (Qfont, x); \ |
c2f5bfd6 KH |
247 | if (! XSAVE_VALUE (x)->pointer) error ("Font already closed"); \ |
248 | font = XSAVE_VALUE (x)->pointer; \ | |
249 | } while (0) | |
250 | ||
f8657b39 KH |
251 | /* Ignore the difference of font pixel sizes less than or equal to |
252 | this value. */ | |
253 | #define FONT_PIXEL_SIZE_QUANTUM 1 | |
254 | ||
c2f5bfd6 KH |
255 | struct face; |
256 | struct composition; | |
257 | ||
258 | /* Macros for lispy glyph-string. */ | |
76860cbb SM |
259 | enum lgstring_indices |
260 | { | |
261 | LGSTRING_IX_FONT, LGSTRING_IX_WIDTH, | |
262 | LGSTRING_IX_LBEARING, LGSTRING_IX_RBEARING, | |
263 | LGSTRING_IX_ASCENT, LGSTRING_IX_DESCENT | |
264 | }; | |
265 | #define LGSTRING_SLOT(lgs, ix) AREF (AREF ((lgs), 0), ix) | |
266 | #define LGSTRING_FONT(lgs) LGSTRING_SLOT (lgs, LGSTRING_IX_FONT) | |
267 | #define LGSTRING_WIDTH(lgs) XINT (LGSTRING_SLOT (lgs, LGSTRING_IX_WIDTH)) | |
268 | #define LGSTRING_LBEARING(lgs) XINT (LGSTRING_SLOT (lgs, LGSTRING_IX_LBEARING)) | |
269 | #define LGSTRING_RBEARING(lgs) XINT (LGSTRING_SLOT (lgs, LGSTRING_IX_RBEARING)) | |
270 | #define LGSTRING_ASCENT(lgs) XINT (LGSTRING_SLOT (lgs, LGSTRING_IX_ASCENT)) | |
271 | #define LGSTRING_DESCENT(lgs) XINT (LGSTRING_SLOT (lgs, LGSTRING_IX_DESCENT)) | |
272 | #define LGSTRING_SET_SLOT(lgs, ix, val) ASET (AREF ((lgs), 0), ix, (val)) | |
273 | #define LGSTRING_SET_FONT(lgs, val) \ | |
274 | LGSTRING_SET_SLOT(lgs, LGSTRING_IX_FONT, (val)) | |
4b4836de | 275 | #define LGSTRING_SET_WIDTH(lgs, val) \ |
76860cbb | 276 | LGSTRING_SET_SLOT(lgs, LGSTRING_IX_WIDTH, make_number (val)) |
4b4836de | 277 | #define LGSTRING_SET_LBEARING(lgs, val) \ |
76860cbb | 278 | LGSTRING_SET_SLOT(lgs, LGSTRING_IX_LBEARING, make_number (val)) |
4b4836de | 279 | #define LGSTRING_SET_RBEARING(lgs, val) \ |
76860cbb | 280 | LGSTRING_SET_SLOT(lgs, LGSTRING_IX_RBEARING, make_number (val)) |
4b4836de | 281 | #define LGSTRING_SET_ASCENT(lgs, val) \ |
76860cbb | 282 | LGSTRING_SET_SLOT(lgs, LGSTRING_IX_ASCENT, make_number (val)) |
4b4836de | 283 | #define LGSTRING_SET_DESCENT(lgs, val) \ |
76860cbb | 284 | LGSTRING_SET_SLOT(lgs, LGSTRING_IX_DESCENT, make_number (val)) |
c2f5bfd6 KH |
285 | |
286 | #define LGSTRING_LENGTH(lgs) (ASIZE ((lgs)) - 1) | |
287 | #define LGSTRING_GLYPH(lgs, idx) AREF ((lgs), (idx) + 1) | |
4b4836de KH |
288 | #define LGSTRING_SET_GLYPH(lgs, idx, val) ASET ((lgs), (idx) + 1, (val)) |
289 | ||
52b95de4 | 290 | /* Vector size of Lispy glyph. */ |
76860cbb SM |
291 | enum lglyph_indices |
292 | { | |
293 | LGLYPH_IX_FROM, LGLYPH_IX_TO, LGLYPH_IX_CHAR, LGLYPH_IX_CODE, | |
294 | LGLYPH_IX_WIDTH, LGLYPH_IX_LBEARING, LGLYPH_IX_RBEARING, | |
295 | LGLYPH_IX_ASCENT, LGLYPH_IX_DESCENT, LGLYPH_IX_ADJUSTMENT, | |
296 | /* Not an index. */ | |
297 | LGLYPH_SIZE | |
298 | }; | |
299 | #define LGLYPH_FROM(g) XINT (AREF ((g), LGLYPH_IX_FROM)) | |
300 | #define LGLYPH_TO(g) XINT (AREF ((g), LGLYPH_IX_TO)) | |
301 | #define LGLYPH_CHAR(g) XINT (AREF ((g), LGLYPH_IX_CHAR)) | |
302 | #define LGLYPH_CODE(g) XUINT (AREF ((g), LGLYPH_IX_CODE)) | |
303 | #define LGLYPH_WIDTH(g) XINT (AREF ((g), LGLYPH_IX_WIDTH)) | |
304 | #define LGLYPH_LBEARING(g) XINT (AREF ((g), LGLYPH_IX_LBEARING)) | |
305 | #define LGLYPH_RBEARING(g) XINT (AREF ((g), LGLYPH_IX_RBEARING)) | |
306 | #define LGLYPH_ASCENT(g) XINT (AREF ((g), LGLYPH_IX_ASCENT)) | |
307 | #define LGLYPH_DESCENT(g) XINT (AREF ((g), LGLYPH_IX_DESCENT)) | |
308 | #define LGLYPH_ADJUSTMENT(g) AREF ((g), LGLYPH_IX_ADJUSTMENT) | |
309 | #define LGLYPH_SET_FROM(g, val) ASET ((g), LGLYPH_IX_FROM, make_number (val)) | |
310 | #define LGLYPH_SET_TO(g, val) ASET ((g), LGLYPH_IX_TO, make_number (val)) | |
311 | #define LGLYPH_SET_CHAR(g, val) ASET ((g), LGLYPH_IX_CHAR, make_number (val)) | |
312 | /* FIXME: we should use make_uint_number here. */ | |
313 | #define LGLYPH_SET_CODE(g, val) ASET ((g), LGLYPH_IX_CODE, make_number (val)) | |
314 | #define LGLYPH_SET_WIDTH(g, val) ASET ((g), LGLYPH_IX_WIDTH, make_number (val)) | |
315 | #define LGLYPH_SET_LBEARING(g, val) ASET ((g), LGLYPH_IX_RBEARING, make_number (val)) | |
316 | #define LGLYPH_SET_RBEARING(g, val) ASET ((g), LGLYPH_IX_LBEARING, make_number (val)) | |
317 | #define LGLYPH_SET_ASCENT(g, val) ASET ((g), LGLYPH_IX_ASCENT, make_number (val)) | |
318 | #define LGLYPH_SET_DESCENT(g, val) ASET ((g), LGLYPH_IX_DESCENT, make_number (val)) | |
319 | #define LGLYPH_SET_ADJUSTMENT(g, val) ASET ((g), LGLYPH_IX_ADJUSTMENT, (val)) | |
33b27f57 | 320 | |
0bd4cc79 KH |
321 | #define LGLYPH_XOFF(g) (VECTORP (LGLYPH_ADJUSTMENT (g)) \ |
322 | ? XINT (AREF (LGLYPH_ADJUSTMENT (g), 0)) : 0) | |
323 | #define LGLYPH_YOFF(g) (VECTORP (LGLYPH_ADJUSTMENT (g)) \ | |
324 | ? XINT (AREF (LGLYPH_ADJUSTMENT (g), 1)) : 0) | |
325 | #define LGLYPH_WADJUST(g) (VECTORP (LGLYPH_ADJUSTMENT (g)) \ | |
326 | ? XINT (AREF (LGLYPH_ADJUSTMENT (g), 2)) : 0) | |
c2f5bfd6 KH |
327 | |
328 | #define FONT_INVALID_CODE 0xFFFFFFFF | |
329 | ||
217caa37 KH |
330 | /* Font driver. Members specified as "optional" can be NULL. */ |
331 | ||
c2f5bfd6 KH |
332 | struct font_driver |
333 | { | |
334 | /* Symbol indicating the type of the font-driver. */ | |
335 | Lisp_Object type; | |
336 | ||
69ea039a | 337 | /* Return a cache of font-entities on frame F. The cache must be a |
c2f5bfd6 | 338 | cons whose cdr part is the actual cache area. */ |
69ea039a | 339 | Lisp_Object (*get_cache) P_ ((FRAME_PTR F)); |
c2f5bfd6 | 340 | |
dc377380 KH |
341 | /* List fonts exactly matching with FONT_SPEC on FRAME. The value |
342 | is a vector of font-entities. This is the sole API that | |
343 | allocates font-entities. */ | |
c2f5bfd6 KH |
344 | Lisp_Object (*list) P_ ((Lisp_Object frame, Lisp_Object font_spec)); |
345 | ||
dc377380 KH |
346 | /* Return a font entity most closely maching with FONT_SPEC on |
347 | FRAME. The closeness is detemined by the font backend, thus | |
348 | `face-font-selection-order' is ignored here. */ | |
349 | Lisp_Object (*match) P_ ((Lisp_Object frame, Lisp_Object font_spec)); | |
350 | ||
217caa37 KH |
351 | /* Optional. |
352 | List available families. The value is a list of family names | |
353 | (symbols). */ | |
c2f5bfd6 KH |
354 | Lisp_Object (*list_family) P_ ((Lisp_Object frame)); |
355 | ||
217caa37 KH |
356 | /* Optional (if FONT_EXTRA_INDEX is not Lisp_Save_Value). |
357 | Free FONT_EXTRA_INDEX field of FONT_ENTITY. */ | |
c2f5bfd6 KH |
358 | void (*free_entity) P_ ((Lisp_Object font_entity)); |
359 | ||
360 | /* Open a font specified by FONT_ENTITY on frame F. If the font is | |
361 | scalable, open it with PIXEL_SIZE. */ | |
362 | struct font *(*open) P_ ((FRAME_PTR f, Lisp_Object font_entity, | |
363 | int pixel_size)); | |
364 | ||
365 | /* Close FONT on frame F. */ | |
366 | void (*close) P_ ((FRAME_PTR f, struct font *font)); | |
367 | ||
217caa37 KH |
368 | /* Optional (if FACE->extra is not used). |
369 | Prepare FACE for displaying characters by FONT on frame F by | |
370 | storing some data in FACE->extra. If successful, return 0. | |
371 | Otherwise, return -1. */ | |
c2f5bfd6 KH |
372 | int (*prepare_face) P_ ((FRAME_PTR f, struct face *face)); |
373 | ||
217caa37 KH |
374 | /* Optional. |
375 | Done FACE for displaying characters by FACE->font on frame F. */ | |
c2f5bfd6 KH |
376 | void (*done_face) P_ ((FRAME_PTR f, struct face *face)); |
377 | ||
217caa37 KH |
378 | /* Optional. |
379 | If FONT_ENTITY has a glyph for character C (Unicode code point), | |
380 | return 1. If not, return 0. If a font must be opened to check | |
381 | it, return -1. */ | |
c2f5bfd6 KH |
382 | int (*has_char) P_ ((Lisp_Object entity, int c)); |
383 | ||
217caa37 KH |
384 | /* Return a glyph code of FONT for characer C (Unicode code point). |
385 | If FONT doesn't have such a glyph, return FONT_INVALID_CODE. */ | |
c2f5bfd6 KH |
386 | unsigned (*encode_char) P_ ((struct font *font, int c)); |
387 | ||
ef5e1a96 KH |
388 | /* Computate the total metrics of the NGLYPHS glyphs specified by |
389 | the font FONT and the sequence of glyph codes CODE, and store the | |
390 | result in METRICS. */ | |
c2f5bfd6 KH |
391 | int (*text_extents) P_ ((struct font *font, |
392 | unsigned *code, int nglyphs, | |
393 | struct font_metrics *metrics)); | |
394 | ||
217caa37 KH |
395 | /* Optional. |
396 | Draw glyphs between FROM and TO of S->char2b at (X Y) pixel | |
c2f5bfd6 KH |
397 | position of frame F with S->FACE and S->GC. If WITH_BACKGROUND |
398 | is nonzero, fill the background in advance. It is assured that | |
399 | WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars). */ | |
400 | int (*draw) P_ ((struct glyph_string *s, int from, int to, | |
401 | int x, int y, int with_background)); | |
402 | ||
217caa37 KH |
403 | /* Optional. |
404 | Store bitmap data for glyph-code CODE of FONT in BITMAP. It is | |
405 | intended that this method is callled from the other font-driver | |
406 | for actual drawing. */ | |
c2f5bfd6 KH |
407 | int (*get_bitmap) P_ ((struct font *font, unsigned code, |
408 | struct font_bitmap *bitmap, | |
409 | int bits_per_pixel)); | |
410 | ||
217caa37 KH |
411 | /* Optional. |
412 | Free bitmap data in BITMAP. */ | |
c2f5bfd6 KH |
413 | void (*free_bitmap) P_ ((struct font *font, struct font_bitmap *bitmap)); |
414 | ||
217caa37 KH |
415 | /* Optional. |
416 | Return an outline data for glyph-code CODE of FONT. The format | |
417 | of the outline data depends on the font-driver. */ | |
c2f5bfd6 KH |
418 | void *(*get_outline) P_ ((struct font *font, unsigned code)); |
419 | ||
217caa37 KH |
420 | /* Optional. |
421 | Free OUTLINE (that is obtained by the above method). */ | |
c2f5bfd6 KH |
422 | void (*free_outline) P_ ((struct font *font, void *outline)); |
423 | ||
217caa37 KH |
424 | /* Optional. |
425 | Get coordinates of the INDEXth anchor point of the glyph whose | |
c2f5bfd6 | 426 | code is CODE. Store the coordinates in *X and *Y. Return 0 if |
217caa37 | 427 | the operations was successfull. Otherwise return -1. */ |
c2f5bfd6 KH |
428 | int (*anchor_point) P_ ((struct font *font, unsigned code, int index, |
429 | int *x, int *y)); | |
430 | ||
217caa37 KH |
431 | /* Optional. |
432 | Return a list describing which scripts/languages FONT | |
c2f5bfd6 KH |
433 | supports by which GSUB/GPOS features of OpenType tables. */ |
434 | Lisp_Object (*otf_capability) P_ ((struct font *font)); | |
435 | ||
217caa37 | 436 | /* Optional. |
b6c8772a KH |
437 | Apply FONT's OTF-FEATURES to the glyph string. |
438 | ||
439 | FEATURES specifies which OTF features to apply in this format: | |
440 | (SCRIPT LANGSYS GSUB-FEATURE GPOS-FEATURE) | |
441 | See the documentation of `font-drive-otf' for the detail. | |
c2f5bfd6 KH |
442 | |
443 | This method applies the specified features to the codes in the | |
444 | elements of GSTRING-IN (between FROMth and TOth). The output | |
445 | codes are stored in GSTRING-OUT at the IDXth element and the | |
446 | following elements. | |
447 | ||
448 | Return the number of output codes. If none of the features are | |
449 | applicable to the input data, return 0. If GSTRING-OUT is too | |
450 | short, return -1. */ | |
b6c8772a | 451 | int (*otf_drive) P_ ((struct font *font, Lisp_Object features, |
c2f5bfd6 | 452 | Lisp_Object gstring_in, int from, int to, |
e2873d13 | 453 | Lisp_Object gstring_out, int idx, int alternate_subst)); |
5a74d0e5 KH |
454 | |
455 | /* Optional. | |
456 | Make the font driver ready for frame F. Usually this function | |
457 | makes some data specific to F and store it in F by calling | |
458 | font_put_frame_data (). */ | |
459 | int (*start_for_frame) P_ ((FRAME_PTR f)); | |
460 | ||
461 | /* Optional. | |
462 | End using the driver for frame F. Usually this function free | |
463 | some data stored for F. */ | |
464 | int (*end_for_frame) P_ ((FRAME_PTR f)); | |
4b4836de KH |
465 | |
466 | /* Optional. | |
778686b1 KH |
467 | |
468 | Shape text in LGSTRING. See the docstring of `font-make-gstring' | |
469 | for the format of LGSTRING. If the (N+1)th element of LGSTRING | |
470 | is nil, input of shaping is from the 1st to (N)th elements. In | |
471 | each input glyph, FROM, TO, CHAR, and CODE are already set. | |
472 | ||
473 | This function updates all fields of the input glyphs. If the | |
474 | output glyphs (M) are more than the input glyphs (N), (N+1)th | |
475 | through (M)th elements of LGSTRING are updated possibly by making | |
476 | a new glyph object and storing it in LGSTRING. If (M) is greater | |
477 | than the length of LGSTRING, nil should be return. In that case, | |
478 | this function is called again with the larger LGSTRING. */ | |
4b4836de | 479 | Lisp_Object (*shape) P_ ((Lisp_Object lgstring)); |
c2f5bfd6 KH |
480 | }; |
481 | ||
482 | ||
5a74d0e5 KH |
483 | /* Chain of font drivers. There's one global font driver list |
484 | (font_driver_list in font.c). In addition, each frame has it's own | |
485 | font driver list at FRAME_PTR->font_driver_list. */ | |
486 | ||
c2f5bfd6 KH |
487 | struct font_driver_list |
488 | { | |
5a74d0e5 KH |
489 | /* 1 iff this driver is currently used. It is igonred in the global |
490 | font driver list.*/ | |
484ca464 | 491 | int on; |
5a74d0e5 | 492 | /* Pointer to the font driver. */ |
c2f5bfd6 | 493 | struct font_driver *driver; |
5a74d0e5 | 494 | /* Pointer to the next element of the chain. */ |
c2f5bfd6 KH |
495 | struct font_driver_list *next; |
496 | }; | |
497 | ||
5a74d0e5 KH |
498 | |
499 | /* Chain of arbitrary data specific to each font driver. Each frame | |
500 | has it's own font data list at FRAME_PTR->font_data_list. */ | |
501 | ||
502 | struct font_data_list | |
503 | { | |
504 | /* Pointer to the font driver. */ | |
505 | struct font_driver *driver; | |
506 | /* Data specific to the font driver. */ | |
507 | void *data; | |
508 | /* Pointer to the next element of the chain. */ | |
509 | struct font_data_list *next; | |
510 | }; | |
511 | ||
c2f5bfd6 KH |
512 | extern int enable_font_backend; |
513 | ||
514 | EXFUN (Ffont_spec, MANY); | |
4b4836de | 515 | EXFUN (Ffont_get, 2); |
8d3251f2 | 516 | EXFUN (Flist_fonts, 4); |
484ca464 | 517 | EXFUN (Fclear_font_cache, 0); |
8bb2f20f | 518 | EXFUN (Ffont_xlfd_name, 1); |
c2f5bfd6 | 519 | |
4b4836de KH |
520 | extern int font_registry_charsets P_ ((Lisp_Object, struct charset **, |
521 | struct charset **)); | |
c2f5bfd6 KH |
522 | extern Lisp_Object font_symbolic_weight P_ ((Lisp_Object font)); |
523 | extern Lisp_Object font_symbolic_slant P_ ((Lisp_Object font)); | |
524 | extern Lisp_Object font_symbolic_width P_ ((Lisp_Object font)); | |
525 | ||
217caa37 KH |
526 | extern int font_match_p P_ ((Lisp_Object spec, Lisp_Object entity)); |
527 | ||
c2f5bfd6 | 528 | extern Lisp_Object font_find_object P_ ((struct font *font)); |
217caa37 KH |
529 | extern Lisp_Object font_get_name P_ ((Lisp_Object font_object)); |
530 | extern Lisp_Object font_get_spec P_ ((Lisp_Object font_object)); | |
531 | extern Lisp_Object font_get_frame P_ ((Lisp_Object font_object)); | |
c2f5bfd6 KH |
532 | extern int font_has_char P_ ((FRAME_PTR, Lisp_Object, int)); |
533 | extern unsigned font_encode_char P_ ((Lisp_Object, int)); | |
534 | ||
535 | extern int font_set_lface_from_name P_ ((FRAME_PTR f, | |
536 | Lisp_Object lface, | |
537 | Lisp_Object fontname, | |
538 | int force_p, int may_fail_p)); | |
539 | extern Lisp_Object font_find_for_lface P_ ((FRAME_PTR f, Lisp_Object *lface, | |
4b4836de | 540 | Lisp_Object spec, int c)); |
b6c8772a KH |
541 | extern Lisp_Object font_open_for_lface P_ ((FRAME_PTR f, Lisp_Object entity, |
542 | Lisp_Object *lface, | |
543 | Lisp_Object spec)); | |
c2f5bfd6 KH |
544 | extern void font_load_for_face P_ ((FRAME_PTR f, struct face *face)); |
545 | extern void font_prepare_for_face P_ ((FRAME_PTR f, struct face *face)); | |
546 | extern Lisp_Object font_open_by_name P_ ((FRAME_PTR f, char *name)); | |
64c9fe54 | 547 | extern void font_close_object (FRAME_PTR f, Lisp_Object font_object); |
c2f5bfd6 KH |
548 | |
549 | extern Lisp_Object intern_downcase P_ ((char *str, int len)); | |
550 | extern void font_update_sort_order P_ ((int *order)); | |
551 | ||
64c9fe54 KH |
552 | extern void font_merge_old_spec P_ ((Lisp_Object name, Lisp_Object family, |
553 | Lisp_Object registry, Lisp_Object spec)); | |
c2f5bfd6 KH |
554 | |
555 | ||
a46bb06e | 556 | extern int font_parse_xlfd P_ ((char *name, Lisp_Object font)); |
c2f5bfd6 KH |
557 | extern int font_unparse_xlfd P_ ((Lisp_Object font, int pixel_size, |
558 | char *name, int bytes)); | |
a46bb06e | 559 | extern int font_parse_fcname P_ ((char *name, Lisp_Object font)); |
217caa37 KH |
560 | extern int font_unparse_fcname P_ ((Lisp_Object font, int pixel_size, |
561 | char *name, int bytes)); | |
c2f5bfd6 KH |
562 | extern void register_font_driver P_ ((struct font_driver *driver, FRAME_PTR f)); |
563 | extern void free_font_driver_list P_ ((FRAME_PTR f)); | |
dc377380 | 564 | extern Lisp_Object font_update_drivers P_ ((FRAME_PTR f, Lisp_Object list)); |
0bd4cc79 KH |
565 | extern Lisp_Object font_at P_ ((int c, EMACS_INT pos, struct face *face, |
566 | struct window *w, Lisp_Object object)); | |
c2f5bfd6 | 567 | |
4b4836de KH |
568 | extern struct font *font_prepare_composition P_ ((struct composition *cmp, |
569 | FRAME_PTR f)); | |
c2f5bfd6 | 570 | |
17484ddc JR |
571 | extern Lisp_Object font_put_extra P_ ((Lisp_Object font, Lisp_Object prop, |
572 | Lisp_Object val)); | |
c2f5bfd6 | 573 | |
5a74d0e5 KH |
574 | extern int font_put_frame_data P_ ((FRAME_PTR f, |
575 | struct font_driver *driver, | |
576 | void *data)); | |
577 | extern void *font_get_frame_data P_ ((FRAME_PTR f, | |
578 | struct font_driver *driver)); | |
579 | ||
c2f5bfd6 KH |
580 | #ifdef HAVE_FREETYPE |
581 | extern struct font_driver ftfont_driver; | |
582 | #endif /* HAVE_FREETYPE */ | |
583 | #ifdef HAVE_X_WINDOWS | |
584 | extern struct font_driver xfont_driver; | |
585 | extern struct font_driver ftxfont_driver; | |
586 | #ifdef HAVE_XFT | |
587 | extern struct font_driver xftfont_driver; | |
588 | #endif /* HAVE_XFT */ | |
589 | #endif /* HAVE_X_WINDOWS */ | |
590 | #ifdef WINDOWSNT | |
591 | extern struct font_driver w32font_driver; | |
97724679 | 592 | extern struct font_driver uniscribe_font_driver; |
c2f5bfd6 KH |
593 | #endif /* WINDOWSNT */ |
594 | #ifdef MAC_OS | |
595 | extern struct font_driver atmfont_driver; | |
596 | #endif /* MAC_OS */ | |
597 | ||
598 | #endif /* not EMACS_FONT_H */ | |
885b7d09 MB |
599 | |
600 | /* arch-tag: 3b7260c3-5bec-4d6b-a0db-95c1b431b1a2 | |
601 | (do not change this comment) */ |