Mercurial > emacs
comparison src/xdisp.c @ 94937:18a1217b0d5e
Throughout the file, delete all USE_FONT_BACKEND
conditionals. Don't check enable_font_backend. Delete all codes
used only when USE_FONT_BACKEND is not defined.
(handle_auto_composed_prop): Do nothing if it->f is not on a
window system. Check how many following characters can be
displayed by the same font.
(calc_pixel_width_or_height): Type of the 4th arg is changed to
'struct font *'.
(get_char_face_and_encoding): Assign the whole encoding task to
the `encode-char' method of a font driver.
(fill_composite_glyph_string): Adjusted for the change of `struct
face' and `struct glyph_string'.
(fill_glyph_string): Likewise.
(get_per_char_metric): Arguments changed.
(x_get_glyph_overhangs): Adjusted for the change of `struct face'
and `struct glyph_string'.
(produce_stretch_glyph, calc_line_height_property)
(x_produce_glyphs): Likewise.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 14 May 2008 01:40:23 +0000 |
parents | df6f9d73861f |
children | 8971ddf55736 |
comparison
equal
deleted
inserted
replaced
94936:abd9e2a3d739 | 94937:18a1217b0d5e |
---|---|
201 #ifdef MAC_OS | 201 #ifdef MAC_OS |
202 #include "macterm.h" | 202 #include "macterm.h" |
203 #endif | 203 #endif |
204 | 204 |
205 #ifdef HAVE_WINDOW_SYSTEM | 205 #ifdef HAVE_WINDOW_SYSTEM |
206 #ifdef USE_FONT_BACKEND | |
207 #include "font.h" | 206 #include "font.h" |
208 #endif /* USE_FONT_BACKEND */ | |
209 #endif /* HAVE_WINDOW_SYSTEM */ | 207 #endif /* HAVE_WINDOW_SYSTEM */ |
210 | 208 |
211 #ifndef FRAME_X_OUTPUT | 209 #ifndef FRAME_X_OUTPUT |
212 #define FRAME_X_OUTPUT(f) ((f)->output_data.x) | 210 #define FRAME_X_OUTPUT(f) ((f)->output_data.x) |
213 #endif | 211 #endif |
4571 handle_auto_composed_prop (it) | 4569 handle_auto_composed_prop (it) |
4572 struct it *it; | 4570 struct it *it; |
4573 { | 4571 { |
4574 enum prop_handled handled = HANDLED_NORMALLY; | 4572 enum prop_handled handled = HANDLED_NORMALLY; |
4575 | 4573 |
4576 if (FUNCTIONP (Vauto_composition_function)) | 4574 if (FRAME_WINDOW_P (it->f) && FUNCTIONP (Vauto_composition_function)) |
4577 { | 4575 { |
4578 Lisp_Object val = Qnil; | 4576 Lisp_Object val = Qnil; |
4579 EMACS_INT pos, limit = -1; | 4577 EMACS_INT pos, limit = -1; |
4580 | 4578 |
4581 if (STRINGP (it->string)) | 4579 if (STRINGP (it->string)) |
4587 if (! NILP (val)) | 4585 if (! NILP (val)) |
4588 { | 4586 { |
4589 Lisp_Object cmp_prop; | 4587 Lisp_Object cmp_prop; |
4590 EMACS_INT cmp_start, cmp_end; | 4588 EMACS_INT cmp_start, cmp_end; |
4591 | 4589 |
4592 #ifdef USE_FONT_BACKEND | 4590 if (get_property_and_range (pos, Qcomposition, &cmp_prop, |
4593 if (enable_font_backend | 4591 &cmp_start, &cmp_end, it->string) |
4594 && get_property_and_range (pos, Qcomposition, &cmp_prop, | |
4595 &cmp_start, &cmp_end, it->string) | |
4596 && cmp_start == pos | 4592 && cmp_start == pos |
4597 && COMPOSITION_METHOD (cmp_prop) == COMPOSITION_WITH_GLYPH_STRING) | 4593 && COMPOSITION_METHOD (cmp_prop) == COMPOSITION_WITH_GLYPH_STRING) |
4598 { | 4594 { |
4599 Lisp_Object gstring = COMPOSITION_COMPONENTS (cmp_prop); | 4595 Lisp_Object gstring = COMPOSITION_COMPONENTS (cmp_prop); |
4600 Lisp_Object font_object = LGSTRING_FONT (gstring); | 4596 Lisp_Object font_object = LGSTRING_FONT (gstring); |
4604 it->w, it->string))) | 4600 it->w, it->string))) |
4605 /* We must re-compute the composition for the | 4601 /* We must re-compute the composition for the |
4606 different font. */ | 4602 different font. */ |
4607 val = Qnil; | 4603 val = Qnil; |
4608 } | 4604 } |
4609 #endif | 4605 |
4610 if (! NILP (val)) | 4606 if (! NILP (val)) |
4611 { | 4607 { |
4612 Lisp_Object end; | 4608 Lisp_Object end; |
4613 | 4609 |
4614 /* As Fnext_single_char_property_change is very slow, we | 4610 /* As Fnext_single_char_property_change is very slow, we |
4639 if (pos < limit) | 4635 if (pos < limit) |
4640 { | 4636 { |
4641 int count = SPECPDL_INDEX (); | 4637 int count = SPECPDL_INDEX (); |
4642 Lisp_Object args[5]; | 4638 Lisp_Object args[5]; |
4643 | 4639 |
4640 limit = font_range (pos, limit, FACE_FROM_ID (it->f, it->face_id), | |
4641 it->f, it->string); | |
4644 args[0] = Vauto_composition_function; | 4642 args[0] = Vauto_composition_function; |
4645 specbind (Qauto_composition_function, Qnil); | 4643 specbind (Qauto_composition_function, Qnil); |
4646 args[1] = make_number (pos); | 4644 args[1] = make_number (pos); |
4647 args[2] = make_number (limit); | 4645 args[2] = make_number (limit); |
4648 #ifdef USE_FONT_BACKEND | 4646 args[3] = it->window; |
4649 if (enable_font_backend) | |
4650 args[3] = it->window; | |
4651 else | |
4652 #endif /* USE_FONT_BACKEND */ | |
4653 args[3] = Qnil; | |
4654 args[4] = it->string; | 4647 args[4] = it->string; |
4655 safe_call (5, args); | 4648 safe_call (5, args); |
4656 unbind_to (count, Qnil); | 4649 unbind_to (count, Qnil); |
4657 } | 4650 } |
4658 } | 4651 } |
4735 it->method = GET_FROM_COMPOSITION; | 4728 it->method = GET_FROM_COMPOSITION; |
4736 it->cmp_id = id; | 4729 it->cmp_id = id; |
4737 it->cmp_len = COMPOSITION_LENGTH (prop); | 4730 it->cmp_len = COMPOSITION_LENGTH (prop); |
4738 /* For a terminal, draw only the first (non-TAB) character | 4731 /* For a terminal, draw only the first (non-TAB) character |
4739 of the components. */ | 4732 of the components. */ |
4740 #ifdef USE_FONT_BACKEND | |
4741 if (composition_table[id]->method == COMPOSITION_WITH_GLYPH_STRING) | 4733 if (composition_table[id]->method == COMPOSITION_WITH_GLYPH_STRING) |
4742 { | 4734 { |
4743 /* FIXME: This doesn't do anything!?! */ | 4735 /* FIXME: This doesn't do anything!?! */ |
4744 Lisp_Object lgstring = AREF (XHASH_TABLE (composition_hash_table) | 4736 Lisp_Object lgstring = AREF (XHASH_TABLE (composition_hash_table) |
4745 ->key_and_value, | 4737 ->key_and_value, |
4746 cmp->hash_index * 2); | 4738 cmp->hash_index * 2); |
4747 } | 4739 } |
4748 else | 4740 else |
4749 #endif /* USE_FONT_BACKEND */ | |
4750 { | 4741 { |
4751 int i; | 4742 int i; |
4752 | 4743 |
4753 for (i = 0; i < cmp->glyph_len; i++) | 4744 for (i = 0; i < cmp->glyph_len; i++) |
4754 if ((it->c = COMPOSITION_GLYPH (composition_table[id], i)) | 4745 if ((it->c = COMPOSITION_GLYPH (composition_table[id], i)) |
18814 int | 18805 int |
18815 calc_pixel_width_or_height (res, it, prop, font, width_p, align_to) | 18806 calc_pixel_width_or_height (res, it, prop, font, width_p, align_to) |
18816 double *res; | 18807 double *res; |
18817 struct it *it; | 18808 struct it *it; |
18818 Lisp_Object prop; | 18809 Lisp_Object prop; |
18819 void *font; | 18810 struct font *font; |
18820 int width_p, *align_to; | 18811 int width_p, *align_to; |
18821 { | 18812 { |
18822 double pixels; | 18813 double pixels; |
18823 | 18814 |
18824 #define OK_PIXELS(val) ((*res = (double)(val)), 1) | 18815 #define OK_PIXELS(val) ((*res = (double)(val)), 1) |
18867 } | 18858 } |
18868 } | 18859 } |
18869 | 18860 |
18870 #ifdef HAVE_WINDOW_SYSTEM | 18861 #ifdef HAVE_WINDOW_SYSTEM |
18871 if (EQ (prop, Qheight)) | 18862 if (EQ (prop, Qheight)) |
18872 return OK_PIXELS (font ? FONT_HEIGHT ((XFontStruct *)font) : FRAME_LINE_HEIGHT (it->f)); | 18863 return OK_PIXELS (font ? FONT_HEIGHT (font) : FRAME_LINE_HEIGHT (it->f)); |
18873 if (EQ (prop, Qwidth)) | 18864 if (EQ (prop, Qwidth)) |
18874 return OK_PIXELS (font ? FONT_WIDTH ((XFontStruct *)font) : FRAME_COLUMN_WIDTH (it->f)); | 18865 return OK_PIXELS (font ? FONT_WIDTH (font) : FRAME_COLUMN_WIDTH (it->f)); |
18875 #else | 18866 #else |
18876 if (EQ (prop, Qheight) || EQ (prop, Qwidth)) | 18867 if (EQ (prop, Qheight) || EQ (prop, Qwidth)) |
18877 return OK_PIXELS (1); | 18868 return OK_PIXELS (1); |
18878 #endif | 18869 #endif |
18879 | 18870 |
19152 XChar2b *char2b; | 19143 XChar2b *char2b; |
19153 int multibyte_p, display_p; | 19144 int multibyte_p, display_p; |
19154 { | 19145 { |
19155 struct face *face = FACE_FROM_ID (f, face_id); | 19146 struct face *face = FACE_FROM_ID (f, face_id); |
19156 | 19147 |
19157 #ifdef USE_FONT_BACKEND | 19148 if (face->font) |
19158 if (enable_font_backend) | 19149 { |
19159 { | 19150 unsigned code = face->font->driver->encode_char (face->font, c); |
19160 struct font *font = (struct font *) face->font_info; | 19151 |
19161 | 19152 if (code != FONT_INVALID_CODE) |
19162 if (font) | 19153 STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF)); |
19163 { | |
19164 unsigned code = font->driver->encode_char (font, c); | |
19165 | |
19166 if (code != FONT_INVALID_CODE) | |
19167 STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF)); | |
19168 else | |
19169 STORE_XCHAR2B (char2b, 0, 0); | |
19170 } | |
19171 } | |
19172 else | |
19173 #endif /* USE_FONT_BACKEND */ | |
19174 if (!multibyte_p) | |
19175 { | |
19176 /* Unibyte case. We don't have to encode, but we have to make | |
19177 sure to use a face suitable for unibyte. */ | |
19178 STORE_XCHAR2B (char2b, 0, c); | |
19179 face_id = FACE_FOR_CHAR (f, face, c, -1, Qnil); | |
19180 face = FACE_FROM_ID (f, face_id); | |
19181 } | |
19182 else if (c < 128) | |
19183 { | |
19184 /* Case of ASCII in a face known to fit ASCII. */ | |
19185 STORE_XCHAR2B (char2b, 0, c); | |
19186 } | |
19187 else if (face->font != NULL) | |
19188 { | |
19189 struct font_info *font_info | |
19190 = FONT_INFO_FROM_ID (f, face->font_info_id); | |
19191 struct charset *charset = CHARSET_FROM_ID (font_info->charset); | |
19192 unsigned code = ENCODE_CHAR (charset, c); | |
19193 | |
19194 if (CHARSET_DIMENSION (charset) == 1) | |
19195 STORE_XCHAR2B (char2b, 0, code); | |
19196 else | 19154 else |
19197 STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF)); | 19155 STORE_XCHAR2B (char2b, 0, 0); |
19198 /* Maybe encode the character in *CHAR2B. */ | |
19199 FRAME_RIF (f)->encode_char (c, char2b, font_info, charset, NULL); | |
19200 } | 19156 } |
19201 | 19157 |
19202 /* Make sure X resources of the face are allocated. */ | 19158 /* Make sure X resources of the face are allocated. */ |
19203 #ifdef HAVE_X_WINDOWS | 19159 #ifdef HAVE_X_WINDOWS |
19204 if (display_p) | 19160 if (display_p) |
19229 face = FACE_FROM_ID (f, glyph->face_id); | 19185 face = FACE_FROM_ID (f, glyph->face_id); |
19230 | 19186 |
19231 if (two_byte_p) | 19187 if (two_byte_p) |
19232 *two_byte_p = 0; | 19188 *two_byte_p = 0; |
19233 | 19189 |
19234 #ifdef USE_FONT_BACKEND | 19190 if (face->font) |
19235 if (enable_font_backend) | 19191 { |
19236 { | 19192 unsigned code = face->font->driver->encode_char (face->font, glyph->u.ch); |
19237 struct font *font = (struct font *) face->font_info; | 19193 |
19238 | 19194 if (code != FONT_INVALID_CODE) |
19239 if (font) | 19195 STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF)); |
19240 { | 19196 else |
19241 unsigned code = font->driver->encode_char (font, glyph->u.ch); | 19197 STORE_XCHAR2B (char2b, 0, code); |
19242 | |
19243 if (code != FONT_INVALID_CODE) | |
19244 STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF)); | |
19245 else | |
19246 STORE_XCHAR2B (char2b, 0, code); | |
19247 } | |
19248 } | |
19249 else | |
19250 #endif /* USE_FONT_BACKEND */ | |
19251 if (!glyph->multibyte_p) | |
19252 { | |
19253 /* Unibyte case. We don't have to encode, but we have to make | |
19254 sure to use a face suitable for unibyte. */ | |
19255 STORE_XCHAR2B (char2b, 0, glyph->u.ch); | |
19256 } | |
19257 else if (glyph->u.ch < 128) | |
19258 { | |
19259 /* Case of ASCII in a face known to fit ASCII. */ | |
19260 STORE_XCHAR2B (char2b, 0, glyph->u.ch); | |
19261 } | |
19262 else | |
19263 { | |
19264 struct font_info *font_info | |
19265 = FONT_INFO_FROM_ID (f, face->font_info_id); | |
19266 if (font_info) | |
19267 { | |
19268 struct charset *charset = CHARSET_FROM_ID (font_info->charset); | |
19269 unsigned code = ENCODE_CHAR (charset, glyph->u.ch); | |
19270 | |
19271 if (CHARSET_DIMENSION (charset) == 1) | |
19272 STORE_XCHAR2B (char2b, 0, code); | |
19273 else | |
19274 STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF)); | |
19275 | |
19276 /* Maybe encode the character in *CHAR2B. */ | |
19277 if (CHARSET_ID (charset) != charset_ascii) | |
19278 { | |
19279 glyph->font_type | |
19280 = FRAME_RIF (f)->encode_char (glyph->u.ch, char2b, font_info, | |
19281 charset, two_byte_p); | |
19282 } | |
19283 } | |
19284 } | 19198 } |
19285 | 19199 |
19286 /* Make sure X resources of the face are allocated. */ | 19200 /* Make sure X resources of the face are allocated. */ |
19287 xassert (face != NULL); | 19201 xassert (face != NULL); |
19288 PREPARE_FACE_FOR_DISPLAY (f, face); | 19202 PREPARE_FACE_FOR_DISPLAY (f, face); |
19310 | 19224 |
19311 xassert (s); | 19225 xassert (s); |
19312 | 19226 |
19313 s->for_overlaps = overlaps; | 19227 s->for_overlaps = overlaps; |
19314 | 19228 |
19315 #ifdef USE_FONT_BACKEND | 19229 if (s->cmp->method == COMPOSITION_WITH_GLYPH_STRING) |
19316 if (enable_font_backend && s->cmp->method == COMPOSITION_WITH_GLYPH_STRING) | |
19317 { | 19230 { |
19318 Lisp_Object gstring | 19231 Lisp_Object gstring |
19319 = AREF (XHASH_TABLE (composition_hash_table)->key_and_value, | 19232 = AREF (XHASH_TABLE (composition_hash_table)->key_and_value, |
19320 s->cmp->hash_index * 2); | 19233 s->cmp->hash_index * 2); |
19321 | 19234 |
19322 s->face = base_face; | 19235 s->face = base_face; |
19323 s->font_info = base_face->font_info; | 19236 s->font = base_face->font; |
19324 s->font = s->font_info->font; | |
19325 for (i = 0, s->nchars = 0; i < s->cmp->glyph_len; i++, s->nchars++) | 19237 for (i = 0, s->nchars = 0; i < s->cmp->glyph_len; i++, s->nchars++) |
19326 { | 19238 { |
19327 Lisp_Object g = LGSTRING_GLYPH (gstring, i); | 19239 Lisp_Object g = LGSTRING_GLYPH (gstring, i); |
19328 unsigned code; | 19240 unsigned code; |
19329 XChar2b * store_pos; | 19241 XChar2b * store_pos; |
19334 STORE_XCHAR2B (store_pos, code >> 8, code & 0xFF); | 19246 STORE_XCHAR2B (store_pos, code >> 8, code & 0xFF); |
19335 } | 19247 } |
19336 s->width = s->cmp->pixel_width; | 19248 s->width = s->cmp->pixel_width; |
19337 } | 19249 } |
19338 else | 19250 else |
19339 #endif /* USE_FONT_BACKEND */ | |
19340 { | 19251 { |
19341 /* For all glyphs of this composition, starting at the offset | 19252 /* For all glyphs of this composition, starting at the offset |
19342 S->gidx, until we reach the end of the definition or encounter a | 19253 S->gidx, until we reach the end of the definition or encounter a |
19343 glyph that requires the different face, add it to S. */ | 19254 glyph that requires the different face, add it to S. */ |
19344 struct face *face; | 19255 struct face *face; |
19345 | 19256 |
19346 s->face = NULL; | 19257 s->face = NULL; |
19347 s->font = NULL; | 19258 s->font = NULL; |
19348 s->font_info = NULL; | |
19349 for (i = s->gidx; i < s->cmp->glyph_len; i++) | 19259 for (i = s->gidx; i < s->cmp->glyph_len; i++) |
19350 { | 19260 { |
19351 int c = COMPOSITION_GLYPH (s->cmp, i); | 19261 int c = COMPOSITION_GLYPH (s->cmp, i); |
19352 | 19262 |
19353 if (c != '\t') | 19263 if (c != '\t') |
19361 { | 19271 { |
19362 if (! s->face) | 19272 if (! s->face) |
19363 { | 19273 { |
19364 s->face = face; | 19274 s->face = face; |
19365 s->font = s->face->font; | 19275 s->font = s->face->font; |
19366 s->font_info = FONT_INFO_FROM_FACE (s->f, s->face); | |
19367 } | 19276 } |
19368 else if (s->face != face) | 19277 else if (s->face != face) |
19369 break; | 19278 break; |
19370 } | 19279 } |
19371 } | 19280 } |
19446 if (glyph++->padding_p != s->padding_p) | 19355 if (glyph++->padding_p != s->padding_p) |
19447 break; | 19356 break; |
19448 } | 19357 } |
19449 | 19358 |
19450 s->font = s->face->font; | 19359 s->font = s->face->font; |
19451 s->font_info = FONT_INFO_FROM_FACE (s->f, s->face); | |
19452 | 19360 |
19453 /* If the specified font could not be loaded, use the frame's font, | 19361 /* If the specified font could not be loaded, use the frame's font, |
19454 but record the fact that we couldn't load it in | 19362 but record the fact that we couldn't load it in |
19455 S->font_not_found_p so that we can draw rectangles for the | 19363 S->font_not_found_p so that we can draw rectangles for the |
19456 characters of the glyph string. */ | 19364 characters of the glyph string. */ |
19510 glyph = s->row->glyphs[s->area] + start; | 19418 glyph = s->row->glyphs[s->area] + start; |
19511 last = s->row->glyphs[s->area] + end; | 19419 last = s->row->glyphs[s->area] + end; |
19512 face_id = glyph->face_id; | 19420 face_id = glyph->face_id; |
19513 s->face = FACE_FROM_ID (s->f, face_id); | 19421 s->face = FACE_FROM_ID (s->f, face_id); |
19514 s->font = s->face->font; | 19422 s->font = s->face->font; |
19515 s->font_info = FONT_INFO_FROM_FACE (s->f, s->face); | |
19516 s->width = glyph->pixel_width; | 19423 s->width = glyph->pixel_width; |
19517 s->nchars = 1; | 19424 s->nchars = 1; |
19518 voffset = glyph->voffset; | 19425 voffset = glyph->voffset; |
19519 | 19426 |
19520 for (++glyph; | 19427 for (++glyph; |
19532 string by calling PREPARE_FACE_FOR_DISPLAY. */ | 19439 string by calling PREPARE_FACE_FOR_DISPLAY. */ |
19533 xassert (s->face); | 19440 xassert (s->face); |
19534 return glyph - s->row->glyphs[s->area]; | 19441 return glyph - s->row->glyphs[s->area]; |
19535 } | 19442 } |
19536 | 19443 |
19537 static XCharStruct * | 19444 static struct font_metrics * |
19538 get_per_char_metric (f, font, font_info, char2b, font_type) | 19445 get_per_char_metric (f, font, char2b) |
19539 struct frame *f; | 19446 struct frame *f; |
19540 XFontStruct *font; | 19447 struct font *font; |
19541 struct font_info *font_info; | |
19542 XChar2b *char2b; | 19448 XChar2b *char2b; |
19543 int font_type; | 19449 { |
19544 { | 19450 static struct font_metrics metrics; |
19545 #ifdef USE_FONT_BACKEND | 19451 unsigned code = (XCHAR2B_BYTE1 (char2b) << 8) | XCHAR2B_BYTE2 (char2b); |
19546 if (enable_font_backend) | 19452 struct font *fontp; |
19547 { | 19453 |
19548 static XCharStruct pcm_value; | 19454 if (! font || code == FONT_INVALID_CODE) |
19549 unsigned code = (XCHAR2B_BYTE1 (char2b) << 8) | XCHAR2B_BYTE2 (char2b); | 19455 return NULL; |
19550 struct font *fontp; | 19456 font->driver->text_extents (font, &code, 1, &metrics); |
19551 struct font_metrics metrics; | 19457 return &metrics; |
19552 | |
19553 if (! font_info || code == FONT_INVALID_CODE) | |
19554 return NULL; | |
19555 fontp = (struct font *) font_info; | |
19556 fontp->driver->text_extents (fontp, &code, 1, &metrics); | |
19557 pcm_value.lbearing = metrics.lbearing; | |
19558 pcm_value.rbearing = metrics.rbearing; | |
19559 pcm_value.ascent = metrics.ascent; | |
19560 pcm_value.descent = metrics.descent; | |
19561 pcm_value.width = metrics.width; | |
19562 return &pcm_value; | |
19563 } | |
19564 #endif /* USE_FONT_BACKEND */ | |
19565 return FRAME_RIF (f)->per_char_metric (font, char2b, font_type); | |
19566 } | 19458 } |
19567 | 19459 |
19568 /* EXPORT for RIF: | 19460 /* EXPORT for RIF: |
19569 Set *LEFT and *RIGHT to the left and right overhang of GLYPH on | 19461 Set *LEFT and *RIGHT to the left and right overhang of GLYPH on |
19570 frame F. Overhangs of glyphs other than type CHAR_GLYPH are | 19462 frame F. Overhangs of glyphs other than type CHAR_GLYPH are |
19578 { | 19470 { |
19579 *left = *right = 0; | 19471 *left = *right = 0; |
19580 | 19472 |
19581 if (glyph->type == CHAR_GLYPH) | 19473 if (glyph->type == CHAR_GLYPH) |
19582 { | 19474 { |
19583 XFontStruct *font; | |
19584 struct face *face; | 19475 struct face *face; |
19585 struct font_info *font_info; | |
19586 XChar2b char2b; | 19476 XChar2b char2b; |
19587 XCharStruct *pcm; | 19477 struct font_metrics *pcm; |
19588 | 19478 |
19589 face = get_glyph_face_and_encoding (f, glyph, &char2b, NULL); | 19479 face = get_glyph_face_and_encoding (f, glyph, &char2b, NULL); |
19590 font = face->font; | 19480 if (face->font && (pcm = get_per_char_metric (f, face->font, &char2b))) |
19591 font_info = FONT_INFO_FROM_FACE (f, face); | |
19592 if (font /* ++KFS: Should this be font_info ? */ | |
19593 && (pcm = get_per_char_metric (f, font, font_info, &char2b, glyph->font_type))) | |
19594 { | 19481 { |
19595 if (pcm->rbearing > pcm->width) | 19482 if (pcm->rbearing > pcm->width) |
19596 *right = pcm->rbearing - pcm->width; | 19483 *right = pcm->rbearing - pcm->width; |
19597 if (pcm->lbearing < 0) | 19484 if (pcm->lbearing < 0) |
19598 *left = -pcm->lbearing; | 19485 *left = -pcm->lbearing; |
20534 int width = 0, height = 0, align_to = -1; | 20421 int width = 0, height = 0, align_to = -1; |
20535 int zero_width_ok_p = 0, zero_height_ok_p = 0; | 20422 int zero_width_ok_p = 0, zero_height_ok_p = 0; |
20536 int ascent = 0; | 20423 int ascent = 0; |
20537 double tem; | 20424 double tem; |
20538 struct face *face = FACE_FROM_ID (it->f, it->face_id); | 20425 struct face *face = FACE_FROM_ID (it->f, it->face_id); |
20539 XFontStruct *font = face->font ? face->font : FRAME_FONT (it->f); | 20426 struct font *font = face->font ? face->font : FRAME_FONT (it->f); |
20540 | 20427 |
20541 PREPARE_FACE_FOR_DISPLAY (it->f, face); | 20428 PREPARE_FACE_FOR_DISPLAY (it->f, face); |
20542 | 20429 |
20543 /* List should start with `space'. */ | 20430 /* List should start with `space'. */ |
20544 xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace)); | 20431 xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace)); |
20675 | 20562 |
20676 static Lisp_Object | 20563 static Lisp_Object |
20677 calc_line_height_property (it, val, font, boff, override) | 20564 calc_line_height_property (it, val, font, boff, override) |
20678 struct it *it; | 20565 struct it *it; |
20679 Lisp_Object val; | 20566 Lisp_Object val; |
20680 XFontStruct *font; | 20567 struct font *font; |
20681 int boff, override; | 20568 int boff, override; |
20682 { | 20569 { |
20683 Lisp_Object face_name = Qnil; | 20570 Lisp_Object face_name = Qnil; |
20684 int ascent, descent, height; | 20571 int ascent, descent, height; |
20685 | 20572 |
20710 } | 20597 } |
20711 else | 20598 else |
20712 { | 20599 { |
20713 int face_id; | 20600 int face_id; |
20714 struct face *face; | 20601 struct face *face; |
20715 struct font_info *font_info; | |
20716 | 20602 |
20717 face_id = lookup_named_face (it->f, face_name, 0); | 20603 face_id = lookup_named_face (it->f, face_name, 0); |
20718 if (face_id < 0) | 20604 if (face_id < 0) |
20719 return make_number (-1); | 20605 return make_number (-1); |
20720 | 20606 |
20721 face = FACE_FROM_ID (it->f, face_id); | 20607 face = FACE_FROM_ID (it->f, face_id); |
20722 font = face->font; | 20608 font = face->font; |
20723 if (font == NULL) | 20609 if (font == NULL) |
20724 return make_number (-1); | 20610 return make_number (-1); |
20725 | 20611 boff = font->baseline_offset; |
20726 font_info = FONT_INFO_FROM_FACE (it->f, face); | 20612 if (font->vertical_centering) |
20727 boff = font_info->baseline_offset; | |
20728 if (font_info->vertical_centering) | |
20729 boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff; | 20613 boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff; |
20730 } | 20614 } |
20731 | 20615 |
20732 ascent = FONT_BASE (font) + boff; | 20616 ascent = FONT_BASE (font) + boff; |
20733 descent = FONT_DESCENT (font) - boff; | 20617 descent = FONT_DESCENT (font) - boff; |
20765 it->glyph_not_available_p = 0; | 20649 it->glyph_not_available_p = 0; |
20766 | 20650 |
20767 if (it->what == IT_CHARACTER) | 20651 if (it->what == IT_CHARACTER) |
20768 { | 20652 { |
20769 XChar2b char2b; | 20653 XChar2b char2b; |
20770 XFontStruct *font; | 20654 struct font *font; |
20771 struct face *face = FACE_FROM_ID (it->f, it->face_id); | 20655 struct face *face = FACE_FROM_ID (it->f, it->face_id); |
20772 XCharStruct *pcm; | 20656 struct font_metrics *pcm; |
20773 int font_not_found_p; | 20657 int font_not_found_p; |
20774 struct font_info *font_info; | |
20775 int boff; /* baseline offset */ | 20658 int boff; /* baseline offset */ |
20776 /* We may change it->multibyte_p upon unibyte<->multibyte | 20659 /* We may change it->multibyte_p upon unibyte<->multibyte |
20777 conversion. So, save the current value now and restore it | 20660 conversion. So, save the current value now and restore it |
20778 later. | 20661 later. |
20779 | 20662 |
20811 font_not_found_p = font == NULL; | 20694 font_not_found_p = font == NULL; |
20812 if (font_not_found_p) | 20695 if (font_not_found_p) |
20813 { | 20696 { |
20814 font = FRAME_FONT (it->f); | 20697 font = FRAME_FONT (it->f); |
20815 boff = FRAME_BASELINE_OFFSET (it->f); | 20698 boff = FRAME_BASELINE_OFFSET (it->f); |
20816 font_info = NULL; | |
20817 } | 20699 } |
20818 else | 20700 else |
20819 { | 20701 { |
20820 font_info = FONT_INFO_FROM_FACE (it->f, face); | 20702 boff = font->baseline_offset; |
20821 boff = font_info->baseline_offset; | 20703 if (font->vertical_centering) |
20822 if (font_info->vertical_centering) | |
20823 boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff; | 20704 boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff; |
20824 } | 20705 } |
20825 | 20706 |
20826 if (it->char_to_display >= ' ' | 20707 if (it->char_to_display >= ' ' |
20827 && (!it->multibyte_p || it->char_to_display < 128)) | 20708 && (!it->multibyte_p || it->char_to_display < 128)) |
20829 /* Either unibyte or ASCII. */ | 20710 /* Either unibyte or ASCII. */ |
20830 int stretched_p; | 20711 int stretched_p; |
20831 | 20712 |
20832 it->nglyphs = 1; | 20713 it->nglyphs = 1; |
20833 | 20714 |
20834 pcm = get_per_char_metric (it->f, font, font_info, &char2b, | 20715 pcm = get_per_char_metric (it->f, font, &char2b); |
20835 FONT_TYPE_FOR_UNIBYTE (font, it->char_to_display)); | |
20836 | 20716 |
20837 if (it->override_ascent >= 0) | 20717 if (it->override_ascent >= 0) |
20838 { | 20718 { |
20839 it->ascent = it->override_ascent; | 20719 it->ascent = it->override_ascent; |
20840 it->descent = it->override_descent; | 20720 it->descent = it->override_descent; |
21064 metrics. If we didn't find a font, use the frame's | 20944 metrics. If we didn't find a font, use the frame's |
21065 default font and calculate the width of the character by | 20945 default font and calculate the width of the character by |
21066 multiplying the width of font by the width of the | 20946 multiplying the width of font by the width of the |
21067 character. */ | 20947 character. */ |
21068 | 20948 |
21069 pcm = get_per_char_metric (it->f, font, font_info, &char2b, | 20949 pcm = get_per_char_metric (it->f, font, &char2b); |
21070 FONT_TYPE_FOR_MULTIBYTE (font, it->c)); | |
21071 | 20950 |
21072 if (font_not_found_p || !pcm) | 20951 if (font_not_found_p || !pcm) |
21073 { | 20952 { |
21074 int char_width = CHAR_WIDTH (it->char_to_display); | 20953 int char_width = CHAR_WIDTH (it->char_to_display); |
21075 | 20954 |
21145 the overall glyphs composed). */ | 21024 the overall glyphs composed). */ |
21146 struct face *face = FACE_FROM_ID (it->f, it->face_id); | 21025 struct face *face = FACE_FROM_ID (it->f, it->face_id); |
21147 int boff; /* baseline offset */ | 21026 int boff; /* baseline offset */ |
21148 struct composition *cmp = composition_table[it->cmp_id]; | 21027 struct composition *cmp = composition_table[it->cmp_id]; |
21149 int glyph_len = cmp->glyph_len; | 21028 int glyph_len = cmp->glyph_len; |
21150 XFontStruct *font = face->font; | 21029 struct font *font = face->font; |
21151 | 21030 |
21152 it->nglyphs = 1; | 21031 it->nglyphs = 1; |
21153 | 21032 |
21154 #ifdef USE_FONT_BACKEND | |
21155 if (cmp->method == COMPOSITION_WITH_GLYPH_STRING) | 21033 if (cmp->method == COMPOSITION_WITH_GLYPH_STRING) |
21156 { | 21034 { |
21157 PREPARE_FACE_FOR_DISPLAY (it->f, face); | 21035 PREPARE_FACE_FOR_DISPLAY (it->f, face); |
21158 font_prepare_composition (cmp, it->f); | 21036 font_prepare_composition (cmp, it->f); |
21159 } | 21037 } |
21160 else | 21038 else |
21161 #endif /* USE_FONT_BACKEND */ | |
21162 /* If we have not yet calculated pixel size data of glyphs of | 21039 /* If we have not yet calculated pixel size data of glyphs of |
21163 the composition for the current face font, calculate them | 21040 the composition for the current face font, calculate them |
21164 now. Theoretically, we have to check all fonts for the | 21041 now. Theoretically, we have to check all fonts for the |
21165 glyphs, but that requires much time and memory space. So, | 21042 glyphs, but that requires much time and memory space. So, |
21166 here we check only the font of the first glyph. This leads | 21043 here we check only the font of the first glyph. This leads |
21179 int i, width, ascent, descent; | 21056 int i, width, ascent, descent; |
21180 int left_padded = 0, right_padded = 0; | 21057 int left_padded = 0, right_padded = 0; |
21181 int face_id; | 21058 int face_id; |
21182 int c; | 21059 int c; |
21183 XChar2b char2b; | 21060 XChar2b char2b; |
21184 XCharStruct *pcm; | 21061 struct font_metrics *pcm; |
21185 int font_not_found_p; | 21062 int font_not_found_p; |
21186 struct font_info *font_info; | |
21187 int pos; | 21063 int pos; |
21188 | 21064 |
21189 for (glyph_len = cmp->glyph_len; glyph_len > 0; glyph_len--) | 21065 for (glyph_len = cmp->glyph_len; glyph_len > 0; glyph_len--) |
21190 if ((c = COMPOSITION_GLYPH (cmp, glyph_len - 1)) != '\t') | 21066 if ((c = COMPOSITION_GLYPH (cmp, glyph_len - 1)) != '\t') |
21191 break; | 21067 break; |
21207 if (font_not_found_p) | 21083 if (font_not_found_p) |
21208 { | 21084 { |
21209 face = face->ascii_face; | 21085 face = face->ascii_face; |
21210 font = face->font; | 21086 font = face->font; |
21211 } | 21087 } |
21212 font_info = FONT_INFO_FROM_FACE (it->f, face); | 21088 boff = font->baseline_offset; |
21213 boff = font_info->baseline_offset; | 21089 if (font->vertical_centering) |
21214 if (font_info->vertical_centering) | |
21215 boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff; | 21090 boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff; |
21216 font_ascent = FONT_BASE (font) + boff; | 21091 font_ascent = FONT_BASE (font) + boff; |
21217 font_descent = FONT_DESCENT (font) - boff; | 21092 font_descent = FONT_DESCENT (font) - boff; |
21218 font_height = FONT_HEIGHT (font); | 21093 font_height = FONT_HEIGHT (font); |
21219 | 21094 |
21222 pcm = NULL; | 21097 pcm = NULL; |
21223 if (! font_not_found_p) | 21098 if (! font_not_found_p) |
21224 { | 21099 { |
21225 get_char_face_and_encoding (it->f, c, it->face_id, | 21100 get_char_face_and_encoding (it->f, c, it->face_id, |
21226 &char2b, it->multibyte_p, 0); | 21101 &char2b, it->multibyte_p, 0); |
21227 pcm = get_per_char_metric (it->f, font, font_info, &char2b, | 21102 pcm = get_per_char_metric (it->f, font, &char2b); |
21228 FONT_TYPE_FOR_MULTIBYTE (font, c)); | |
21229 } | 21103 } |
21230 | 21104 |
21231 /* Initialize the bounding box. */ | 21105 /* Initialize the bounding box. */ |
21232 if (pcm) | 21106 if (pcm) |
21233 { | 21107 { |
21250 leftmost = 0; | 21124 leftmost = 0; |
21251 lowest = - descent + boff; | 21125 lowest = - descent + boff; |
21252 highest = ascent + boff; | 21126 highest = ascent + boff; |
21253 | 21127 |
21254 if (! font_not_found_p | 21128 if (! font_not_found_p |
21255 && font_info->default_ascent | 21129 && font->default_ascent |
21256 && CHAR_TABLE_P (Vuse_default_ascent) | 21130 && CHAR_TABLE_P (Vuse_default_ascent) |
21257 && !NILP (Faref (Vuse_default_ascent, | 21131 && !NILP (Faref (Vuse_default_ascent, |
21258 make_number (it->char_to_display)))) | 21132 make_number (it->char_to_display)))) |
21259 highest = font_info->default_ascent + boff; | 21133 highest = font->default_ascent + boff; |
21260 | 21134 |
21261 /* Draw the first glyph at the normal position. It may be | 21135 /* Draw the first glyph at the normal position. It may be |
21262 shifted to right later if some other glyphs are drawn | 21136 shifted to right later if some other glyphs are drawn |
21263 at the left. */ | 21137 at the left. */ |
21264 cmp->offsets[i * 2] = 0; | 21138 cmp->offsets[i * 2] = 0; |
21283 | 21157 |
21284 if (font == NULL) | 21158 if (font == NULL) |
21285 pcm = NULL; | 21159 pcm = NULL; |
21286 else | 21160 else |
21287 { | 21161 { |
21288 font_info = FONT_INFO_FROM_FACE (it->f, this_face); | 21162 this_boff = font->baseline_offset; |
21289 this_boff = font_info->baseline_offset; | 21163 if (font->vertical_centering) |
21290 if (font_info->vertical_centering) | |
21291 this_boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff; | 21164 this_boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff; |
21292 get_char_face_and_encoding (it->f, ch, face_id, | 21165 get_char_face_and_encoding (it->f, ch, face_id, |
21293 &char2b, it->multibyte_p, 0); | 21166 &char2b, it->multibyte_p, 0); |
21294 pcm = get_per_char_metric (it->f, font, font_info, &char2b, | 21167 pcm = get_per_char_metric (it->f, font, &char2b); |
21295 FONT_TYPE_FOR_MULTIBYTE (font, | |
21296 ch)); | |
21297 } | 21168 } |
21298 if (! pcm) | 21169 if (! pcm) |
21299 cmp->offsets[i * 2] = cmp->offsets[i * 2 + 1] = 0; | 21170 cmp->offsets[i * 2] = cmp->offsets[i * 2 + 1] = 0; |
21300 else | 21171 else |
21301 { | 21172 { |
21308 { | 21179 { |
21309 /* Relative composition with or without | 21180 /* Relative composition with or without |
21310 alternate chars. */ | 21181 alternate chars. */ |
21311 left = (leftmost + rightmost - width) / 2; | 21182 left = (leftmost + rightmost - width) / 2; |
21312 btm = - descent + boff; | 21183 btm = - descent + boff; |
21313 if (font_info->relative_compose | 21184 if (font->relative_compose |
21314 && (! CHAR_TABLE_P (Vignore_relative_composition) | 21185 && (! CHAR_TABLE_P (Vignore_relative_composition) |
21315 || NILP (Faref (Vignore_relative_composition, | 21186 || NILP (Faref (Vignore_relative_composition, |
21316 make_number (ch))))) | 21187 make_number (ch))))) |
21317 { | 21188 { |
21318 | 21189 |
21319 if (- descent >= font_info->relative_compose) | 21190 if (- descent >= font->relative_compose) |
21320 /* One extra pixel between two glyphs. */ | 21191 /* One extra pixel between two glyphs. */ |
21321 btm = highest + 1; | 21192 btm = highest + 1; |
21322 else if (ascent <= 0) | 21193 else if (ascent <= 0) |
21323 /* One extra pixel between two glyphs. */ | 21194 /* One extra pixel between two glyphs. */ |
21324 btm = lowest - 1 - ascent - descent; | 21195 btm = lowest - 1 - ascent - descent; |