aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2008-05-14 01:25:20 +0000
committerKenichi Handa2008-05-14 01:25:20 +0000
commit875003e5bce60bfda5b853f8512099cf16e8b169 (patch)
tree171937410aff84bcb0945f090c9d95d2711f60e2 /src
parent5a51a1443ad877b8de1d052cbd322eaacfebdf0b (diff)
downloademacs-875003e5bce60bfda5b853f8512099cf16e8b169.tar.gz
emacs-875003e5bce60bfda5b853f8512099cf16e8b169.zip
(Qfont_spec, Qfont_entity, Qfont_object): Extern them.
(enum font_property_index): New members FONT_DPI_INDEX, FONT_SPACING_INDEX, FONT_AVGWIDTH_INDEX, FONT_NAME_INDEX, FONT_FULLNAME_INDEX, FONT_FILE_INDEX, FONT_FORMAT_INDEX, FONT_OBJECT_MAX. Delete FONT_FRAME_INDEX. (FONT_WEIGHT_NUMERIC, FONT_SLANT_NUMERIC, FONT_WIDTH_NUMERIC) (FONT_WEIGHT_SYMBOLIC, FONT_SLANT_SYMBOLIC, FONT_WIDTH_SYMBOLIC) (FONT_WEIGHT_FOR_FACE, FONT_SLANT_FOR_FACE, FONT_WIDTH_FOR_FACE) (FONT_WEIGHT_NAME_NUMERIC, FONT_SLANT_NAME_NUMERIC) (FONT_WIDTH_NAME_NUMERIC, FONT_SET_STYLE): New macros. (struct font_spec, struct font_entity): New structs. (FONT_ENCODING_NOT_DECIDED): Moved from fontset.h. (struct font): Many members from old "struct font_info" moved to here. Members font and entity deleted. (FONT_SPEC_P, FONT_ENTITY_P, FONT_OBJECT_P, FONTP): Modified for the new font-related objects. (CHECK_FONT_SPEC, CHECK_FONT_ENTITY, CHECK_FONT_OBJECT) (CHECK_FONT_GET_OBJECT): Likewise. (XFONT_SPEC, XFONT_ENTITY, XFONT_OBJECT, XSETFONT): New macros. (PT_PER_INCH, POINT_TO_PIXEL, PIXEL_TO_POINT): Moved from font.h. (struct font_driver): New members case_sensitive anc check. Type of the member list and open changed. (enable_font_backend, font_symbolic_weight, font_symbolic_slant) (font_symbolic_width, font_find_object, font_get_spec) (font_set_lface_from_name): Delete extern. (Fcopy_font_spec, Fmerge_font_spec, Ffont_family_list): New EXFUNs.
Diffstat (limited to 'src')
-rw-r--r--src/font.h449
1 files changed, 355 insertions, 94 deletions
diff --git a/src/font.h b/src/font.h
index d93caef3dee..0de6c9f7a50 100644
--- a/src/font.h
+++ b/src/font.h
@@ -30,31 +30,32 @@ Boston, MA 02110-1301, USA. */
30 30
31 FONT-SPEC 31 FONT-SPEC
32 32
33 Vector (length FONT_SPEC_MAX) of font properties. Some 33 Pseudo vector (length FONT_SPEC_MAX) of font properties. Some
34 properties can be left unspecified (i.e. nil). Emacs asks 34 properties can be left unspecified (i.e. nil). Emacs asks
35 font-drivers to find a font by FONT-SPEC. A fontset entry 35 font-drivers to find a font by FONT-SPEC. A fontset entry
36 specifies requisite properties whereas a face specifies just 36 specifies requisite properties whereas a face specifies just
37 preferable properties. This object is fully modifiable by 37 preferable properties.
38 Lisp.
39 38
40 FONT-ENTITY 39 FONT-ENTITY
41 40
42 Vector (length FONT_ENTITY_MAX) of fully specified font 41 Pseudo vector (length FONT_ENTITY_MAX) of fully instanciated
43 properties that a font-driver returns upon a request of 42 font properties that a font-driver returns upon a request of
44 FONT-SPEC. 43 FONT-SPEC.
45 44
46 Note: Only the method `list' of a font-driver can create this 45 Note: Only the method `list' and `match' of a font-driver can
47 object, and should never be modified by Lisp. In that sense, 46 create this object, and should never be modified by Lisp.
48 it may be cleaner to implement it as a Lisp object of a new
49 type (e.g. struct Lisp_Font).
50 47
51 FONT-OBJECT 48 FONT-OBJECT
52 49
53 Lisp object of type Lisp_Misc_Save_Value encapsulating a 50 Pseudo vector (length FONT_OBJECT_MAX) of a opend font.
54 pointer to "struct font". This corresponds to an opened font.
55 51
56 Note: The note for FONT-ENTITY also applies to this. 52 Lisp object encapsulating "struct font". This corresponds to
57*/ 53 an opened font.
54
55 Note: Only the method `open' of a font-driver can create this
56 object, and should never be modified by Lisp. */
57
58extern Lisp_Object Qfont_spec, Qfont_entity, Qfont_object;
58 59
59 60
60struct font_driver; 61struct font_driver;
@@ -68,8 +69,8 @@ struct font;
68enum font_property_index 69enum font_property_index
69 { 70 {
70 /* FONT-TYPE is a symbol indicating a font backend; currently `x', 71 /* FONT-TYPE is a symbol indicating a font backend; currently `x',
71 `xft', `ftx', `freetype' are available on X and gdi on Windows. 72 `xft', `ftx' are available on X and gdi on Windows.
72 For Windows, we `bdf' and `uniscribe' backends are in progress. 73 For Windows, `bdf' and `uniscribe' backends are in progress.
73 For Mac OS X, we need `atm'. */ 74 For Mac OS X, we need `atm'. */
74 FONT_TYPE_INDEX, 75 FONT_TYPE_INDEX,
75 76
@@ -83,34 +84,78 @@ enum font_property_index
83 FONT_ADSTYLE_INDEX, 84 FONT_ADSTYLE_INDEX,
84 85
85 /* FONT-REGISTRY is a combination of a charset-registry and 86 /* FONT-REGISTRY is a combination of a charset-registry and
86 charset0encoding name (symbol). */ 87 charset-encoding name (symbol). */
87 FONT_REGISTRY_INDEX, 88 FONT_REGISTRY_INDEX,
88 89
89 /* FONT-WEIGHT is a numeric value of weight (e.g. medium, bold) of 90 /* 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 the font. The lowest 8-bit is an index determining the
91 fontconfig. */ 92 symbolic name, and the higher bits is the actual numeric value
93 defined in `font-weight-table'. */
92 FONT_WEIGHT_INDEX, 94 FONT_WEIGHT_INDEX,
93 95
94 /* FONT-SLANT is a numeric value of slant (e.g. r, i, o) of the 96 /* 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 97 font. The lowest 8-bit is an index determining the symbolic
96 fontconfig plus 100. */ 98 name, and the higher bits is the actual numeric value defined
99 in `font-slant-table'. */
97 FONT_SLANT_INDEX, 100 FONT_SLANT_INDEX,
98 101
99 /* FONT-WIDTH is a numeric value of setwidth (e.g. normal, 102 /* FONT-WIDTH is a numeric value of setwidth (e.g. normal) of the
100 condensed) of the font. The value is what defined by 103 font. The lowest 8-bit is an index determining the symbolic
101 FC_WIDTH_* in fontconfig. */ 104 name, and the higher bits is the actual numeric value defined
105 `font-width-table'. */
102 FONT_WIDTH_INDEX, 106 FONT_WIDTH_INDEX,
103 107
104 /* FONT-SIZE is a size of the font. If integer, it is a pixel 108 /* 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 109 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 110 point size. The value zero means that the font is
107 that the font is scalable. */ 111 scalable. */
108 FONT_SIZE_INDEX, 112 FONT_SIZE_INDEX,
109 113
114 /* FONT-DPI is a resolution (dot per inch) for which the font is
115 designed. */
116 FONT_DPI_INDEX,
117
118 /* FONT-SPACING is a spacing (mono, proportional, charcell) of the
119 font (integer; one of enum font_spacing). */
120 FONT_SPACING_INDEX,
121
122 /* FONT-AVGWIDTH is an average width (1/10 pixel unit) of the
123 font. */
124 FONT_AVGWIDTH_INDEX,
125
126#if 0
127 /* The following two members are to substitute for the above 6
128 members (FONT_WEIGHT_INDEX to FONT_AVGWIDTH_INDEX excluding
129 FONT_SIZE_INDEX) if it is found that font-entities consumes too
130 much memory. */
131
132 /* FONT-STYLE is a 24-bit integer containing indices for
133 style-related properties WEIGHT, SLANT, and WIDTH. The lowest
134 8-bit is an indice to the weight table AREF (font_style_table,
135 0), the next 8-bit is an indice to the slant table AREF
136 (font_style_table, 1), the highest 8-bit is an indice to the
137 slant table AREF (font_style_table, 2). The indice 0 indicates
138 that the corresponding style is not specified. This way, we
139 can represent at most 255 different names for each style, which
140 is surely sufficient. */
141 FONT_STYLE_INDEX,
142
143 /* FONT-METRICS is a 27-bit integer containing metrics-related
144 properties DPI, AVGWIDTH, SPACING. The lowest 12-bit is for
145 DPI, the next 12-bit is for AVGWIDTH, the highest 3-bit is for
146 SPACING. In each bit field, the highest bit indicates that the
147 corresponding value is set or not. This way, we can represent
148 DPI by 11-bit (0 to 2047), AVGWIDTH by 11-bit (0 to 2047),
149 SPACING by 3-bit (0 for proportional, 1 for dual, 2 for mono, 3
150 for charcell), which is surely sufficient. */
151 FONT_METRICS_INDEX,
152#endif
153
110 /* In a font-spec, the value is an alist of extra information of a 154 /* In a font-spec, the value is an alist of extra information of a
111 font such as name, OpenType features, and language coverage. 155 font such as name, OpenType features, and language coverage.
112 In a font-entity, the value is an extra infomation for 156 In addition, in a font-entity, the value may contain a pair
113 identifying a font (font-driver dependent). */ 157 (font-entity . INFO) where INFO is an extra infomation to
158 identify a font (font-driver dependent). */
114 FONT_EXTRA_INDEX, /* alist alist */ 159 FONT_EXTRA_INDEX, /* alist alist */
115 160
116 /* This value is the length of font-spec vector. */ 161 /* This value is the length of font-spec vector. */
@@ -118,48 +163,224 @@ enum font_property_index
118 163
119 /* The followings are used only for a font-entity. */ 164 /* The followings are used only for a font-entity. */
120 165
121 /* Frame on which the font is found. The value is nil if the font 166 /* List of font-objects opened from the font-entity. */
122 can be opend on any frame. */ 167 FONT_OBJLIST_INDEX = FONT_SPEC_MAX,
123 FONT_FRAME_INDEX = FONT_SPEC_MAX,
124
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. */
127 FONT_OBJLIST_INDEX,
128 168
129 /* This value is the length of font-entity vector. */ 169 /* This value is the length of font-entity vector. */
130 FONT_ENTITY_MAX 170 FONT_ENTITY_MAX,
171
172 /* XLFD name of the font (string). */
173 FONT_NAME_INDEX = FONT_ENTITY_MAX,
174
175 /* Full name of the font (string). It is the name extracted from
176 the opend font, and may be different from the above. It may be
177 nil if the opened font doesn't give a name. */
178 FONT_FULLNAME_INDEX,
179
180 /* File name of the font or nil if a file associated with the font
181 is not available. */
182 FONT_FILE_INDEX,
183
184 /* Format of the font (symbol). */
185 FONT_FORMAT_INDEX,
186
187 /* This value is the length of font-object vector. */
188 FONT_OBJECT_MAX
131 }; 189 };
132 190
133extern Lisp_Object QCspacing, QCdpi, QCscalable, QCotf, QClanguage, QCscript; 191/* Return the numeric weight value of FONT. */
192#define FONT_WEIGHT_NUMERIC(font) \
193 (INTEGERP (AREF ((font), FONT_WEIGHT_INDEX)) \
194 ? (XINT (AREF ((font), FONT_WEIGHT_INDEX)) >> 8) : -1)
195/* Return the numeric slant value of FONT. */
196#define FONT_SLANT_NUMERIC(font) \
197 (INTEGERP (AREF ((font), FONT_SLANT_INDEX)) \
198 ? (XINT (AREF ((font), FONT_SLANT_INDEX)) >> 8) : -1)
199/* Return the numeric width value of FONT. */
200#define FONT_WIDTH_NUMERIC(font) \
201 (INTEGERP (AREF ((font), FONT_WIDTH_INDEX)) \
202 ? (XINT (AREF ((font), FONT_WIDTH_INDEX)) >> 8) : -1)
203/* Return the symbolic weight value of FONT. */
204#define FONT_WEIGHT_SYMBOLIC(font) \
205 font_style_symbolic (font, FONT_WEIGHT_INDEX, 0)
206/* Return the symbolic slant value of FONT. */
207#define FONT_SLANT_SYMBOLIC(font) \
208 font_style_symbolic (font, FONT_SLANT_INDEX, 0)
209/* Return the symbolic width value of FONT. */
210#define FONT_WIDTH_SYMBOLIC(font) \
211 font_style_symbolic (font, FONT_WIDTH_INDEX, 0)
212/* Return the face-weight corresponding to the weight of FONT. */
213#define FONT_WEIGHT_FOR_FACE(font) \
214 font_style_symbolic (font, FONT_WEIGHT_INDEX, 1)
215/* Return the face-slant corresponding to the slant of FONT. */
216#define FONT_SLANT_FOR_FACE(font) \
217 font_style_symbolic (font, FONT_SLANT_INDEX, 1)
218/* Return the face-swidth corresponding to the slant of FONT. */
219#define FONT_WIDTH_FOR_FACE(font) \
220 font_style_symbolic (font, FONT_WIDTH_INDEX, 1)
221
222/* Return the numeric weight value corresponding ot the symbol NAME. */
223#define FONT_WEIGHT_NAME_NUMERIC(name) \
224 (font_style_to_value (FONT_WEIGHT_INDEX, (name), 0) >> 8)
225/* Return the numeric slant value corresponding ot the symbol NAME. */
226#define FONT_SLANT_NAME_NUMERIC(name) \
227 (font_style_to_value (FONT_SLANT_INDEX, (name), 0) >> 8)
228/* Return the numeric width value corresponding ot the symbol NAME. */
229#define FONT_WIDTH_NAME_NUMERIC(name) \
230 (font_style_to_value (FONT_WIDTH_INDEX, (name), 0) >> 8)
231
232/* Set the font property PROP of FONT to VAL. PROP is one of
233 style-related font property index (FONT_WEIGHT/SLANT/WIDTH_INDEX).
234 VAL (integer or symbol) is the numeric or symbolic style value. */
235#define FONT_SET_STYLE(font, prop, val) \
236 ASET ((font), prop, make_number (font_style_to_value (prop, val, 1)))
237
238extern Lisp_Object QCspacing, QCdpi, QCscalable, QCotf, QClang, QCscript;
239extern Lisp_Object QCavgwidth, QCfont_entity, QCfc_unknown_spec;
134 240
135/* Important character set symbols. */ 241/* Important character set symbols. */
136extern Lisp_Object Qiso8859_1, Qiso10646_1, Qunicode_bmp, Qunicode_sip; 242extern Lisp_Object Qiso8859_1, Qiso10646_1, Qunicode_bmp, Qunicode_sip;
137 243
138extern Lisp_Object null_string; 244/* Structure for a font-spec. */
139extern Lisp_Object null_vector; 245
246struct font_spec
247{
248 EMACS_UINT size;
249 struct Lisp_Vector *next;
250 Lisp_Object props[FONT_SPEC_MAX];
251};
252
253/* Structure for a font-entity. */
254
255struct font_entity
256{
257 EMACS_UINT size;
258 struct Lisp_Vector *next;
259 Lisp_Object props[FONT_ENTITY_MAX];
260};
140 261
141/* Structure for an opened font. We can safely cast this structure to 262/* A value which may appear in the member `encoding' of struct font
142 "struct font_info". */ 263 indicating that a font itself doesn't tell which encoding to be
264 used. */
265#define FONT_ENCODING_NOT_DECIDED 255
266
267/* Structure for a font-object. */
143 268
144struct font 269struct font
145{ 270{
146 struct font_info font; 271 EMACS_UINT size;
272 struct Lisp_Vector *next;
273
274 /* All Lisp_Object components must come first.
275 That ensures they are all aligned normally. */
147 276
148 /* From which font-entity the font is opened. */ 277 Lisp_Object props[FONT_OBJECT_MAX];
149 Lisp_Object entity; 278
279 /* Beyond here, there should be no more Lisp_Object components. */
280
281 /* Maximum bound width over all existing characters of the font. On
282 X window, this is same as (font->max_bounds.width). */
283 int max_width;
150 284
151 /* By which pixel size the font is opened. */ 285 /* By which pixel size the font is opened. */
152 int pixel_size; 286 int pixel_size;
153 287
154 /* Font-driver for the font. */ 288 /* Height of the font. On X window, this is the same as
155 struct font_driver *driver; 289 (font->ascent + font->descent). */
290 int height;
291
292 /* Width of the space glyph of the font. If the font doesn't have a
293 SPACE glyph, the value is 0. */
294 int space_width;
295
296 /* Average width of glyphs in the font. If the font itself doesn't
297 have that information but has glyphs of ASCII character, the
298 value is the average with of those glyphs. Otherwise, the value
299 is 0. */
300 int average_width;
301
302 /* Minimum glyph width (in pixels). */
303 int min_width;
156 304
157 /* Symbol of font font; x, ttf, pcf, etc, */ 305 /* Ascent and descent of the font (in pixels). */
158 Lisp_Object format; 306 int ascent, descent;
159 307
160 /* File name of the font, or NULL if the font is not associated with 308 /* Vertical pixel width of the underline. If is zero if that
161 a file. */ 309 information is not in the font. */
162 char *file_name; 310 int underline_thickness;
311
312 /* Vertical pixel position (relative to the baseline) of the
313 underline. If it is positive, it is below the baseline. It is
314 negative if that information is not in the font. */
315 int underline_position;
316
317 /* 1 if `vertical-centering-font-regexp' matches this font name.
318 In this case, we render characters at vartical center positions
319 of lines. */
320 int vertical_centering;
321
322 /* Encoding type of the font. The value is one of
323 0, 1, 2, or 3:
324 0: code points 0x20..0x7F or 0x2020..0x7F7F are used
325 1: code points 0xA0..0xFF or 0xA0A0..0xFFFF are used
326 2: code points 0x20A0..0x7FFF are used
327 3: code points 0xA020..0xFF7F are used
328 If the member `font_encoder' is not NULL, this member is ignored. */
329 unsigned char encoding_type;
330
331 /* The baseline position of a font is normally `ascent' value of the
332 font. However, there exists many fonts which don't set `ascent'
333 an appropriate value to be used as baseline position. This is
334 typical in such ASCII fonts which are designed to be used with
335 Chinese, Japanese, Korean characters. When we use mixture of
336 such fonts and normal fonts (having correct `ascent' value), a
337 display line gets very ugly. Since we have no way to fix it
338 automatically, it is users responsibility to supply well designed
339 fonts or correct `ascent' value of fonts. But, the latter
340 requires heavy work (modifying all bitmap data in BDF files).
341 So, Emacs accepts a private font property
342 `_MULE_BASELINE_OFFSET'. If a font has this property, we
343 calculate the baseline position by subtracting the value from
344 `ascent'. In other words, the value indicates how many bits
345 higher we should draw a character of the font than normal ASCII
346 text for a better looking.
347
348 We also have to consider the fact that the concept of `baseline'
349 differs among scripts to which each character belongs. For
350 instance, baseline should be at the bottom most position of all
351 glyphs for Chinese, Japanese, and Korean. But, many of existing
352 fonts for those characters doesn't have correct `ascent' values
353 because they are designed to be used with ASCII fonts. To
354 display characters of different language on the same line, the
355 best way will be to arrange them in the middle of the line. So,
356 in such a case, again, we utilize the font property
357 `_MULE_BASELINE_OFFSET'. If the value is larger than `ascent' we
358 calculate baseline so that a character is arranged in the middle
359 of a line. */
360 int baseline_offset;
361
362 /* Non zero means a character should be composed at a position
363 relative to the height (or depth) of previous glyphs in the
364 following cases:
365 (1) The bottom of the character is higher than this value. In
366 this case, the character is drawn above the previous glyphs.
367 (2) The top of the character is lower than 0 (i.e. baseline
368 height). In this case, the character is drawn beneath the
369 previous glyphs.
370
371 This value is taken from a private font property
372 `_MULE_RELATIVE_COMPOSE' which is introduced by Emacs. */
373 int relative_compose;
374
375 /* Non zero means an ascent value to be used for a character
376 registered in char-table `use-default-ascent'. */
377 int default_ascent;
378
379 /* CCL program to calculate code points of the font. */
380 struct ccl_program *font_encoder;
381
382 /* Font-driver for the font. */
383 struct font_driver *driver;
163 384
164 /* Charset to encode a character code into a glyph code of the font. 385 /* 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 386 -1 means that the font doesn't require this information to encode
@@ -171,15 +392,6 @@ struct font
171 determine it. */ 392 determine it. */
172 int repertory_charset; 393 int repertory_charset;
173 394
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
180 /* 1 iff the font is scalable. */
181 int scalable;
182
183 /* There will be more to this structure, but they are private to a 395 /* There will be more to this structure, but they are private to a
184 font-driver. */ 396 font-driver. */
185}; 397};
@@ -212,20 +424,23 @@ struct font_bitmap
212 424
213/* Predicates to check various font-related objects. */ 425/* Predicates to check various font-related objects. */
214 426
427/* 1 iff X is one of font-spec, font-entity, and font-object. */
428#define FONTP(x) PSEUDOVECTORP (x, PVEC_FONT)
429/* 1 iff X is font-spec. */
215#define FONT_SPEC_P(x) \ 430#define FONT_SPEC_P(x) \
216 (VECTORP (x) && ASIZE (x) == FONT_SPEC_MAX) 431 (FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_SPEC_MAX)
432/* 1 iff X is font-entity. */
217#define FONT_ENTITY_P(x) \ 433#define FONT_ENTITY_P(x) \
218 (VECTORP (x) && ASIZE (x) == FONT_ENTITY_MAX) 434 (FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_ENTITY_MAX)
435/* 1 iff X is font-object. */
219#define FONT_OBJECT_P(x) \ 436#define FONT_OBJECT_P(x) \
220 (XTYPE (x) == Lisp_Misc && XMISCTYPE (x) == Lisp_Misc_Save_Value) 437 (FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_OBJECT_MAX)
221#define FONTP(x) \
222 ((VECTORP (x) && (ASIZE (x) == FONT_SPEC_MAX \
223 || ASIZE (x) == FONT_ENTITY_MAX)) \
224 || FONT_OBJECT_P (x))
225 438
439/* 1 iff ENTITY can't be loaded. */
226#define FONT_ENTITY_NOT_LOADABLE(entity) \ 440#define FONT_ENTITY_NOT_LOADABLE(entity) \
227 EQ (AREF (entity, FONT_OBJLIST_INDEX), Qt) 441 EQ (AREF (entity, FONT_OBJLIST_INDEX), Qt)
228 442
443/* Flag ENTITY not loadable. */
229#define FONT_ENTITY_SET_NOT_LOADABLE(entity) \ 444#define FONT_ENTITY_SET_NOT_LOADABLE(entity) \
230 ASET (entity, FONT_OBJLIST_INDEX, Qt) 445 ASET (entity, FONT_OBJLIST_INDEX, Qt)
231 446
@@ -235,19 +450,37 @@ struct font_bitmap
235#define CHECK_FONT(x) \ 450#define CHECK_FONT(x) \
236 do { if (! FONTP (x)) wrong_type_argument (Qfont, x); } while (0) 451 do { if (! FONTP (x)) wrong_type_argument (Qfont, x); } while (0)
237#define CHECK_FONT_SPEC(x) \ 452#define CHECK_FONT_SPEC(x) \
238 do { if (! FONT_SPEC_P (x)) wrong_type_argument (Qfont, x); } while (0) 453 do { if (! FONT_SPEC_P (x)) wrong_type_argument (Qfont_spec, x); } while (0)
239#define CHECK_FONT_ENTITY(x) \ 454#define CHECK_FONT_ENTITY(x) \
240 do { if (! FONT_ENTITY_P (x)) wrong_type_argument (Qfont, x); } while (0) 455 do { if (! FONT_ENTITY_P (x)) wrong_type_argument (Qfont_entity, x); } while (0)
241#define CHECK_FONT_OBJECT(x) \ 456#define CHECK_FONT_OBJECT(x) \
242 do { if (! FONT_OBJECT_P (x)) wrong_type_argument (Qfont, x); } while (0) 457 do { if (! FONT_OBJECT_P (x)) wrong_type_argument (Qfont_object, x); } while (0)
243 458
244#define CHECK_FONT_GET_OBJECT(x, font) \ 459#define CHECK_FONT_GET_OBJECT(x, font) \
245 do { \ 460 do { \
246 if (! FONT_OBJECT_P (x)) wrong_type_argument (Qfont, x); \ 461 CHECK_FONT_OBJECT (x); \
247 if (! XSAVE_VALUE (x)->pointer) error ("Font already closed"); \ 462 font = XFONT_OBJECT (x); \
248 font = XSAVE_VALUE (x)->pointer; \
249 } while (0) 463 } while (0)
250 464
465#define XFONT_SPEC(p) \
466 (eassert (FONT_SPEC_P(p)), (struct font_spec *) XPNTR (p))
467#define XFONT_ENTITY(p) \
468 (eassert (FONT_ENTITY_P(p)), (struct font_entity *) XPNTR (p))
469#define XFONT_OBJECT(p) \
470 (eassert (FONT_OBJECT_P(p)), (struct font *) XPNTR (p))
471#define XSETFONT(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FONT))
472
473/* Number of pt per inch (from the TeXbook). */
474#define PT_PER_INCH 72.27
475
476/* Return a pixel size (integer) corresponding to POINT size (double)
477 on resolution DPI. */
478#define POINT_TO_PIXEL(POINT, DPI) ((POINT) * (DPI) / PT_PER_INCH + 0.5)
479
480/* Return a point size (double) corresponding to POINT size (integer)
481 on resolution DPI. */
482#define PIXEL_TO_POINT(PIXEL, DPI) ((PIXEL) * PT_PER_INCH / (DPI) + 0.5)
483
251/* Ignore the difference of font pixel sizes less than or equal to 484/* Ignore the difference of font pixel sizes less than or equal to
252 this value. */ 485 this value. */
253#define FONT_PIXEL_SIZE_QUANTUM 1 486#define FONT_PIXEL_SIZE_QUANTUM 1
@@ -334,13 +567,19 @@ struct font_driver
334 /* Symbol indicating the type of the font-driver. */ 567 /* Symbol indicating the type of the font-driver. */
335 Lisp_Object type; 568 Lisp_Object type;
336 569
570 /* 1 iff the font's foundary, family, and adstyle names are case
571 sensitve. */
572 int case_sensitive;
573
337 /* Return a cache of font-entities on frame F. The cache must be a 574 /* Return a cache of font-entities on frame F. The cache must be a
338 cons whose cdr part is the actual cache area. */ 575 cons whose cdr part is the actual cache area. */
339 Lisp_Object (*get_cache) P_ ((FRAME_PTR F)); 576 Lisp_Object (*get_cache) P_ ((FRAME_PTR F));
340 577
341 /* List fonts exactly matching with FONT_SPEC on FRAME. The value 578 /* List fonts exactly matching with FONT_SPEC on FRAME. The value
342 is a vector of font-entities. This is the sole API that 579 is a list of font-entities. It is assured that the properties
343 allocates font-entities. */ 580 WEIGHT to AVGWIDTH are all nil (i.e. not specified) in FONT_SPEC.
581 This and the following `match' are the only APIs that allocate
582 font-entities. */
344 Lisp_Object (*list) P_ ((Lisp_Object frame, Lisp_Object font_spec)); 583 Lisp_Object (*list) P_ ((Lisp_Object frame, Lisp_Object font_spec));
345 584
346 /* Return a font entity most closely maching with FONT_SPEC on 585 /* Return a font entity most closely maching with FONT_SPEC on
@@ -359,8 +598,8 @@ struct font_driver
359 598
360 /* Open a font specified by FONT_ENTITY on frame F. If the font is 599 /* Open a font specified by FONT_ENTITY on frame F. If the font is
361 scalable, open it with PIXEL_SIZE. */ 600 scalable, open it with PIXEL_SIZE. */
362 struct font *(*open) P_ ((FRAME_PTR f, Lisp_Object font_entity, 601 Lisp_Object (*open) P_ ((FRAME_PTR f, Lisp_Object font_entity,
363 int pixel_size)); 602 int pixel_size));
364 603
365 /* Close FONT on frame F. */ 604 /* Close FONT on frame F. */
366 void (*close) P_ ((FRAME_PTR f, struct font *font)); 605 void (*close) P_ ((FRAME_PTR f, struct font *font));
@@ -477,6 +716,12 @@ struct font_driver
477 than the length of LGSTRING, nil should be return. In that case, 716 than the length of LGSTRING, nil should be return. In that case,
478 this function is called again with the larger LGSTRING. */ 717 this function is called again with the larger LGSTRING. */
479 Lisp_Object (*shape) P_ ((Lisp_Object lgstring)); 718 Lisp_Object (*shape) P_ ((Lisp_Object lgstring));
719
720 /* Optional.
721
722 If FONT is usable on frame F, return 0. Otherwise return -1.
723 */
724 int (*check) P_ ((FRAME_PTR F, struct font *font));
480}; 725};
481 726
482 727
@@ -509,49 +754,62 @@ struct font_data_list
509 struct font_data_list *next; 754 struct font_data_list *next;
510}; 755};
511 756
512extern int enable_font_backend;
513
514EXFUN (Ffont_spec, MANY); 757EXFUN (Ffont_spec, MANY);
758EXFUN (Fcopy_font_spec, 1);
759EXFUN (Fmerge_font_spec, 2);
515EXFUN (Ffont_get, 2); 760EXFUN (Ffont_get, 2);
761EXFUN (Ffont_put, 3);
516EXFUN (Flist_fonts, 4); 762EXFUN (Flist_fonts, 4);
763EXFUN (Ffont_family_list, 1);
517EXFUN (Fclear_font_cache, 0); 764EXFUN (Fclear_font_cache, 0);
518EXFUN (Ffont_xlfd_name, 1); 765EXFUN (Ffont_xlfd_name, 1);
519 766
767extern Lisp_Object font_make_spec P_ ((void));
768extern Lisp_Object font_make_entity P_ ((void));
769extern Lisp_Object font_make_object P_ ((int));
770
520extern int font_registry_charsets P_ ((Lisp_Object, struct charset **, 771extern int font_registry_charsets P_ ((Lisp_Object, struct charset **,
521 struct charset **)); 772 struct charset **));
522extern Lisp_Object font_symbolic_weight P_ ((Lisp_Object font)); 773extern int font_style_to_value P_ ((enum font_property_index prop,
523extern Lisp_Object font_symbolic_slant P_ ((Lisp_Object font)); 774 Lisp_Object name, int noerror));
524extern Lisp_Object font_symbolic_width P_ ((Lisp_Object font)); 775extern Lisp_Object font_style_symbolic P_ ((Lisp_Object font,
776 enum font_property_index prop,
777 int for_face));
525 778
526extern int font_match_p P_ ((Lisp_Object spec, Lisp_Object entity)); 779extern int font_match_p P_ ((Lisp_Object spec, Lisp_Object entity));
780extern Lisp_Object font_list_entities P_ ((Lisp_Object frame,
781 Lisp_Object spec));
527 782
528extern Lisp_Object font_find_object P_ ((struct font *font));
529extern Lisp_Object font_get_name P_ ((Lisp_Object font_object)); 783extern Lisp_Object font_get_name P_ ((Lisp_Object font_object));
530extern Lisp_Object font_get_spec P_ ((Lisp_Object font_object)); 784extern Lisp_Object font_spec_from_name P_ ((Lisp_Object font_name));
531extern Lisp_Object font_get_frame P_ ((Lisp_Object font_object)); 785extern Lisp_Object font_get_frame P_ ((Lisp_Object font_object));
532extern int font_has_char P_ ((FRAME_PTR, Lisp_Object, int)); 786extern int font_has_char P_ ((FRAME_PTR, Lisp_Object, int));
533extern unsigned font_encode_char P_ ((Lisp_Object, int)); 787extern unsigned font_encode_char P_ ((Lisp_Object, int));
534 788
535extern int font_set_lface_from_name P_ ((FRAME_PTR f, 789extern void font_clear_prop P_ ((Lisp_Object *attrs,
536 Lisp_Object lface, 790 enum font_property_index prop));
537 Lisp_Object fontname, 791extern void font_update_lface P_ ((FRAME_PTR f, Lisp_Object *attrs));
538 int force_p, int may_fail_p));
539extern Lisp_Object font_find_for_lface P_ ((FRAME_PTR f, Lisp_Object *lface, 792extern Lisp_Object font_find_for_lface P_ ((FRAME_PTR f, Lisp_Object *lface,
540 Lisp_Object spec, int c)); 793 Lisp_Object spec, int c));
541extern Lisp_Object font_open_for_lface P_ ((FRAME_PTR f, Lisp_Object entity, 794extern Lisp_Object font_open_for_lface P_ ((FRAME_PTR f, Lisp_Object entity,
542 Lisp_Object *lface, 795 Lisp_Object *lface,
543 Lisp_Object spec)); 796 Lisp_Object spec));
544extern void font_load_for_face P_ ((FRAME_PTR f, struct face *face)); 797extern Lisp_Object font_load_for_lface P_ ((FRAME_PTR f, Lisp_Object *lface,
798 Lisp_Object spec));
545extern void font_prepare_for_face P_ ((FRAME_PTR f, struct face *face)); 799extern void font_prepare_for_face P_ ((FRAME_PTR f, struct face *face));
800extern void font_done_for_face P_ ((FRAME_PTR f, struct face *face));
801
546extern Lisp_Object font_open_by_name P_ ((FRAME_PTR f, char *name)); 802extern Lisp_Object font_open_by_name P_ ((FRAME_PTR f, char *name));
547extern void font_close_object (FRAME_PTR f, Lisp_Object font_object); 803extern void font_close_object (FRAME_PTR f, Lisp_Object font_object);
548 804
549extern Lisp_Object intern_downcase P_ ((char *str, int len)); 805extern Lisp_Object font_intern_prop P_ ((char *str, int len));
550extern void font_update_sort_order P_ ((int *order)); 806extern void font_update_sort_order P_ ((int *order));
551 807
552extern void font_merge_old_spec P_ ((Lisp_Object name, Lisp_Object family, 808extern void font_parse_family_registry P_ ((Lisp_Object family,
553 Lisp_Object registry, Lisp_Object spec)); 809 Lisp_Object registry,
554 810 Lisp_Object spec));
811extern Lisp_Object font_spec_from_family_registry P_ ((Lisp_Object family,
812 Lisp_Object registry));
555 813
556extern int font_parse_xlfd P_ ((char *name, Lisp_Object font)); 814extern int font_parse_xlfd P_ ((char *name, Lisp_Object font));
557extern int font_unparse_xlfd P_ ((Lisp_Object font, int pixel_size, 815extern int font_unparse_xlfd P_ ((Lisp_Object font, int pixel_size,
@@ -564,6 +822,9 @@ extern void free_font_driver_list P_ ((FRAME_PTR f));
564extern Lisp_Object font_update_drivers P_ ((FRAME_PTR f, Lisp_Object list)); 822extern Lisp_Object font_update_drivers P_ ((FRAME_PTR f, Lisp_Object list));
565extern Lisp_Object font_at P_ ((int c, EMACS_INT pos, struct face *face, 823extern Lisp_Object font_at P_ ((int c, EMACS_INT pos, struct face *face,
566 struct window *w, Lisp_Object object)); 824 struct window *w, Lisp_Object object));
825extern EMACS_INT font_range P_ ((EMACS_INT pos, EMACS_INT limit,
826 struct face *face, FRAME_PTR f,
827 Lisp_Object object));
567 828
568extern struct font *font_prepare_composition P_ ((struct composition *cmp, 829extern struct font *font_prepare_composition P_ ((struct composition *cmp,
569 FRAME_PTR f)); 830 FRAME_PTR f));