Mercurial > emacs
diff src/macterm.c @ 59718:d4cb255b034d
* dispextern.h (struct glyph_string): New members clip_head and
clip_tail.
* xdisp.c (get_glyph_string_clip_rect): Restrict horizontal clip
region to the area between clip_head and clip_tail.
(draw_glyphs): Record the area that need to be actually redrawn to
the new variables clip_head and clip_tail when there are
overhangs. Set values of these variables to the corresponding
members in struct glyph_string. Refine x coordinates for
* macgui.h (STORE_XCHARSETSTRUCT): New macro.
* macterm.c (mac_compute_glyph_string_overhangs): Implement with
QDTextBounds.
(x_draw_glyph_string): Don't fill the background of the successor
of a glyph with a right overhang if the successor will draw a
cursor.
(XLoadQueryFont): Obtain font metrics using QDTextBounds.
(x_redisplay_interface): Add entry for
compute_glyph_string_overhangs.
| author | Steven Tamm <steventamm@mac.com> |
|---|---|
| date | Mon, 24 Jan 2005 17:59:36 +0000 |
| parents | 369714ad80ed |
| children | 1df465faf1df befae6bafecb |
line wrap: on
line diff
--- a/src/macterm.c Mon Jan 24 13:22:29 2005 +0000 +++ b/src/macterm.c Mon Jan 24 17:59:36 2005 +0000 @@ -1991,20 +1991,33 @@ mac_compute_glyph_string_overhangs (s) struct glyph_string *s; { -#if 0 - /* MAC_TODO: XTextExtents16 does nothing yet... */ - - if (s->cmp == NULL - && s->first_glyph->type == CHAR_GLYPH) - { - XCharStruct cs; - int direction, font_ascent, font_descent; - XTextExtents16 (s->font, s->char2b, s->nchars, &direction, - &font_ascent, &font_descent, &cs); - s->right_overhang = cs.rbearing > cs.width ? cs.rbearing - cs.width : 0; - s->left_overhang = cs.lbearing < 0 ? -cs.lbearing : 0; - } -#endif + Rect r; + MacFontStruct *font = s->font; + + TextFont (font->mac_fontnum); + TextSize (font->mac_fontsize); + TextFace (font->mac_fontface); + + if (s->two_byte_p) + QDTextBounds (s->nchars * 2, (char *)s->char2b, &r); + else + { + int i; + char *buf = xmalloc (s->nchars); + + if (buf == NULL) + SetRect (&r, 0, 0, 0, 0); + else + { + for (i = 0; i < s->nchars; ++i) + buf[i] = s->char2b[i].byte2; + QDTextBounds (s->nchars, buf, &r); + xfree (buf); + } + } + + s->right_overhang = r.right > s->width ? r.right - s->width : 0; + s->left_overhang = r.left < 0 ? -r.left : 0; } @@ -3072,10 +3085,12 @@ { int relief_drawn_p = 0; - /* If S draws into the background of its successor, draw the - background of the successor first so that S can draw into it. - This makes S->next use XDrawString instead of XDrawImageString. */ - if (s->next && s->right_overhang && !s->for_overlaps_p) + /* If S draws into the background of its successor that does not + draw a cursor, draw the background of the successor first so that + S can draw into it. This makes S->next use XDrawString instead + of XDrawImageString. */ + if (s->next && s->right_overhang && !s->for_overlaps_p + && s->next->hl != DRAW_CURSOR) { xassert (s->next->img == NULL); x_set_glyph_string_gc (s->next); @@ -6756,30 +6771,40 @@ returns 15 for 12-point Monaco! */ char_width = CharWidth ('m'); - font->max_bounds.rbearing = char_width; - font->max_bounds.lbearing = 0; - font->max_bounds.width = char_width; - font->max_bounds.ascent = the_fontinfo.ascent; - font->max_bounds.descent = the_fontinfo.descent; - - font->min_bounds = font->max_bounds; - - if (is_two_byte_font || CharWidth ('m') == CharWidth ('i')) - font->per_char = NULL; + if (is_two_byte_font) + { + font->per_char = NULL; + + if (fontface & italic) + font->max_bounds.rbearing = char_width + 1; + else + font->max_bounds.rbearing = char_width; + font->max_bounds.lbearing = 0; + font->max_bounds.width = char_width; + font->max_bounds.ascent = the_fontinfo.ascent; + font->max_bounds.descent = the_fontinfo.descent; + + font->min_bounds = font->max_bounds; + } else { font->per_char = (XCharStruct *) xmalloc (sizeof (XCharStruct) * (0xff - 0x20 + 1)); { - int c, min_width, max_width; + int c, min_width, max_width; + Rect char_bounds, min_bounds, max_bounds; + char ch; min_width = max_width = char_width; + SetRect (&min_bounds, -32767, -32767, 32767, 32767); + SetRect (&max_bounds, 0, 0, 0, 0); for (c = 0x20; c <= 0xff; c++) { - font->per_char[c - 0x20] = font->max_bounds; - char_width = CharWidth (c); - font->per_char[c - 0x20].width = char_width; - font->per_char[c - 0x20].rbearing = char_width; + ch = c; + char_width = CharWidth (ch); + QDTextBounds (1, &ch, &char_bounds); + STORE_XCHARSTRUCT (font->per_char[c - 0x20], + char_width, char_bounds); /* Some Japanese fonts (in SJIS encoding) return 0 as the character width of 0x7f. */ if (char_width > 0) @@ -6787,9 +6812,25 @@ min_width = min (min_width, char_width); max_width = max (max_width, char_width); } - } - font->min_bounds.width = min_width; - font->max_bounds.width = max_width; + if (!EmptyRect (&char_bounds)) + { + SetRect (&min_bounds, + max (min_bounds.left, char_bounds.left), + max (min_bounds.top, char_bounds.top), + min (min_bounds.right, char_bounds.right), + min (min_bounds.bottom, char_bounds.bottom)); + UnionRect (&max_bounds, &char_bounds, &max_bounds); + } + } + STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds); + STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds); + if (min_width == max_width + && max_bounds.left >= 0 && max_bounds.right <= max_width) + { + /* Fixed width and no overhangs. */ + xfree (font->per_char); + font->per_char = NULL; + } } } @@ -9693,7 +9734,7 @@ 0, /* destroy_fringe_bitmap */ mac_per_char_metric, mac_encode_char, - NULL, /* mac_compute_glyph_string_overhangs */ + mac_compute_glyph_string_overhangs, x_draw_glyph_string, mac_define_frame_cursor, mac_clear_frame_area,
