Mercurial > emacs
comparison src/macterm.c @ 90314:d1c5430c5bff
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-21
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 97-112)
- Update from CVS
- Merge from erc--emacs--0
- Update from CVS: src/regex.c (extend_range_table_work_area): Fix typo.
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 37)
- Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 22 Feb 2006 06:54:10 +0000 |
parents | 4b3d39451150 783439580869 |
children | 34c8b755296d |
comparison
equal
deleted
inserted
replaced
90313:496f6d9b9d20 | 90314:d1c5430c5bff |
---|---|
283 if (saved_port_clip_region == NULL) | 283 if (saved_port_clip_region == NULL) |
284 saved_port_clip_region = NewRgn (); | 284 saved_port_clip_region = NewRgn (); |
285 if (new_region == NULL) | 285 if (new_region == NULL) |
286 new_region = NewRgn (); | 286 new_region = NewRgn (); |
287 | 287 |
288 if (region) | 288 if (region && !EmptyRgn (region)) |
289 { | 289 { |
290 GetClip (saved_port_clip_region); | 290 GetClip (saved_port_clip_region); |
291 SectRgn (saved_port_clip_region, region, new_region); | 291 SectRgn (saved_port_clip_region, region, new_region); |
292 SetClip (new_region); | 292 SetClip (new_region); |
293 } | 293 } |
295 | 295 |
296 static void | 296 static void |
297 mac_end_clip (region) | 297 mac_end_clip (region) |
298 RgnHandle region; | 298 RgnHandle region; |
299 { | 299 { |
300 if (region) | 300 if (region && !EmptyRgn (region)) |
301 SetClip (saved_port_clip_region); | 301 SetClip (saved_port_clip_region); |
302 } | 302 } |
303 | 303 |
304 | 304 |
305 /* X display function emulation */ | 305 /* X display function emulation */ |
682 InvertRect (&r); | 682 InvertRect (&r); |
683 } | 683 } |
684 | 684 |
685 | 685 |
686 static void | 686 static void |
687 mac_draw_string_common (f, gc, x, y, buf, nchars, mode, bytes_per_char) | 687 mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char) |
688 struct frame *f; | 688 struct frame *f; |
689 GC gc; | 689 GC gc; |
690 int x, y; | 690 int x, y; |
691 char *buf; | 691 char *buf; |
692 int nchars, mode, bytes_per_char; | 692 int nchars, bg_width, bytes_per_char; |
693 { | 693 { |
694 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 | |
695 UInt32 textFlags, savedFlags; | |
696 if (mac_use_core_graphics) { | |
697 textFlags = kQDUseCGTextRendering; | |
698 savedFlags = SwapQDTextFlags(textFlags); | |
699 } | |
700 #endif | |
701 | |
702 SetPortWindowPort (FRAME_MAC_WINDOW (f)); | 694 SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
703 | |
704 RGBForeColor (GC_FORE_COLOR (gc)); | |
705 if (mode != srcOr) | |
706 RGBBackColor (GC_BACK_COLOR (gc)); | |
707 | 695 |
708 #if USE_ATSUI | 696 #if USE_ATSUI |
709 if (GC_FONT (gc)->mac_style) | 697 if (GC_FONT (gc)->mac_style) |
710 { | 698 { |
711 OSErr err; | 699 OSErr err; |
724 #endif | 712 #endif |
725 err = atsu_get_text_layout_with_text_ptr ((ConstUniCharArrayPtr)buf, | 713 err = atsu_get_text_layout_with_text_ptr ((ConstUniCharArrayPtr)buf, |
726 nchars, | 714 nchars, |
727 GC_FONT (gc)->mac_style, | 715 GC_FONT (gc)->mac_style, |
728 &text_layout); | 716 &text_layout); |
729 if (err == noErr) | 717 if (err != noErr) |
718 return; | |
719 #ifdef MAC_OSX | |
720 if (!mac_use_core_graphics) | |
730 { | 721 { |
722 #endif | |
723 mac_begin_clip (GC_CLIP_REGION (gc)); | |
724 RGBForeColor (GC_FORE_COLOR (gc)); | |
725 if (bg_width) | |
726 { | |
727 Rect r; | |
728 | |
729 SetRect (&r, x, y - FONT_BASE (GC_FONT (gc)), | |
730 x + bg_width, y + FONT_DESCENT (GC_FONT (gc))); | |
731 RGBBackColor (GC_BACK_COLOR (gc)); | |
732 EraseRect (&r); | |
733 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f))); | |
734 } | |
735 MoveTo (x, y); | |
736 ATSUDrawText (text_layout, | |
737 kATSUFromTextBeginning, kATSUToTextEnd, | |
738 kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc); | |
739 mac_end_clip (GC_CLIP_REGION (gc)); | |
731 #ifdef MAC_OSX | 740 #ifdef MAC_OSX |
732 if (!mac_use_core_graphics) | 741 } |
742 else | |
743 { | |
744 CGrafPtr port; | |
745 CGContextRef context; | |
746 float port_height = FRAME_PIXEL_HEIGHT (f); | |
747 ATSUAttributeTag tags[] = {kATSUCGContextTag}; | |
748 ByteCount sizes[] = {sizeof (CGContextRef)}; | |
749 ATSUAttributeValuePtr values[] = {&context}; | |
750 | |
751 GetPort (&port); | |
752 QDBeginCGContext (port, &context); | |
753 if (gc->n_clip_rects || bg_width) | |
733 { | 754 { |
734 #endif | 755 CGContextTranslateCTM (context, 0, port_height); |
735 mac_begin_clip (GC_CLIP_REGION (gc)); | 756 CGContextScaleCTM (context, 1, -1); |
736 MoveTo (x, y); | 757 if (gc->n_clip_rects) |
737 ATSUDrawText (text_layout, | 758 CGContextClipToRects (context, gc->clip_rects, |
738 kATSUFromTextBeginning, kATSUToTextEnd, | 759 gc->n_clip_rects); |
739 kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc); | 760 if (bg_width) |
740 mac_end_clip (GC_CLIP_REGION (gc)); | 761 { |
741 #ifdef MAC_OSX | 762 CGContextSetRGBFillColor |
763 (context, | |
764 RED_FROM_ULONG (gc->xgcv.background) / 255.0f, | |
765 GREEN_FROM_ULONG (gc->xgcv.background) / 255.0f, | |
766 BLUE_FROM_ULONG (gc->xgcv.background) / 255.0f, | |
767 1.0); | |
768 CGContextFillRect | |
769 (context, | |
770 CGRectMake (x, y - FONT_BASE (GC_FONT (gc)), | |
771 bg_width, FONT_HEIGHT (GC_FONT (gc)))); | |
772 } | |
773 CGContextScaleCTM (context, 1, -1); | |
774 CGContextTranslateCTM (context, 0, -port_height); | |
742 } | 775 } |
743 else | 776 CGContextSetRGBFillColor |
744 { | 777 (context, |
745 CGrafPtr port; | 778 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0f, |
746 CGContextRef context; | 779 GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0f, |
747 float port_height = FRAME_PIXEL_HEIGHT (f); | 780 BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0f, |
748 ATSUAttributeTag tags[] = {kATSUCGContextTag}; | 781 1.0); |
749 ByteCount sizes[] = {sizeof (CGContextRef)}; | 782 err = ATSUSetLayoutControls (text_layout, |
750 ATSUAttributeValuePtr values[] = {&context}; | 783 sizeof (tags) / sizeof (tags[0]), |
751 | 784 tags, sizes, values); |
752 GetPort (&port); | 785 if (err == noErr) |
753 QDBeginCGContext (port, &context); | 786 ATSUDrawText (text_layout, |
754 if (gc->n_clip_rects) | 787 kATSUFromTextBeginning, kATSUToTextEnd, |
755 { | 788 Long2Fix (x), Long2Fix (port_height - y)); |
756 CGContextTranslateCTM (context, 0, port_height); | 789 CGContextSynchronize (context); |
757 CGContextScaleCTM (context, 1, -1); | 790 QDEndCGContext (port, &context); |
758 CGContextClipToRects (context, gc->clip_rects, | |
759 gc->n_clip_rects); | |
760 CGContextScaleCTM (context, 1, -1); | |
761 CGContextTranslateCTM (context, 0, -port_height); | |
762 } | |
763 CGContextSetRGBFillColor | |
764 (context, | |
765 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0, | |
766 GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0, | |
767 BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0, | |
768 1.0); | |
769 err = ATSUSetLayoutControls (text_layout, | |
770 sizeof (tags) / sizeof (tags[0]), | |
771 tags, sizes, values); | |
772 if (err == noErr) | |
773 ATSUDrawText (text_layout, | |
774 kATSUFromTextBeginning, kATSUToTextEnd, | |
775 Long2Fix (x), Long2Fix (port_height - y)); | |
776 CGContextSynchronize (context); | |
777 QDEndCGContext (port, &context); | |
778 #if 0 | 791 #if 0 |
779 /* This doesn't work on Mac OS X 10.1. */ | 792 /* This doesn't work on Mac OS X 10.1. */ |
780 ATSUClearLayoutControls (text_layout, | 793 ATSUClearLayoutControls (text_layout, |
781 sizeof (tags) / sizeof (tags[0]), | 794 sizeof (tags) / sizeof (tags[0]), tags); |
782 tags); | |
783 #else | 795 #else |
784 ATSUSetLayoutControls (text_layout, | 796 ATSUSetLayoutControls (text_layout, |
785 sizeof (tags) / sizeof (tags[0]), | 797 sizeof (tags) / sizeof (tags[0]), |
786 tags, sizes, values); | 798 tags, sizes, values); |
787 #endif | |
788 } | |
789 #endif | 799 #endif |
790 } | 800 } |
801 #endif /* MAC_OSX */ | |
791 } | 802 } |
792 else | 803 else |
793 { | 804 #endif /* USE_ATSUI */ |
794 #endif | 805 { |
795 TextFont (GC_FONT (gc)->mac_fontnum); | |
796 TextSize (GC_FONT (gc)->mac_fontsize); | |
797 TextFace (GC_FONT (gc)->mac_fontface); | |
798 TextMode (mode); | |
799 | |
800 mac_begin_clip (GC_CLIP_REGION (gc)); | |
801 MoveTo (x, y); | |
802 DrawText (buf, 0, nchars * bytes_per_char); | |
803 mac_end_clip (GC_CLIP_REGION (gc)); | |
804 #if USE_ATSUI | |
805 } | |
806 #endif | |
807 | |
808 if (mode != srcOr) | |
809 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f))); | |
810 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 | 806 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 |
811 if (mac_use_core_graphics) | 807 UInt32 savedFlags; |
812 SwapQDTextFlags(savedFlags); | 808 |
813 #endif | 809 if (mac_use_core_graphics) |
810 savedFlags = SwapQDTextFlags (kQDUseCGTextRendering); | |
811 #endif | |
812 mac_begin_clip (GC_CLIP_REGION (gc)); | |
813 RGBForeColor (GC_FORE_COLOR (gc)); | |
814 #ifdef MAC_OS8 | |
815 if (bg_width) | |
816 { | |
817 RGBBackColor (GC_BACK_COLOR (gc)); | |
818 TextMode (srcCopy); | |
819 } | |
820 else | |
821 TextMode (srcOr); | |
822 #else | |
823 /* We prefer not to use srcCopy text transfer mode on Mac OS X | |
824 because: | |
825 - Screen is double-buffered. (In srcCopy mode, a text is | |
826 drawn into an offscreen graphics world first. So | |
827 performance gain cannot be expected.) | |
828 - It lowers rendering quality. | |
829 - Some fonts leave garbage on cursor movement. */ | |
830 if (bg_width) | |
831 { | |
832 Rect r; | |
833 | |
834 RGBBackColor (GC_BACK_COLOR (gc)); | |
835 SetRect (&r, x, y - FONT_BASE (GC_FONT (gc)), | |
836 x + bg_width, y + FONT_DESCENT (GC_FONT (gc))); | |
837 EraseRect (&r); | |
838 } | |
839 TextMode (srcOr); | |
840 #endif | |
841 TextFont (GC_FONT (gc)->mac_fontnum); | |
842 TextSize (GC_FONT (gc)->mac_fontsize); | |
843 TextFace (GC_FONT (gc)->mac_fontface); | |
844 MoveTo (x, y); | |
845 DrawText (buf, 0, nchars * bytes_per_char); | |
846 if (bg_width) | |
847 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f))); | |
848 mac_end_clip (GC_CLIP_REGION (gc)); | |
849 | |
850 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 | |
851 if (mac_use_core_graphics) | |
852 SwapQDTextFlags(savedFlags); | |
853 #endif | |
854 } | |
814 } | 855 } |
815 | 856 |
816 | 857 |
817 /* Mac replacement for XDrawString. */ | 858 /* Mac replacement for XDrawString. */ |
818 | 859 |
822 GC gc; | 863 GC gc; |
823 int x, y; | 864 int x, y; |
824 char *buf; | 865 char *buf; |
825 int nchars; | 866 int nchars; |
826 { | 867 { |
827 mac_draw_string_common (f, gc, x, y, buf, nchars, srcOr, 1); | 868 mac_draw_string_common (f, gc, x, y, buf, nchars, 0, 1); |
828 } | 869 } |
829 | 870 |
830 | 871 |
831 /* Mac replacement for XDrawString16. */ | 872 /* Mac replacement for XDrawString16. */ |
832 | 873 |
836 GC gc; | 877 GC gc; |
837 int x, y; | 878 int x, y; |
838 XChar2b *buf; | 879 XChar2b *buf; |
839 int nchars; | 880 int nchars; |
840 { | 881 { |
841 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, srcOr, 2); | 882 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, 0, 2); |
842 } | 883 } |
843 | 884 |
844 | 885 |
845 /* Mac replacement for XDrawImageString. */ | 886 /* Mac replacement for XDrawImageString. */ |
846 | 887 |
847 static void | 888 static void |
848 mac_draw_image_string (f, gc, x, y, buf, nchars) | 889 mac_draw_image_string (f, gc, x, y, buf, nchars, bg_width) |
849 struct frame *f; | 890 struct frame *f; |
850 GC gc; | 891 GC gc; |
851 int x, y; | 892 int x, y; |
852 char *buf; | 893 char *buf; |
853 int nchars; | 894 int nchars, bg_width; |
854 { | 895 { |
855 mac_draw_string_common (f, gc, x, y, buf, nchars, srcCopy, 1); | 896 mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, 1); |
856 } | 897 } |
857 | 898 |
858 | 899 |
859 /* Mac replacement for XDrawString16. */ | 900 /* Mac replacement for XDrawString16. */ |
860 | 901 |
861 static void | 902 static void |
862 mac_draw_image_string_16 (f, gc, x, y, buf, nchars) | 903 mac_draw_image_string_16 (f, gc, x, y, buf, nchars, bg_width) |
863 struct frame *f; | 904 struct frame *f; |
864 GC gc; | 905 GC gc; |
865 int x, y; | 906 int x, y; |
866 XChar2b *buf; | 907 XChar2b *buf; |
867 int nchars; | 908 int nchars, bg_width; |
868 { | 909 { |
869 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, srcCopy, 2); | 910 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, bg_width, 2); |
870 } | 911 } |
871 | 912 |
872 | 913 |
873 /* Mac replacement for XQueryTextExtents, but takes a character. If | 914 /* Mac replacement for XQueryTextExtents, but takes a character. If |
874 STYLE is NULL, measurement is done by QuickDraw Text routines for | 915 STYLE is NULL, measurement is done by QuickDraw Text routines for |
1038 if (valid_p) | 1079 if (valid_p) |
1039 cg_text_anti_aliasing_threshold = threshold; | 1080 cg_text_anti_aliasing_threshold = threshold; |
1040 } | 1081 } |
1041 | 1082 |
1042 static int | 1083 static int |
1043 mac_draw_string_cg (f, gc, x, y, buf, nchars) | 1084 mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width) |
1044 struct frame *f; | 1085 struct frame *f; |
1045 GC gc; | 1086 GC gc; |
1046 int x, y; | 1087 int x, y; |
1047 XChar2b *buf; | 1088 XChar2b *buf; |
1048 int nchars; | 1089 int nchars, bg_width; |
1049 { | 1090 { |
1050 CGrafPtr port; | 1091 CGrafPtr port; |
1051 float port_height, gx, gy; | 1092 float port_height, gx, gy; |
1052 int i; | 1093 int i; |
1053 CGContextRef context; | 1094 CGContextRef context; |
1060 port = GetWindowPort (FRAME_MAC_WINDOW (f)); | 1101 port = GetWindowPort (FRAME_MAC_WINDOW (f)); |
1061 port_height = FRAME_PIXEL_HEIGHT (f); | 1102 port_height = FRAME_PIXEL_HEIGHT (f); |
1062 gx = x; | 1103 gx = x; |
1063 gy = port_height - y; | 1104 gy = port_height - y; |
1064 glyphs = (CGGlyph *)buf; | 1105 glyphs = (CGGlyph *)buf; |
1065 advances = xmalloc (sizeof (CGSize) * nchars); | 1106 advances = alloca (sizeof (CGSize) * nchars); |
1107 if (advances == NULL) | |
1108 return 0; | |
1066 for (i = 0; i < nchars; i++) | 1109 for (i = 0; i < nchars; i++) |
1067 { | 1110 { |
1068 XCharStruct *pcm = mac_per_char_metric (GC_FONT (gc), buf, 0); | 1111 XCharStruct *pcm = mac_per_char_metric (GC_FONT (gc), buf, 0); |
1069 | 1112 |
1070 advances[i].width = pcm->width; | 1113 advances[i].width = pcm->width; |
1072 glyphs[i] = GC_FONT (gc)->cg_glyphs[buf->byte2]; | 1115 glyphs[i] = GC_FONT (gc)->cg_glyphs[buf->byte2]; |
1073 buf++; | 1116 buf++; |
1074 } | 1117 } |
1075 | 1118 |
1076 QDBeginCGContext (port, &context); | 1119 QDBeginCGContext (port, &context); |
1077 if (gc->n_clip_rects) | 1120 if (gc->n_clip_rects || bg_width) |
1078 { | 1121 { |
1079 CGContextTranslateCTM (context, 0, port_height); | 1122 CGContextTranslateCTM (context, 0, port_height); |
1080 CGContextScaleCTM (context, 1, -1); | 1123 CGContextScaleCTM (context, 1, -1); |
1081 CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects); | 1124 if (gc->n_clip_rects) |
1125 CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects); | |
1126 if (bg_width) | |
1127 { | |
1128 CGContextSetRGBFillColor | |
1129 (context, | |
1130 RED_FROM_ULONG (gc->xgcv.background) / 255.0f, | |
1131 GREEN_FROM_ULONG (gc->xgcv.background) / 255.0f, | |
1132 BLUE_FROM_ULONG (gc->xgcv.background) / 255.0f, | |
1133 1.0); | |
1134 CGContextFillRect | |
1135 (context, | |
1136 CGRectMake (gx, y - FONT_BASE (GC_FONT (gc)), | |
1137 bg_width, FONT_HEIGHT (GC_FONT (gc)))); | |
1138 } | |
1082 CGContextScaleCTM (context, 1, -1); | 1139 CGContextScaleCTM (context, 1, -1); |
1083 CGContextTranslateCTM (context, 0, -port_height); | 1140 CGContextTranslateCTM (context, 0, -port_height); |
1084 } | 1141 } |
1085 CGContextSetRGBFillColor (context, | 1142 CGContextSetRGBFillColor (context, |
1086 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0, | 1143 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0f, |
1087 GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0, | 1144 GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0f, |
1088 BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0, | 1145 BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0f, |
1089 1.0); | 1146 1.0); |
1090 CGContextSetFont (context, GC_FONT (gc)->cg_font); | 1147 CGContextSetFont (context, GC_FONT (gc)->cg_font); |
1091 CGContextSetFontSize (context, GC_FONT (gc)->mac_fontsize); | 1148 CGContextSetFontSize (context, GC_FONT (gc)->mac_fontsize); |
1092 if (GC_FONT (gc)->mac_fontsize <= cg_text_anti_aliasing_threshold) | 1149 if (GC_FONT (gc)->mac_fontsize <= cg_text_anti_aliasing_threshold) |
1093 CGContextSetShouldAntialias (context, false); | 1150 CGContextSetShouldAntialias (context, false); |
1101 gx += advances[i].width; | 1158 gx += advances[i].width; |
1102 } | 1159 } |
1103 #endif | 1160 #endif |
1104 CGContextSynchronize (context); | 1161 CGContextSynchronize (context); |
1105 QDEndCGContext (port, &context); | 1162 QDEndCGContext (port, &context); |
1106 | |
1107 xfree (advances); | |
1108 | 1163 |
1109 return 1; | 1164 return 1; |
1110 } | 1165 } |
1111 #endif | 1166 #endif |
1112 | 1167 |
1375 if (n < 0 || n > MAX_CLIP_RECTS) | 1430 if (n < 0 || n > MAX_CLIP_RECTS) |
1376 abort (); | 1431 abort (); |
1377 if (n == 0) | 1432 if (n == 0) |
1378 { | 1433 { |
1379 if (gc->clip_region) | 1434 if (gc->clip_region) |
1380 { | 1435 SetEmptyRgn (gc->clip_region); |
1381 DisposeRgn (gc->clip_region); | |
1382 gc->clip_region = NULL; | |
1383 } | |
1384 } | 1436 } |
1385 else | 1437 else |
1386 { | 1438 { |
1387 if (gc->clip_region == NULL) | 1439 if (gc->clip_region == NULL) |
1388 gc->clip_region = NewRgn (); | 1440 gc->clip_region = NewRgn (); |
2322 { | 2374 { |
2323 mac_erase_rectangle (s->f, s->gc, x, y, w, h); | 2375 mac_erase_rectangle (s->f, s->gc, x, y, w, h); |
2324 } | 2376 } |
2325 | 2377 |
2326 | 2378 |
2327 /* We prefer not to use XDrawImageString (srcCopy text transfer mode) | |
2328 on Mac OS X because: | |
2329 - Screen is double-buffered. (In srcCopy mode, a text is drawn | |
2330 into an offscreen graphics world first. So performance gain | |
2331 cannot be expected.) | |
2332 - It lowers rendering quality. | |
2333 - Some fonts leave garbage on cursor movement. */ | |
2334 | |
2335 /* Draw the background of glyph_string S. If S->background_filled_p | 2379 /* Draw the background of glyph_string S. If S->background_filled_p |
2336 is non-zero don't draw it. FORCE_P non-zero means draw the | 2380 is non-zero don't draw it. FORCE_P non-zero means draw the |
2337 background even if it wouldn't be drawn normally. This is used | 2381 background even if it wouldn't be drawn normally. This is used |
2338 when a string preceding S draws into the background of S, or S | 2382 when a string preceding S draws into the background of S, or S |
2339 contains the first component of a composition. */ | 2383 contains the first component of a composition. */ |
2361 XSetFillStyle (s->display, s->gc, FillSolid); | 2405 XSetFillStyle (s->display, s->gc, FillSolid); |
2362 s->background_filled_p = 1; | 2406 s->background_filled_p = 1; |
2363 } | 2407 } |
2364 else | 2408 else |
2365 #endif | 2409 #endif |
2366 #if defined (MAC_OS8) && !USE_ATSUI | |
2367 if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width | 2410 if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width |
2368 || s->font_not_found_p | 2411 || s->font_not_found_p |
2369 || s->extends_to_end_of_line_p | 2412 || s->extends_to_end_of_line_p |
2370 || force_p) | 2413 || force_p) |
2371 #endif | |
2372 { | 2414 { |
2373 x_clear_glyph_string_rect (s, s->x, s->y + box_line_width, | 2415 x_clear_glyph_string_rect (s, s->x, s->y + box_line_width, |
2374 s->background_width, | 2416 s->background_width, |
2375 s->height - 2 * box_line_width); | 2417 s->height - 2 * box_line_width); |
2376 s->background_filled_p = 1; | 2418 s->background_filled_p = 1; |
2383 | 2425 |
2384 static void | 2426 static void |
2385 x_draw_glyph_string_foreground (s) | 2427 x_draw_glyph_string_foreground (s) |
2386 struct glyph_string *s; | 2428 struct glyph_string *s; |
2387 { | 2429 { |
2388 int i, x; | 2430 int i, x, bg_width; |
2389 | 2431 |
2390 /* If first glyph of S has a left box line, start drawing the text | 2432 /* If first glyph of S has a left box line, start drawing the text |
2391 of S to the right of that box line. */ | 2433 of S to the right of that box line. */ |
2392 if (s->face->box != FACE_NO_BOX | 2434 if (s->face->box != FACE_NO_BOX |
2393 && s->first_glyph->left_box_line_p) | 2435 && s->first_glyph->left_box_line_p) |
2422 #endif | 2464 #endif |
2423 ) | 2465 ) |
2424 for (i = 0; i < s->nchars; ++i) | 2466 for (i = 0; i < s->nchars; ++i) |
2425 char1b[i] = s->char2b[i].byte2; | 2467 char1b[i] = s->char2b[i].byte2; |
2426 | 2468 |
2427 #if defined (MAC_OS8) && !USE_ATSUI | |
2428 /* Draw text with XDrawString if background has already been | 2469 /* Draw text with XDrawString if background has already been |
2429 filled. Otherwise, use XDrawImageString. (Note that | 2470 filled. Otherwise, use XDrawImageString. (Note that |
2430 XDrawImageString is usually faster than XDrawString.) Always | 2471 XDrawImageString is usually faster than XDrawString.) Always |
2431 use XDrawImageString when drawing the cursor so that there is | 2472 use XDrawImageString when drawing the cursor so that there is |
2432 no chance that characters under a box cursor are invisible. */ | 2473 no chance that characters under a box cursor are invisible. */ |
2433 if (s->for_overlaps | 2474 if (s->for_overlaps |
2434 || (s->background_filled_p && s->hl != DRAW_CURSOR)) | 2475 || (s->background_filled_p && s->hl != DRAW_CURSOR)) |
2435 #endif | 2476 bg_width = 0; /* Corresponds to XDrawString. */ |
2436 { | 2477 else |
2437 /* Draw characters with 16-bit or 8-bit functions. */ | 2478 bg_width = s->background_width; /* Corresponds to XDrawImageString. */ |
2438 if (s->two_byte_p | 2479 |
2480 if (s->two_byte_p | |
2439 #if USE_ATSUI | 2481 #if USE_ATSUI |
2440 || GC_FONT (s->gc)->mac_style | 2482 || GC_FONT (s->gc)->mac_style |
2441 #endif | 2483 #endif |
2442 ) | 2484 ) |
2443 #if USE_CG_TEXT_DRAWING | 2485 #if USE_CG_TEXT_DRAWING |
2444 if (!s->two_byte_p | 2486 if (!s->two_byte_p |
2445 && mac_draw_string_cg (s->f, s->gc, x, s->ybase - boff, | 2487 && mac_draw_image_string_cg (s->f, s->gc, x, s->ybase - boff, |
2446 s->char2b, s->nchars)) | 2488 s->char2b, s->nchars, bg_width)) |
2447 ; | 2489 ; |
2448 else | 2490 else |
2449 #endif | 2491 #endif |
2450 mac_draw_string_16 (s->f, s->gc, x, s->ybase - boff, | 2492 mac_draw_image_string_16 (s->f, s->gc, x, s->ybase - boff, |
2451 s->char2b, s->nchars); | 2493 s->char2b, s->nchars, bg_width); |
2452 else | |
2453 mac_draw_string (s->f, s->gc, x, s->ybase - boff, | |
2454 char1b, s->nchars); | |
2455 } | |
2456 #if defined (MAC_OS8) && !USE_ATSUI | |
2457 else | 2494 else |
2458 { | 2495 mac_draw_image_string (s->f, s->gc, x, s->ybase - boff, |
2459 if (s->two_byte_p) | 2496 char1b, s->nchars, bg_width); |
2460 mac_draw_image_string_16 (s->f, s->gc, x, s->ybase - boff, | |
2461 s->char2b, s->nchars); | |
2462 else | |
2463 mac_draw_image_string (s->f, s->gc, x, s->ybase - boff, | |
2464 char1b, s->nchars); | |
2465 } | |
2466 #endif | |
2467 } | 2497 } |
2468 } | 2498 } |
2469 | 2499 |
2470 /* Draw the foreground of composite glyph string S. */ | 2500 /* Draw the foreground of composite glyph string S. */ |
2471 | 2501 |
7854 } | 7884 } |
7855 | 7885 |
7856 #if !defined (MAC_OS8) || USE_ATSUI | 7886 #if !defined (MAC_OS8) || USE_ATSUI |
7857 /* AppKit and WebKit do some adjustment to the heights of Courier, | 7887 /* AppKit and WebKit do some adjustment to the heights of Courier, |
7858 Helvetica, and Times. This only works on the environments where | 7888 Helvetica, and Times. This only works on the environments where |
7859 the XDrawImageString counterpart is never used. */ | 7889 srcCopy text transfer mode is never used. */ |
7860 if (strcmp (family, "courier") == 0 || strcmp (family, "helvetica") == 0 | 7890 if ( |
7861 || strcmp (family, "times") == 0) | 7891 #ifdef MAC_OS8 /* implies USE_ATSUI */ |
7892 font->mac_style && | |
7893 #endif | |
7894 (strcmp (family, "courier") == 0 || strcmp (family, "helvetica") == 0 | |
7895 || strcmp (family, "times") == 0)) | |
7862 font->ascent += (font->ascent + font->descent) * .15 + 0.5; | 7896 font->ascent += (font->ascent + font->descent) * .15 + 0.5; |
7863 #endif | 7897 #endif |
7864 | 7898 |
7865 return font; | 7899 return font; |
7866 } | 7900 } |