aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2006-02-21 08:10:04 +0000
committerYAMAMOTO Mitsuharu2006-02-21 08:10:04 +0000
commit9fb446e3f1fcc75cf018fef830d7d660f425ae46 (patch)
tree98355d68f400e8b5f732df4e40d25962e4ed2e55
parent3fc64795f4cefda4dedeabf4136eaad49845406d (diff)
downloademacs-9fb446e3f1fcc75cf018fef830d7d660f425ae46.tar.gz
emacs-9fb446e3f1fcc75cf018fef830d7d660f425ae46.zip
(mac_draw_string_common): Remove arg MODE. New arg
BG_WIDTH. All uses changed. Draw background if BG_WIDTH is not zero. (mac_draw_image_string, mac_draw_image_string_16): New arg BG_WIDTH. [USE_CG_TEXT_DRAWING] (mac_draw_image_string_cg): Rename from mac_draw_string_cg. New arg BG_WIDTH. All uses changed. Draw background if BG_WIDTH is not zero. Use float constants as divisors instead of double. Use alloca instead of xmalloc/xfree. (x_draw_glyph_string_background, x_draw_glyph_string_foreground) [!MAC_OS8 || USE_ATSUI]: Background may be drawn using mac_draw_image_string* functions. (XLoadQueryFont) [MAC_OS8 && USE_ATSUI]: Don't adjust heights of some fonts when srcCopy text transfer mode might be used. (mac_begin_clip, mac_end_clip): Check if region is empty. (mac_set_clip_rectangles): When resetting clip region, make it empty instead of disposing of it.
-rw-r--r--src/ChangeLog18
-rw-r--r--src/macterm.c324
2 files changed, 197 insertions, 145 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 3667d6c7a68..1d2cc429eea 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,21 @@
12006-02-21 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2
3 * macterm.c (mac_draw_string_common): Remove arg MODE. New arg
4 BG_WIDTH. All uses changed. Draw background if BG_WIDTH is not zero.
5 (mac_draw_image_string, mac_draw_image_string_16): New arg BG_WIDTH.
6 [USE_CG_TEXT_DRAWING] (mac_draw_image_string_cg): Rename from
7 mac_draw_string_cg. New arg BG_WIDTH. All uses changed. Draw
8 background if BG_WIDTH is not zero. Use float constants as
9 divisors instead of double. Use alloca instead of xmalloc/xfree.
10 (x_draw_glyph_string_background, x_draw_glyph_string_foreground)
11 [!MAC_OS8 || USE_ATSUI]: Background may be drawn using
12 mac_draw_image_string* functions.
13 (XLoadQueryFont) [MAC_OS8 && USE_ATSUI]: Don't adjust heights of
14 some fonts when srcCopy text transfer mode might be used.
15 (mac_begin_clip, mac_end_clip): Check if region is empty.
16 (mac_set_clip_rectangles): When resetting clip region, make it
17 empty instead of disposing of it.
18
12006-02-20 Kim F. Storm <storm@cua.dk> 192006-02-20 Kim F. Storm <storm@cua.dk>
2 20
3 * Makefile.in: Add fringe.elc to WINDOW_SUPPORT. 21 * Makefile.in: Add fringe.elc to WINDOW_SUPPORT.
diff --git a/src/macterm.c b/src/macterm.c
index 69181958cf0..40a20026bd2 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -283,7 +283,7 @@ mac_begin_clip (region)
283 if (new_region == NULL) 283 if (new_region == NULL)
284 new_region = NewRgn (); 284 new_region = NewRgn ();
285 285
286 if (region) 286 if (region && !EmptyRgn (region))
287 { 287 {
288 GetClip (saved_port_clip_region); 288 GetClip (saved_port_clip_region);
289 SectRgn (saved_port_clip_region, region, new_region); 289 SectRgn (saved_port_clip_region, region, new_region);
@@ -295,7 +295,7 @@ static void
295mac_end_clip (region) 295mac_end_clip (region)
296 RgnHandle region; 296 RgnHandle region;
297{ 297{
298 if (region) 298 if (region && !EmptyRgn (region))
299 SetClip (saved_port_clip_region); 299 SetClip (saved_port_clip_region);
300} 300}
301 301
@@ -682,27 +682,15 @@ mac_invert_rectangle (f, x, y, width, height)
682 682
683 683
684static void 684static void
685mac_draw_string_common (f, gc, x, y, buf, nchars, mode, bytes_per_char) 685mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char)
686 struct frame *f; 686 struct frame *f;
687 GC gc; 687 GC gc;
688 int x, y; 688 int x, y;
689 char *buf; 689 char *buf;
690 int nchars, mode, bytes_per_char; 690 int nchars, bg_width, bytes_per_char;
691{ 691{
692#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
693 UInt32 textFlags, savedFlags;
694 if (mac_use_core_graphics) {
695 textFlags = kQDUseCGTextRendering;
696 savedFlags = SwapQDTextFlags(textFlags);
697 }
698#endif
699
700 SetPortWindowPort (FRAME_MAC_WINDOW (f)); 692 SetPortWindowPort (FRAME_MAC_WINDOW (f));
701 693
702 RGBForeColor (GC_FORE_COLOR (gc));
703 if (mode != srcOr)
704 RGBBackColor (GC_BACK_COLOR (gc));
705
706#if USE_ATSUI 694#if USE_ATSUI
707 if (GC_FONT (gc)->mac_style) 695 if (GC_FONT (gc)->mac_style)
708 { 696 {
@@ -724,91 +712,144 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, mode, bytes_per_char)
724 nchars, 712 nchars,
725 GC_FONT (gc)->mac_style, 713 GC_FONT (gc)->mac_style,
726 &text_layout); 714 &text_layout);
727 if (err == noErr) 715 if (err != noErr)
728 { 716 return;
729#ifdef MAC_OSX 717#ifdef MAC_OSX
730 if (!mac_use_core_graphics) 718 if (!mac_use_core_graphics)
731 { 719 {
732#endif 720#endif
733 mac_begin_clip (GC_CLIP_REGION (gc)); 721 mac_begin_clip (GC_CLIP_REGION (gc));
734 MoveTo (x, y); 722 RGBForeColor (GC_FORE_COLOR (gc));
735 ATSUDrawText (text_layout, 723 if (bg_width)
736 kATSUFromTextBeginning, kATSUToTextEnd, 724 {
737 kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc); 725 Rect r;
738 mac_end_clip (GC_CLIP_REGION (gc)); 726
739#ifdef MAC_OSX 727 SetRect (&r, x, y - FONT_BASE (GC_FONT (gc)),
728 x + bg_width, y + FONT_DESCENT (GC_FONT (gc)));
729 RGBBackColor (GC_BACK_COLOR (gc));
730 EraseRect (&r);
731 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
740 } 732 }
741 else 733 MoveTo (x, y);
734 ATSUDrawText (text_layout,
735 kATSUFromTextBeginning, kATSUToTextEnd,
736 kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc);
737 mac_end_clip (GC_CLIP_REGION (gc));
738#ifdef MAC_OSX
739 }
740 else
741 {
742 CGrafPtr port;
743 CGContextRef context;
744 float port_height = FRAME_PIXEL_HEIGHT (f);
745 ATSUAttributeTag tags[] = {kATSUCGContextTag};
746 ByteCount sizes[] = {sizeof (CGContextRef)};
747 ATSUAttributeValuePtr values[] = {&context};
748
749 GetPort (&port);
750 QDBeginCGContext (port, &context);
751 if (gc->n_clip_rects || bg_width)
742 { 752 {
743 CGrafPtr port; 753 CGContextTranslateCTM (context, 0, port_height);
744 CGContextRef context; 754 CGContextScaleCTM (context, 1, -1);
745 float port_height = FRAME_PIXEL_HEIGHT (f);
746 ATSUAttributeTag tags[] = {kATSUCGContextTag};
747 ByteCount sizes[] = {sizeof (CGContextRef)};
748 ATSUAttributeValuePtr values[] = {&context};
749
750 GetPort (&port);
751 QDBeginCGContext (port, &context);
752 if (gc->n_clip_rects) 755 if (gc->n_clip_rects)
756 CGContextClipToRects (context, gc->clip_rects,
757 gc->n_clip_rects);
758 if (bg_width)
753 { 759 {
754 CGContextTranslateCTM (context, 0, port_height); 760 CGContextSetRGBFillColor
755 CGContextScaleCTM (context, 1, -1); 761 (context,
756 CGContextClipToRects (context, gc->clip_rects, 762 RED_FROM_ULONG (gc->xgcv.background) / 255.0f,
757 gc->n_clip_rects); 763 GREEN_FROM_ULONG (gc->xgcv.background) / 255.0f,
758 CGContextScaleCTM (context, 1, -1); 764 BLUE_FROM_ULONG (gc->xgcv.background) / 255.0f,
759 CGContextTranslateCTM (context, 0, -port_height); 765 1.0);
766 CGContextFillRect
767 (context,
768 CGRectMake (x, y - FONT_BASE (GC_FONT (gc)),
769 bg_width, FONT_HEIGHT (GC_FONT (gc))));
760 } 770 }
761 CGContextSetRGBFillColor 771 CGContextScaleCTM (context, 1, -1);
762 (context, 772 CGContextTranslateCTM (context, 0, -port_height);
763 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0, 773 }
764 GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0, 774 CGContextSetRGBFillColor
765 BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0, 775 (context,
766 1.0); 776 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
767 err = ATSUSetLayoutControls (text_layout, 777 GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
768 sizeof (tags) / sizeof (tags[0]), 778 BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
769 tags, sizes, values); 779 1.0);
770 if (err == noErr) 780 err = ATSUSetLayoutControls (text_layout,
771 ATSUDrawText (text_layout,
772 kATSUFromTextBeginning, kATSUToTextEnd,
773 Long2Fix (x), Long2Fix (port_height - y));
774 CGContextSynchronize (context);
775 QDEndCGContext (port, &context);
776#if 0
777 /* This doesn't work on Mac OS X 10.1. */
778 ATSUClearLayoutControls (text_layout,
779 sizeof (tags) / sizeof (tags[0]), 781 sizeof (tags) / sizeof (tags[0]),
780 tags); 782 tags, sizes, values);
783 if (err == noErr)
784 ATSUDrawText (text_layout,
785 kATSUFromTextBeginning, kATSUToTextEnd,
786 Long2Fix (x), Long2Fix (port_height - y));
787 CGContextSynchronize (context);
788 QDEndCGContext (port, &context);
789#if 0
790 /* This doesn't work on Mac OS X 10.1. */
791 ATSUClearLayoutControls (text_layout,
792 sizeof (tags) / sizeof (tags[0]), tags);
781#else 793#else
782 ATSUSetLayoutControls (text_layout, 794 ATSUSetLayoutControls (text_layout,
783 sizeof (tags) / sizeof (tags[0]), 795 sizeof (tags) / sizeof (tags[0]),
784 tags, sizes, values); 796 tags, sizes, values);
785#endif
786 }
787#endif 797#endif
788 } 798 }
799#endif /* MAC_OSX */
789 } 800 }
790 else 801 else
802#endif /* USE_ATSUI */
791 { 803 {
804#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
805 UInt32 savedFlags;
806
807 if (mac_use_core_graphics)
808 savedFlags = SwapQDTextFlags (kQDUseCGTextRendering);
792#endif 809#endif
793 TextFont (GC_FONT (gc)->mac_fontnum); 810 mac_begin_clip (GC_CLIP_REGION (gc));
794 TextSize (GC_FONT (gc)->mac_fontsize); 811 RGBForeColor (GC_FORE_COLOR (gc));
795 TextFace (GC_FONT (gc)->mac_fontface); 812#ifdef MAC_OS8
796 TextMode (mode); 813 if (bg_width)
814 {
815 RGBBackColor (GC_BACK_COLOR (gc));
816 TextMode (srcCopy);
817 }
818 else
819 TextMode (srcOr);
820#else
821 /* We prefer not to use srcCopy text transfer mode on Mac OS X
822 because:
823 - Screen is double-buffered. (In srcCopy mode, a text is
824 drawn into an offscreen graphics world first. So
825 performance gain cannot be expected.)
826 - It lowers rendering quality.
827 - Some fonts leave garbage on cursor movement. */
828 if (bg_width)
829 {
830 Rect r;
797 831
798 mac_begin_clip (GC_CLIP_REGION (gc)); 832 RGBBackColor (GC_BACK_COLOR (gc));
799 MoveTo (x, y); 833 SetRect (&r, x, y - FONT_BASE (GC_FONT (gc)),
800 DrawText (buf, 0, nchars * bytes_per_char); 834 x + bg_width, y + FONT_DESCENT (GC_FONT (gc)));
801 mac_end_clip (GC_CLIP_REGION (gc)); 835 EraseRect (&r);
802#if USE_ATSUI 836 }
803 } 837 TextMode (srcOr);
804#endif 838#endif
839 TextFont (GC_FONT (gc)->mac_fontnum);
840 TextSize (GC_FONT (gc)->mac_fontsize);
841 TextFace (GC_FONT (gc)->mac_fontface);
842 MoveTo (x, y);
843 DrawText (buf, 0, nchars * bytes_per_char);
844 if (bg_width)
845 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
846 mac_end_clip (GC_CLIP_REGION (gc));
805 847
806 if (mode != srcOr)
807 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
808#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 848#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
809 if (mac_use_core_graphics) 849 if (mac_use_core_graphics)
810 SwapQDTextFlags(savedFlags); 850 SwapQDTextFlags(savedFlags);
811#endif 851#endif
852 }
812} 853}
813 854
814 855
@@ -822,7 +863,7 @@ mac_draw_string (f, gc, x, y, buf, nchars)
822 char *buf; 863 char *buf;
823 int nchars; 864 int nchars;
824{ 865{
825 mac_draw_string_common (f, gc, x, y, buf, nchars, srcOr, 1); 866 mac_draw_string_common (f, gc, x, y, buf, nchars, 0, 1);
826} 867}
827 868
828 869
@@ -836,35 +877,35 @@ mac_draw_string_16 (f, gc, x, y, buf, nchars)
836 XChar2b *buf; 877 XChar2b *buf;
837 int nchars; 878 int nchars;
838{ 879{
839 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, srcOr, 2); 880 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, 0, 2);
840} 881}
841 882
842 883
843/* Mac replacement for XDrawImageString. */ 884/* Mac replacement for XDrawImageString. */
844 885
845static void 886static void
846mac_draw_image_string (f, gc, x, y, buf, nchars) 887mac_draw_image_string (f, gc, x, y, buf, nchars, bg_width)
847 struct frame *f; 888 struct frame *f;
848 GC gc; 889 GC gc;
849 int x, y; 890 int x, y;
850 char *buf; 891 char *buf;
851 int nchars; 892 int nchars, bg_width;
852{ 893{
853 mac_draw_string_common (f, gc, x, y, buf, nchars, srcCopy, 1); 894 mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, 1);
854} 895}
855 896
856 897
857/* Mac replacement for XDrawString16. */ 898/* Mac replacement for XDrawString16. */
858 899
859static void 900static void
860mac_draw_image_string_16 (f, gc, x, y, buf, nchars) 901mac_draw_image_string_16 (f, gc, x, y, buf, nchars, bg_width)
861 struct frame *f; 902 struct frame *f;
862 GC gc; 903 GC gc;
863 int x, y; 904 int x, y;
864 XChar2b *buf; 905 XChar2b *buf;
865 int nchars; 906 int nchars, bg_width;
866{ 907{
867 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, srcCopy, 2); 908 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, bg_width, 2);
868} 909}
869 910
870 911
@@ -1038,12 +1079,12 @@ init_cg_text_anti_aliasing_threshold ()
1038} 1079}
1039 1080
1040static int 1081static int
1041mac_draw_string_cg (f, gc, x, y, buf, nchars) 1082mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width)
1042 struct frame *f; 1083 struct frame *f;
1043 GC gc; 1084 GC gc;
1044 int x, y; 1085 int x, y;
1045 XChar2b *buf; 1086 XChar2b *buf;
1046 int nchars; 1087 int nchars, bg_width;
1047{ 1088{
1048 CGrafPtr port; 1089 CGrafPtr port;
1049 float port_height, gx, gy; 1090 float port_height, gx, gy;
@@ -1060,7 +1101,9 @@ mac_draw_string_cg (f, gc, x, y, buf, nchars)
1060 gx = x; 1101 gx = x;
1061 gy = port_height - y; 1102 gy = port_height - y;
1062 glyphs = (CGGlyph *)buf; 1103 glyphs = (CGGlyph *)buf;
1063 advances = xmalloc (sizeof (CGSize) * nchars); 1104 advances = alloca (sizeof (CGSize) * nchars);
1105 if (advances == NULL)
1106 return 0;
1064 for (i = 0; i < nchars; i++) 1107 for (i = 0; i < nchars; i++)
1065 { 1108 {
1066 XCharStruct *pcm = mac_per_char_metric (GC_FONT (gc), buf, 0); 1109 XCharStruct *pcm = mac_per_char_metric (GC_FONT (gc), buf, 0);
@@ -1072,18 +1115,32 @@ mac_draw_string_cg (f, gc, x, y, buf, nchars)
1072 } 1115 }
1073 1116
1074 QDBeginCGContext (port, &context); 1117 QDBeginCGContext (port, &context);
1075 if (gc->n_clip_rects) 1118 if (gc->n_clip_rects || bg_width)
1076 { 1119 {
1077 CGContextTranslateCTM (context, 0, port_height); 1120 CGContextTranslateCTM (context, 0, port_height);
1078 CGContextScaleCTM (context, 1, -1); 1121 CGContextScaleCTM (context, 1, -1);
1079 CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects); 1122 if (gc->n_clip_rects)
1123 CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects);
1124 if (bg_width)
1125 {
1126 CGContextSetRGBFillColor
1127 (context,
1128 RED_FROM_ULONG (gc->xgcv.background) / 255.0f,
1129 GREEN_FROM_ULONG (gc->xgcv.background) / 255.0f,
1130 BLUE_FROM_ULONG (gc->xgcv.background) / 255.0f,
1131 1.0);
1132 CGContextFillRect
1133 (context,
1134 CGRectMake (gx, y - FONT_BASE (GC_FONT (gc)),
1135 bg_width, FONT_HEIGHT (GC_FONT (gc))));
1136 }
1080 CGContextScaleCTM (context, 1, -1); 1137 CGContextScaleCTM (context, 1, -1);
1081 CGContextTranslateCTM (context, 0, -port_height); 1138 CGContextTranslateCTM (context, 0, -port_height);
1082 } 1139 }
1083 CGContextSetRGBFillColor (context, 1140 CGContextSetRGBFillColor (context,
1084 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0, 1141 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
1085 GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0, 1142 GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
1086 BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0, 1143 BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
1087 1.0); 1144 1.0);
1088 CGContextSetFont (context, GC_FONT (gc)->cg_font); 1145 CGContextSetFont (context, GC_FONT (gc)->cg_font);
1089 CGContextSetFontSize (context, GC_FONT (gc)->mac_fontsize); 1146 CGContextSetFontSize (context, GC_FONT (gc)->mac_fontsize);
@@ -1102,8 +1159,6 @@ mac_draw_string_cg (f, gc, x, y, buf, nchars)
1102 CGContextSynchronize (context); 1159 CGContextSynchronize (context);
1103 QDEndCGContext (port, &context); 1160 QDEndCGContext (port, &context);
1104 1161
1105 xfree (advances);
1106
1107 return 1; 1162 return 1;
1108} 1163}
1109#endif 1164#endif
@@ -1375,10 +1430,7 @@ mac_set_clip_rectangles (display, gc, rectangles, n)
1375 if (n == 0) 1430 if (n == 0)
1376 { 1431 {
1377 if (gc->clip_region) 1432 if (gc->clip_region)
1378 { 1433 SetEmptyRgn (gc->clip_region);
1379 DisposeRgn (gc->clip_region);
1380 gc->clip_region = NULL;
1381 }
1382 } 1434 }
1383 else 1435 else
1384 { 1436 {
@@ -2322,14 +2374,6 @@ x_clear_glyph_string_rect (s, x, y, w, h)
2322} 2374}
2323 2375
2324 2376
2325/* We prefer not to use XDrawImageString (srcCopy text transfer mode)
2326 on Mac OS X because:
2327 - Screen is double-buffered. (In srcCopy mode, a text is drawn
2328 into an offscreen graphics world first. So performance gain
2329 cannot be expected.)
2330 - It lowers rendering quality.
2331 - Some fonts leave garbage on cursor movement. */
2332
2333/* Draw the background of glyph_string S. If S->background_filled_p 2377/* Draw the background of glyph_string S. If S->background_filled_p
2334 is non-zero don't draw it. FORCE_P non-zero means draw the 2378 is non-zero don't draw it. FORCE_P non-zero means draw the
2335 background even if it wouldn't be drawn normally. This is used 2379 background even if it wouldn't be drawn normally. This is used
@@ -2361,12 +2405,10 @@ x_draw_glyph_string_background (s, force_p)
2361 } 2405 }
2362 else 2406 else
2363#endif 2407#endif
2364#if defined (MAC_OS8) && !USE_ATSUI
2365 if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width 2408 if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width
2366 || s->font_not_found_p 2409 || s->font_not_found_p
2367 || s->extends_to_end_of_line_p 2410 || s->extends_to_end_of_line_p
2368 || force_p) 2411 || force_p)
2369#endif
2370 { 2412 {
2371 x_clear_glyph_string_rect (s, s->x, s->y + box_line_width, 2413 x_clear_glyph_string_rect (s, s->x, s->y + box_line_width,
2372 s->background_width, 2414 s->background_width,
@@ -2383,7 +2425,7 @@ static void
2383x_draw_glyph_string_foreground (s) 2425x_draw_glyph_string_foreground (s)
2384 struct glyph_string *s; 2426 struct glyph_string *s;
2385{ 2427{
2386 int i, x; 2428 int i, x, bg_width;
2387 2429
2388 /* If first glyph of S has a left box line, start drawing the text 2430 /* If first glyph of S has a left box line, start drawing the text
2389 of S to the right of that box line. */ 2431 of S to the right of that box line. */
@@ -2422,7 +2464,6 @@ x_draw_glyph_string_foreground (s)
2422 for (i = 0; i < s->nchars; ++i) 2464 for (i = 0; i < s->nchars; ++i)
2423 char1b[i] = s->char2b[i].byte2; 2465 char1b[i] = s->char2b[i].byte2;
2424 2466
2425#if defined (MAC_OS8) && !USE_ATSUI
2426 /* Draw text with XDrawString if background has already been 2467 /* Draw text with XDrawString if background has already been
2427 filled. Otherwise, use XDrawImageString. (Note that 2468 filled. Otherwise, use XDrawImageString. (Note that
2428 XDrawImageString is usually faster than XDrawString.) Always 2469 XDrawImageString is usually faster than XDrawString.) Always
@@ -2430,38 +2471,27 @@ x_draw_glyph_string_foreground (s)
2430 no chance that characters under a box cursor are invisible. */ 2471 no chance that characters under a box cursor are invisible. */
2431 if (s->for_overlaps 2472 if (s->for_overlaps
2432 || (s->background_filled_p && s->hl != DRAW_CURSOR)) 2473 || (s->background_filled_p && s->hl != DRAW_CURSOR))
2433#endif 2474 bg_width = 0; /* Corresponds to XDrawString. */
2434 { 2475 else
2435 /* Draw characters with 16-bit or 8-bit functions. */ 2476 bg_width = s->background_width; /* Corresponds to XDrawImageString. */
2436 if (s->two_byte_p 2477
2478 if (s->two_byte_p
2437#if USE_ATSUI 2479#if USE_ATSUI
2438 || GC_FONT (s->gc)->mac_style 2480 || GC_FONT (s->gc)->mac_style
2439#endif 2481#endif
2440 ) 2482 )
2441#if USE_CG_TEXT_DRAWING 2483#if USE_CG_TEXT_DRAWING
2442 if (!s->two_byte_p 2484 if (!s->two_byte_p
2443 && mac_draw_string_cg (s->f, s->gc, x, s->ybase - boff, 2485 && mac_draw_image_string_cg (s->f, s->gc, x, s->ybase - boff,
2444 s->char2b, s->nchars)) 2486 s->char2b, s->nchars, bg_width))
2445 ; 2487 ;
2446 else 2488 else
2447#endif 2489#endif
2448 mac_draw_string_16 (s->f, s->gc, x, s->ybase - boff, 2490 mac_draw_image_string_16 (s->f, s->gc, x, s->ybase - boff,
2449 s->char2b, s->nchars); 2491 s->char2b, s->nchars, bg_width);
2450 else
2451 mac_draw_string (s->f, s->gc, x, s->ybase - boff,
2452 char1b, s->nchars);
2453 }
2454#if defined (MAC_OS8) && !USE_ATSUI
2455 else 2492 else
2456 { 2493 mac_draw_image_string (s->f, s->gc, x, s->ybase - boff,
2457 if (s->two_byte_p) 2494 char1b, s->nchars, bg_width);
2458 mac_draw_image_string_16 (s->f, s->gc, x, s->ybase - boff,
2459 s->char2b, s->nchars);
2460 else
2461 mac_draw_image_string (s->f, s->gc, x, s->ybase - boff,
2462 char1b, s->nchars);
2463 }
2464#endif
2465 } 2495 }
2466} 2496}
2467 2497
@@ -7837,9 +7867,13 @@ XLoadQueryFont (Display *dpy, char *fontname)
7837#if !defined (MAC_OS8) || USE_ATSUI 7867#if !defined (MAC_OS8) || USE_ATSUI
7838 /* AppKit and WebKit do some adjustment to the heights of Courier, 7868 /* AppKit and WebKit do some adjustment to the heights of Courier,
7839 Helvetica, and Times. This only works on the environments where 7869 Helvetica, and Times. This only works on the environments where
7840 the XDrawImageString counterpart is never used. */ 7870 srcCopy text transfer mode is never used. */
7841 if (strcmp (family, "courier") == 0 || strcmp (family, "helvetica") == 0 7871 if (
7842 || strcmp (family, "times") == 0) 7872#ifdef MAC_OS8 /* implies USE_ATSUI */
7873 font->mac_style &&
7874#endif
7875 (strcmp (family, "courier") == 0 || strcmp (family, "helvetica") == 0
7876 || strcmp (family, "times") == 0))
7843 font->ascent += (font->ascent + font->descent) * .15 + 0.5; 7877 font->ascent += (font->ascent + font->descent) * .15 + 0.5;
7844#endif 7878#endif
7845 7879