aboutsummaryrefslogtreecommitdiffstats
path: root/src/macterm.c
diff options
context:
space:
mode:
authorSteven Tamm2005-01-24 17:59:36 +0000
committerSteven Tamm2005-01-24 17:59:36 +0000
commit8c2da0fa6ca49777fdcc7266cbdfe7d0e0a024d0 (patch)
tree0715df56367a8e18a31363b64f441d3166c8478e /src/macterm.c
parente856c2162b0b024acf8dd316c5e47b3f938a0fb1 (diff)
downloademacs-8c2da0fa6ca49777fdcc7266cbdfe7d0e0a024d0.tar.gz
emacs-8c2da0fa6ca49777fdcc7266cbdfe7d0e0a024d0.zip
* 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.
Diffstat (limited to 'src/macterm.c')
-rw-r--r--src/macterm.c105
1 files changed, 73 insertions, 32 deletions
diff --git a/src/macterm.c b/src/macterm.c
index 24aaa52947b..60eee6a4a84 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -1991,20 +1991,33 @@ static void
1991mac_compute_glyph_string_overhangs (s) 1991mac_compute_glyph_string_overhangs (s)
1992 struct glyph_string *s; 1992 struct glyph_string *s;
1993{ 1993{
1994#if 0 1994 Rect r;
1995 /* MAC_TODO: XTextExtents16 does nothing yet... */ 1995 MacFontStruct *font = s->font;
1996
1997 TextFont (font->mac_fontnum);
1998 TextSize (font->mac_fontsize);
1999 TextFace (font->mac_fontface);
1996 2000
1997 if (s->cmp == NULL 2001 if (s->two_byte_p)
1998 && s->first_glyph->type == CHAR_GLYPH) 2002 QDTextBounds (s->nchars * 2, (char *)s->char2b, &r);
2003 else
1999 { 2004 {
2000 XCharStruct cs; 2005 int i;
2001 int direction, font_ascent, font_descent; 2006 char *buf = xmalloc (s->nchars);
2002 XTextExtents16 (s->font, s->char2b, s->nchars, &direction, 2007
2003 &font_ascent, &font_descent, &cs); 2008 if (buf == NULL)
2004 s->right_overhang = cs.rbearing > cs.width ? cs.rbearing - cs.width : 0; 2009 SetRect (&r, 0, 0, 0, 0);
2005 s->left_overhang = cs.lbearing < 0 ? -cs.lbearing : 0; 2010 else
2011 {
2012 for (i = 0; i < s->nchars; ++i)
2013 buf[i] = s->char2b[i].byte2;
2014 QDTextBounds (s->nchars, buf, &r);
2015 xfree (buf);
2016 }
2006 } 2017 }
2007#endif 2018
2019 s->right_overhang = r.right > s->width ? r.right - s->width : 0;
2020 s->left_overhang = r.left < 0 ? -r.left : 0;
2008} 2021}
2009 2022
2010 2023
@@ -3072,10 +3085,12 @@ x_draw_glyph_string (s)
3072{ 3085{
3073 int relief_drawn_p = 0; 3086 int relief_drawn_p = 0;
3074 3087
3075 /* If S draws into the background of its successor, draw the 3088 /* If S draws into the background of its successor that does not
3076 background of the successor first so that S can draw into it. 3089 draw a cursor, draw the background of the successor first so that
3077 This makes S->next use XDrawString instead of XDrawImageString. */ 3090 S can draw into it. This makes S->next use XDrawString instead
3078 if (s->next && s->right_overhang && !s->for_overlaps_p) 3091 of XDrawImageString. */
3092 if (s->next && s->right_overhang && !s->for_overlaps_p
3093 && s->next->hl != DRAW_CURSOR)
3079 { 3094 {
3080 xassert (s->next->img == NULL); 3095 xassert (s->next->img == NULL);
3081 x_set_glyph_string_gc (s->next); 3096 x_set_glyph_string_gc (s->next);
@@ -6756,30 +6771,40 @@ XLoadQueryFont (Display *dpy, char *fontname)
6756 returns 15 for 12-point Monaco! */ 6771 returns 15 for 12-point Monaco! */
6757 char_width = CharWidth ('m'); 6772 char_width = CharWidth ('m');
6758 6773
6759 font->max_bounds.rbearing = char_width; 6774 if (is_two_byte_font)
6760 font->max_bounds.lbearing = 0; 6775 {
6761 font->max_bounds.width = char_width; 6776 font->per_char = NULL;
6762 font->max_bounds.ascent = the_fontinfo.ascent;
6763 font->max_bounds.descent = the_fontinfo.descent;
6764 6777
6765 font->min_bounds = font->max_bounds; 6778 if (fontface & italic)
6779 font->max_bounds.rbearing = char_width + 1;
6780 else
6781 font->max_bounds.rbearing = char_width;
6782 font->max_bounds.lbearing = 0;
6783 font->max_bounds.width = char_width;
6784 font->max_bounds.ascent = the_fontinfo.ascent;
6785 font->max_bounds.descent = the_fontinfo.descent;
6766 6786
6767 if (is_two_byte_font || CharWidth ('m') == CharWidth ('i')) 6787 font->min_bounds = font->max_bounds;
6768 font->per_char = NULL; 6788 }
6769 else 6789 else
6770 { 6790 {
6771 font->per_char = (XCharStruct *) 6791 font->per_char = (XCharStruct *)
6772 xmalloc (sizeof (XCharStruct) * (0xff - 0x20 + 1)); 6792 xmalloc (sizeof (XCharStruct) * (0xff - 0x20 + 1));
6773 { 6793 {
6774 int c, min_width, max_width; 6794 int c, min_width, max_width;
6795 Rect char_bounds, min_bounds, max_bounds;
6796 char ch;
6775 6797
6776 min_width = max_width = char_width; 6798 min_width = max_width = char_width;
6799 SetRect (&min_bounds, -32767, -32767, 32767, 32767);
6800 SetRect (&max_bounds, 0, 0, 0, 0);
6777 for (c = 0x20; c <= 0xff; c++) 6801 for (c = 0x20; c <= 0xff; c++)
6778 { 6802 {
6779 font->per_char[c - 0x20] = font->max_bounds; 6803 ch = c;
6780 char_width = CharWidth (c); 6804 char_width = CharWidth (ch);
6781 font->per_char[c - 0x20].width = char_width; 6805 QDTextBounds (1, &ch, &char_bounds);
6782 font->per_char[c - 0x20].rbearing = char_width; 6806 STORE_XCHARSTRUCT (font->per_char[c - 0x20],
6807 char_width, char_bounds);
6783 /* Some Japanese fonts (in SJIS encoding) return 0 as the 6808 /* Some Japanese fonts (in SJIS encoding) return 0 as the
6784 character width of 0x7f. */ 6809 character width of 0x7f. */
6785 if (char_width > 0) 6810 if (char_width > 0)
@@ -6787,9 +6812,25 @@ XLoadQueryFont (Display *dpy, char *fontname)
6787 min_width = min (min_width, char_width); 6812 min_width = min (min_width, char_width);
6788 max_width = max (max_width, char_width); 6813 max_width = max (max_width, char_width);
6789 } 6814 }
6790 } 6815 if (!EmptyRect (&char_bounds))
6791 font->min_bounds.width = min_width; 6816 {
6792 font->max_bounds.width = max_width; 6817 SetRect (&min_bounds,
6818 max (min_bounds.left, char_bounds.left),
6819 max (min_bounds.top, char_bounds.top),
6820 min (min_bounds.right, char_bounds.right),
6821 min (min_bounds.bottom, char_bounds.bottom));
6822 UnionRect (&max_bounds, &char_bounds, &max_bounds);
6823 }
6824 }
6825 STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds);
6826 STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds);
6827 if (min_width == max_width
6828 && max_bounds.left >= 0 && max_bounds.right <= max_width)
6829 {
6830 /* Fixed width and no overhangs. */
6831 xfree (font->per_char);
6832 font->per_char = NULL;
6833 }
6793 } 6834 }
6794 } 6835 }
6795 6836
@@ -9693,7 +9734,7 @@ static struct redisplay_interface x_redisplay_interface =
9693 0, /* destroy_fringe_bitmap */ 9734 0, /* destroy_fringe_bitmap */
9694 mac_per_char_metric, 9735 mac_per_char_metric,
9695 mac_encode_char, 9736 mac_encode_char,
9696 NULL, /* mac_compute_glyph_string_overhangs */ 9737 mac_compute_glyph_string_overhangs,
9697 x_draw_glyph_string, 9738 x_draw_glyph_string,
9698 mac_define_frame_cursor, 9739 mac_define_frame_cursor,
9699 mac_clear_frame_area, 9740 mac_clear_frame_area,