comparison 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
comparison
equal deleted inserted replaced
59717:351ffb20ab9f 59718:d4cb255b034d
1989 1989
1990 static void 1990 static void
1991 mac_compute_glyph_string_overhangs (s) 1991 mac_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 1996
1997 if (s->cmp == NULL 1997 TextFont (font->mac_fontnum);
1998 && s->first_glyph->type == CHAR_GLYPH) 1998 TextSize (font->mac_fontsize);
1999 { 1999 TextFace (font->mac_fontface);
2000 XCharStruct cs; 2000
2001 int direction, font_ascent, font_descent; 2001 if (s->two_byte_p)
2002 XTextExtents16 (s->font, s->char2b, s->nchars, &direction, 2002 QDTextBounds (s->nchars * 2, (char *)s->char2b, &r);
2003 &font_ascent, &font_descent, &cs); 2003 else
2004 s->right_overhang = cs.rbearing > cs.width ? cs.rbearing - cs.width : 0; 2004 {
2005 s->left_overhang = cs.lbearing < 0 ? -cs.lbearing : 0; 2005 int i;
2006 } 2006 char *buf = xmalloc (s->nchars);
2007 #endif 2007
2008 if (buf == NULL)
2009 SetRect (&r, 0, 0, 0, 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 }
2017 }
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
2011 /* Fill rectangle X, Y, W, H with background color of glyph string S. */ 2024 /* Fill rectangle X, Y, W, H with background color of glyph string S. */
2012 2025
3070 x_draw_glyph_string (s) 3083 x_draw_glyph_string (s)
3071 struct glyph_string *s; 3084 struct 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);
3082 x_set_glyph_string_clipping (s->next); 3097 x_set_glyph_string_clipping (s->next);
3083 x_draw_glyph_string_background (s->next, 1); 3098 x_draw_glyph_string_background (s->next, 1);
6754 else 6769 else
6755 /* Do this instead of use the_fontinfo.widMax, which incorrectly 6770 /* Do this instead of use the_fontinfo.widMax, which incorrectly
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; 6777
6763 font->max_bounds.descent = the_fontinfo.descent; 6778 if (fontface & italic)
6764 6779 font->max_bounds.rbearing = char_width + 1;
6765 font->min_bounds = font->max_bounds; 6780 else
6766 6781 font->max_bounds.rbearing = char_width;
6767 if (is_two_byte_font || CharWidth ('m') == CharWidth ('i')) 6782 font->max_bounds.lbearing = 0;
6768 font->per_char = NULL; 6783 font->max_bounds.width = char_width;
6784 font->max_bounds.ascent = the_fontinfo.ascent;
6785 font->max_bounds.descent = the_fontinfo.descent;
6786
6787 font->min_bounds = font->max_bounds;
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)
6786 { 6811 {
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
6796 TextFont (old_fontnum); /* restore previous font number, size and face */ 6837 TextFont (old_fontnum); /* restore previous font number, size and face */
6797 TextSize (old_fontsize); 6838 TextSize (old_fontsize);
9691 x_draw_fringe_bitmap, 9732 x_draw_fringe_bitmap,
9692 0, /* define_fringe_bitmap */ 9733 0, /* define_fringe_bitmap */
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,
9700 mac_draw_window_cursor, 9741 mac_draw_window_cursor,
9701 mac_draw_vertical_window_border, 9742 mac_draw_vertical_window_border,