comparison src/macterm.c @ 58634:95d38c47c806

* keyboard.c: Don't undef SIGIO * s/darwin.h (NO_SOCK_SIGIO): Define NO_SOCK_SIGIO on carbon * Makefile.in (mac.o): Depend on blockinput.h and atimer.h. (macfns.o): Don't depend on ccl.h. * macfns.c (mac_frame_parm_handlers): Set handlers for Qleft_fringe and Qright_fringe. * macterm.c (mac_fill_rectangle_to_pixmap) (mac_draw_rectangle_to_pixmap, mac_copy_area_to_pixmap) (mac_copy_area_with_mask_to_pixmap, x_draw_image_foreground_1): Put in #if 0. (mac_scroll_area) [TARGET_API_MAC_CARBON]: Use ScrollWindowRect. (x_flush) [TARGET_API_MAC_CARBON]: Don't traverse frames. (XFlush) [TARGET_API_MAC_CARBON]: Define to an empty replacement. (x_draw_glyph_string_background, x_draw_glyph_string_foreground) [!MAC_OS8]: Added ifdef'd out code for os8. Don't use XDrawImageString. Always draw background and foreground separately. (x_draw_image_foreground): Use clipping instead of computing the intersection rectangle. (x_draw_image_glyph_string): Don't draw an image with mask to a pixmap. (x_redisplay_interface): Set flush_display_optional member to 0. (XTread_socket): Correctly reset the TEConverter object.
author Steven Tamm <steventamm@mac.com>
date Tue, 30 Nov 2004 05:57:27 +0000
parents c936fa56eb60
children 2dd8aacd82ce 549734260e34 f2ebccfa87d4
comparison
equal deleted inserted replaced
58633:55d668830eed 58634:95d38c47c806
565 Pixmap 565 Pixmap
566 XCreatePixmap (display, w, width, height, depth) 566 XCreatePixmap (display, w, width, height, depth)
567 Display *display; /* not used */ 567 Display *display; /* not used */
568 WindowPtr w; 568 WindowPtr w;
569 unsigned int width, height; 569 unsigned int width, height;
570 unsigned int depth; /* not used */ 570 unsigned int depth;
571 { 571 {
572 Pixmap pixmap; 572 Pixmap pixmap;
573 Rect r; 573 Rect r;
574 QDErr err; 574 QDErr err;
575 575
641 641
642 PaintRect (&r); /* using foreground color of gc */ 642 PaintRect (&r); /* using foreground color of gc */
643 } 643 }
644 644
645 645
646 #if 0 /* TODO: figure out if we need to do this on Mac. */
646 static void 647 static void
647 mac_fill_rectangle_to_pixmap (display, p, gc, x, y, width, height) 648 mac_fill_rectangle_to_pixmap (display, p, gc, x, y, width, height)
648 Display *display; 649 Display *display;
649 Pixmap p; 650 Pixmap p;
650 GC gc; 651 GC gc;
664 PaintRect (&r); /* using foreground color of gc */ 665 PaintRect (&r); /* using foreground color of gc */
665 UnlockPixels (GetGWorldPixMap (p)); 666 UnlockPixels (GetGWorldPixMap (p));
666 667
667 SetGWorld (old_port, old_gdh); 668 SetGWorld (old_port, old_gdh);
668 } 669 }
670 #endif
669 671
670 672
671 /* Mac replacement for XDrawRectangle: dest is a window. */ 673 /* Mac replacement for XDrawRectangle: dest is a window. */
672 674
673 static void 675 static void
687 689
688 FrameRect (&r); /* using foreground color of gc */ 690 FrameRect (&r); /* using foreground color of gc */
689 } 691 }
690 692
691 693
694 #if 0 /* TODO: figure out if we need to do this on Mac. */
692 /* Mac replacement for XDrawRectangle: dest is a Pixmap. */ 695 /* Mac replacement for XDrawRectangle: dest is a Pixmap. */
693 696
694 static void 697 static void
695 mac_draw_rectangle_to_pixmap (display, p, gc, x, y, width, height) 698 mac_draw_rectangle_to_pixmap (display, p, gc, x, y, width, height)
696 Display *display; 699 Display *display;
712 FrameRect (&r); /* using foreground color of gc */ 715 FrameRect (&r); /* using foreground color of gc */
713 UnlockPixels (GetGWorldPixMap (p)); 716 UnlockPixels (GetGWorldPixMap (p));
714 717
715 SetGWorld (old_port, old_gdh); 718 SetGWorld (old_port, old_gdh);
716 } 719 }
720 #endif
717 721
718 722
719 static void 723 static void
720 mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode, 724 mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
721 bytes_per_char) 725 bytes_per_char)
906 int src_x, src_y; 910 int src_x, src_y;
907 unsigned int width, height; 911 unsigned int width, height;
908 int dest_x, dest_y; 912 int dest_x, dest_y;
909 { 913 {
910 #if TARGET_API_MAC_CARBON 914 #if TARGET_API_MAC_CARBON
911 Rect gw_r, src_r, dest_r; 915 Rect src_r;
916 RgnHandle dummy = NewRgn (); /* For avoiding update events. */
912 917
913 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 918 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
914 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); 919 ScrollWindowRect (w, &src_r, dest_x - src_x, dest_y - src_y,
915 920 kScrollWindowNoOptions, dummy);
916 SetPortWindowPort (w); 921 DisposeRgn (dummy);
917
918 ForeColor (blackColor);
919 BackColor (whiteColor);
920
921 LockPortBits (GetWindowPort (w));
922 {
923 const BitMap *bitmap = GetPortBitMapForCopyBits (GetWindowPort (w));
924 CopyBits (bitmap, bitmap, &src_r, &dest_r, srcCopy, 0);
925 }
926 UnlockPortBits (GetWindowPort (w));
927
928 mac_set_colors (gc);
929 #else /* not TARGET_API_MAC_CARBON */ 922 #else /* not TARGET_API_MAC_CARBON */
930 Rect src_r, dest_r; 923 Rect src_r, dest_r;
931 924
932 SetPort (w); 925 SetPort (w);
933 #if 0 926 #if 0
957 #endif 950 #endif
958 #endif /* not TARGET_API_MAC_CARBON */ 951 #endif /* not TARGET_API_MAC_CARBON */
959 } 952 }
960 953
961 954
955 #if 0 /* TODO: figure out if we need to do this on Mac. */
962 /* Mac replacement for XCopyArea: dest must be Pixmap. */ 956 /* Mac replacement for XCopyArea: dest must be Pixmap. */
963 957
964 static void 958 static void
965 mac_copy_area_to_pixmap (display, src, dest, gc, src_x, src_y, width, height, 959 mac_copy_area_to_pixmap (display, src, dest, gc, src_x, src_y, width, height,
966 dest_x, dest_y) 960 dest_x, dest_y)
1035 UnlockPixels (GetGWorldPixMap (mask)); 1029 UnlockPixels (GetGWorldPixMap (mask));
1036 UnlockPixels (GetGWorldPixMap (src)); 1030 UnlockPixels (GetGWorldPixMap (src));
1037 1031
1038 SetGWorld (old_port, old_gdh); 1032 SetGWorld (old_port, old_gdh);
1039 } 1033 }
1034 #endif
1040 1035
1041 1036
1042 /* Mac replacement for XChangeGC. */ 1037 /* Mac replacement for XChangeGC. */
1043 1038
1044 static void 1039 static void
1129 void *f; 1124 void *f;
1130 { 1125 {
1131 } 1126 }
1132 1127
1133 1128
1129 /* Flush display of frame F, or of all frames if F is null. */
1130
1131 static void
1132 x_flush (f)
1133 struct frame *f;
1134 {
1135 #if TARGET_API_MAC_CARBON
1136 BLOCK_INPUT;
1137 if (f)
1138 QDFlushPortBuffer (GetWindowPort (FRAME_MAC_WINDOW (f)), NULL);
1139 else
1140 QDFlushPortBuffer (GetQDGlobalsThePort (), NULL);
1141 UNBLOCK_INPUT;
1142 #endif
1143 }
1144
1145
1134 /* Remove calls to XFlush by defining XFlush to an empty replacement. 1146 /* Remove calls to XFlush by defining XFlush to an empty replacement.
1135 Calls to XFlush should be unnecessary because the X output buffer 1147 Calls to XFlush should be unnecessary because the X output buffer
1136 is flushed automatically as needed by calls to XPending, 1148 is flushed automatically as needed by calls to XPending,
1137 XNextEvent, or XWindowEvent according to the XFlush man page. 1149 XNextEvent, or XWindowEvent according to the XFlush man page.
1138 XTread_socket calls XPending. Removing XFlush improves 1150 XTread_socket calls XPending. Removing XFlush improves
1139 performance. */ 1151 performance. */
1140 1152
1141 #if TARGET_API_MAC_CARBON
1142 #define XFlush(DISPLAY) QDFlushPortBuffer (GetQDGlobalsThePort (), NULL)
1143 #else
1144 #define XFlush(DISPLAY) (void) 0 1153 #define XFlush(DISPLAY) (void) 0
1145 #endif
1146
1147 /* Flush display of frame F, or of all frames if F is null. */
1148
1149 void
1150 x_flush (f)
1151 struct frame *f;
1152 {
1153 #if TARGET_API_MAC_CARBON
1154 BLOCK_INPUT;
1155 if (f == NULL)
1156 {
1157 Lisp_Object rest, frame;
1158 FOR_EACH_FRAME (rest, frame)
1159 x_flush (XFRAME (frame));
1160 }
1161 else if (FRAME_MAC_P (f))
1162 XFlush (FRAME_MAC_DISPLAY (f));
1163 UNBLOCK_INPUT;
1164 #endif /* TARGET_API_MAC_CARBON */
1165 }
1166
1167 1154
1168 1155
1169 /* Return the struct mac_display_info corresponding to DPY. There's 1156 /* Return the struct mac_display_info corresponding to DPY. There's
1170 only one. */ 1157 only one. */
1171 1158
1955 xgcv.foreground = s->gc->background; 1942 xgcv.foreground = s->gc->background;
1956 XFillRectangle (s->display, s->window, &xgcv, x, y, w, h); 1943 XFillRectangle (s->display, s->window, &xgcv, x, y, w, h);
1957 } 1944 }
1958 1945
1959 1946
1947 /* We prefer not to use XDrawImageString (srcCopy text transfer mode)
1948 on Mac OS X because:
1949 - Screen is double-buffered. (In srcCopy mode, a text is drawn
1950 into an offscreen graphics world first. So performance gain
1951 cannot be expected.)
1952 - It lowers rendering quality.
1953 - Some fonts leave garbage on cursor movement. */
1954
1960 /* Draw the background of glyph_string S. If S->background_filled_p 1955 /* Draw the background of glyph_string S. If S->background_filled_p
1961 is non-zero don't draw it. FORCE_P non-zero means draw the 1956 is non-zero don't draw it. FORCE_P non-zero means draw the
1962 background even if it wouldn't be drawn normally. This is used 1957 background even if it wouldn't be drawn normally. This is used
1963 when a string preceding S draws into the background of S, or S 1958 when a string preceding S draws into the background of S, or S
1964 contains the first component of a composition. */ 1959 contains the first component of a composition. */
1986 XSetFillStyle (s->display, s->gc, FillSolid); 1981 XSetFillStyle (s->display, s->gc, FillSolid);
1987 s->background_filled_p = 1; 1982 s->background_filled_p = 1;
1988 } 1983 }
1989 else 1984 else
1990 #endif 1985 #endif
1986 #if 0 /* defined(MAC_OS8)*/
1991 if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width 1987 if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width
1992 || s->font_not_found_p 1988 || s->font_not_found_p
1993 || s->extends_to_end_of_line_p 1989 || s->extends_to_end_of_line_p
1994 || force_p) 1990 || force_p)
1991 #endif
1995 { 1992 {
1996 x_clear_glyph_string_rect (s, s->x, s->y + box_line_width, 1993 x_clear_glyph_string_rect (s, s->x, s->y + box_line_width,
1997 s->background_width, 1994 s->background_width,
1998 s->height - 2 * box_line_width); 1995 s->height - 2 * box_line_width);
1999 s->background_filled_p = 1; 1996 s->background_filled_p = 1;
2042 /* If we can use 8-bit functions, condense S->char2b. */ 2039 /* If we can use 8-bit functions, condense S->char2b. */
2043 if (!s->two_byte_p) 2040 if (!s->two_byte_p)
2044 for (i = 0; i < s->nchars; ++i) 2041 for (i = 0; i < s->nchars; ++i)
2045 char1b[i] = s->char2b[i].byte2; 2042 char1b[i] = s->char2b[i].byte2;
2046 2043
2044 #if 0 /* defined(MAC_OS8) */
2047 /* Draw text with XDrawString if background has already been 2045 /* Draw text with XDrawString if background has already been
2048 filled. Otherwise, use XDrawImageString. (Note that 2046 filled. Otherwise, use XDrawImageString. (Note that
2049 XDrawImageString is usually faster than XDrawString.) Always 2047 XDrawImageString is usually faster than XDrawString.) Always
2050 use XDrawImageString when drawing the cursor so that there is 2048 use XDrawImageString when drawing the cursor so that there is
2051 no chance that characters under a box cursor are invisible. */ 2049 no chance that characters under a box cursor are invisible. */
2052 if (s->for_overlaps_p 2050 if (s->for_overlaps_p
2053 || (s->background_filled_p && s->hl != DRAW_CURSOR)) 2051 || (s->background_filled_p && s->hl != DRAW_CURSOR))
2052 #endif
2054 { 2053 {
2055 /* Draw characters with 16-bit or 8-bit functions. */ 2054 /* Draw characters with 16-bit or 8-bit functions. */
2056 if (s->two_byte_p) 2055 if (s->two_byte_p)
2057 XDrawString16 (s->display, s->window, s->gc, x, 2056 XDrawString16 (s->display, s->window, s->gc, x,
2058 s->ybase - boff, s->char2b, s->nchars); 2057 s->ybase - boff, s->char2b, s->nchars);
2059 else 2058 else
2060 XDrawString (s->display, s->window, s->gc, x, 2059 XDrawString (s->display, s->window, s->gc, x,
2061 s->ybase - boff, char1b, s->nchars); 2060 s->ybase - boff, char1b, s->nchars);
2062 } 2061 }
2062 #if 0 /* defined(MAC_OS8)*/
2063 else 2063 else
2064 { 2064 {
2065 if (s->two_byte_p) 2065 if (s->two_byte_p)
2066 XDrawImageString16 (s->display, s->window, s->gc, x, 2066 XDrawImageString16 (s->display, s->window, s->gc, x,
2067 s->ybase - boff, s->char2b, s->nchars); 2067 s->ybase - boff, s->char2b, s->nchars);
2068 else 2068 else
2069 XDrawImageString (s->display, s->window, s->gc, x, 2069 XDrawImageString (s->display, s->window, s->gc, x,
2070 s->ybase - boff, char1b, s->nchars); 2070 s->ybase - boff, char1b, s->nchars);
2071 } 2071 }
2072 #endif
2072 } 2073 }
2073 } 2074 }
2074 2075
2075 /* Draw the foreground of composite glyph string S. */ 2076 /* Draw the foreground of composite glyph string S. */
2076 2077
2633 if (s->slice.y == 0) 2634 if (s->slice.y == 0)
2634 y += s->img->vmargin; 2635 y += s->img->vmargin;
2635 2636
2636 if (s->img->pixmap) 2637 if (s->img->pixmap)
2637 { 2638 {
2639 x_set_glyph_string_clipping (s);
2640
2638 if (s->img->mask) 2641 if (s->img->mask)
2639 { 2642 mac_copy_area_with_mask (s->display, s->img->pixmap, s->img->mask,
2640 Rect nr; 2643 s->window, s->gc, s->slice.x, s->slice.y,
2641 XRectangle clip_rect, image_rect, r; 2644 s->slice.width, s->slice.height, x, y);
2642
2643 get_glyph_string_clip_rect (s, &nr);
2644 CONVERT_TO_XRECT (clip_rect, nr);
2645 image_rect.x = x;
2646 image_rect.y = y;
2647 image_rect.width = s->slice.width;
2648 image_rect.height = s->slice.height;
2649 if (x_intersect_rectangles (&clip_rect, &image_rect, &r))
2650 mac_copy_area_with_mask (s->display, s->img->pixmap, s->img->mask,
2651 s->window, s->gc,
2652 s->slice.x + r.x - x, s->slice.y + r.y - y,
2653 r.width, r.height, r.x, r.y);
2654 }
2655 else 2645 else
2656 { 2646 {
2657 Rect nr; 2647 mac_copy_area (s->display, s->img->pixmap,
2658 XRectangle clip_rect, image_rect, r; 2648 s->window, s->gc, s->slice.x, s->slice.y,
2659 2649 s->slice.width, s->slice.height, x, y);
2660 get_glyph_string_clip_rect (s, &nr);
2661 CONVERT_TO_XRECT (clip_rect, nr);
2662 image_rect.x = x;
2663 image_rect.y = y;
2664 image_rect.width = s->slice.width;
2665 image_rect.height = s->slice.height;
2666 if (x_intersect_rectangles (&clip_rect, &image_rect, &r))
2667 mac_copy_area (s->display, s->img->pixmap, s->window, s->gc,
2668 s->slice.x + r.x - x, s->slice.y + r.y - y,
2669 r.width, r.height, r.x, r.y);
2670 2650
2671 /* When the image has a mask, we can expect that at 2651 /* When the image has a mask, we can expect that at
2672 least part of a mouse highlight or a block cursor will 2652 least part of a mouse highlight or a block cursor will
2673 be visible. If the image doesn't have a mask, make 2653 be visible. If the image doesn't have a mask, make
2674 a block cursor visible by drawing a rectangle around 2654 a block cursor visible by drawing a rectangle around
2743 s->slice.x + s->slice.width == s->img->width, 2723 s->slice.x + s->slice.width == s->img->width,
2744 &r); 2724 &r);
2745 } 2725 }
2746 2726
2747 2727
2728 #if 0 /* TODO: figure out if we need to do this on Mac. */
2748 /* Draw the foreground of image glyph string S to PIXMAP. */ 2729 /* Draw the foreground of image glyph string S to PIXMAP. */
2749 2730
2750 static void 2731 static void
2751 x_draw_image_foreground_1 (s, pixmap) 2732 x_draw_image_foreground_1 (s, pixmap)
2752 struct glyph_string *s; 2733 struct glyph_string *s;
2803 else 2784 else
2804 /* Draw a rectangle if image could not be loaded. */ 2785 /* Draw a rectangle if image could not be loaded. */
2805 mac_draw_rectangle_to_pixmap (s->display, pixmap, s->gc, x, y, 2786 mac_draw_rectangle_to_pixmap (s->display, pixmap, s->gc, x, y,
2806 s->slice.width - 1, s->slice.height - 1); 2787 s->slice.width - 1, s->slice.height - 1);
2807 } 2788 }
2789 #endif
2808 2790
2809 2791
2810 /* Draw part of the background of glyph string S. X, Y, W, and H 2792 /* Draw part of the background of glyph string S. X, Y, W, and H
2811 give the rectangle to draw. */ 2793 give the rectangle to draw. */
2812 2794
2874 2856
2875 y = s->y; 2857 y = s->y;
2876 if (s->slice.y == 0) 2858 if (s->slice.y == 0)
2877 y += box_line_vwidth; 2859 y += box_line_vwidth;
2878 2860
2861 #if 0 /* TODO: figure out if we need to do this on Mac. */
2879 if (s->img->mask) 2862 if (s->img->mask)
2880 { 2863 {
2881 /* Create a pixmap as large as the glyph string. Fill it 2864 /* Create a pixmap as large as the glyph string. Fill it
2882 with the background color. Copy the image to it, using 2865 with the background color. Copy the image to it, using
2883 its mask. Copy the temporary pixmap to the display. */ 2866 its mask. Copy the temporary pixmap to the display. */
2910 s->height); 2893 s->height);
2911 XSetForeground (s->display, s->gc, xgcv.foreground); 2894 XSetForeground (s->display, s->gc, xgcv.foreground);
2912 } 2895 }
2913 } 2896 }
2914 else 2897 else
2898 #endif
2915 x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height); 2899 x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);
2916 2900
2917 s->background_filled_p = 1; 2901 s->background_filled_p = 1;
2918 } 2902 }
2919 2903
2920 /* Draw the foreground. */ 2904 /* Draw the foreground. */
2905 #if 0 /* TODO: figure out if we need to do this on Mac. */
2921 if (pixmap != 0) 2906 if (pixmap != 0)
2922 { 2907 {
2923 x_draw_image_foreground_1 (s, pixmap); 2908 x_draw_image_foreground_1 (s, pixmap);
2924 x_set_glyph_string_clipping (s); 2909 x_set_glyph_string_clipping (s);
2925 mac_copy_area (s->display, pixmap, s->window, s->gc, 2910 mac_copy_area (s->display, pixmap, s->window, s->gc,
2926 0, 0, s->background_width, s->height, s->x, s->y); 2911 0, 0, s->background_width, s->height, s->x, s->y);
2927 mac_reset_clipping (s->display, s->window); 2912 mac_reset_clipping (s->display, s->window);
2928 XFreePixmap (s->display, pixmap); 2913 XFreePixmap (s->display, pixmap);
2929 } 2914 }
2930 else 2915 else
2916 #endif
2931 x_draw_image_foreground (s); 2917 x_draw_image_foreground (s);
2932 2918
2933 /* If we must draw a relief around the image, do it. */ 2919 /* If we must draw a relief around the image, do it. */
2934 if (s->img->relief 2920 if (s->img->relief
2935 || s->hl == DRAW_IMAGE_RAISED 2921 || s->hl == DRAW_IMAGE_RAISED
5897 #endif 5883 #endif
5898 5884
5899 static Lisp_Object Qbig5, Qcn_gb, Qsjis, Qeuc_kr; 5885 static Lisp_Object Qbig5, Qcn_gb, Qsjis, Qeuc_kr;
5900 5886
5901 static void 5887 static void
5902 decode_mac_font_name (char *name, int size, short scriptcode) 5888 decode_mac_font_name (name, size, scriptcode)
5889 char *name;
5890 int size;
5891 #if TARGET_API_MAC_CARBON
5892 int scriptcode;
5893 #else
5894 short scriptcode;
5895 #endif
5903 { 5896 {
5904 Lisp_Object coding_system; 5897 Lisp_Object coding_system;
5905 struct coding_system coding; 5898 struct coding_system coding;
5906 char *buf; 5899 char *buf;
5907 5900
5935 name[coding.produced] = '\0'; 5928 name[coding.produced] = '\0';
5936 } 5929 }
5937 5930
5938 5931
5939 static char * 5932 static char *
5940 mac_to_x_fontname (char *name, int size, Style style, short scriptcode) 5933 mac_to_x_fontname (name, size, style, scriptcode, encoding_base)
5934 char *name;
5935 int size;
5936 Style style;
5937 #if TARGET_API_MAC_CARBON
5938 int scriptcode;
5939 #else
5940 short scriptcode;
5941 #endif
5941 { 5942 {
5942 char foundry[32], family[32], cs[32]; 5943 char foundry[32], family[32], cs[32];
5943 char xf[256], *result, *p; 5944 char xf[256], *result, *p;
5944 5945
5945 if (sscanf (name, "%31[^-]-%31[^-]-%31s", foundry, family, cs) != 3) 5946 if (sscanf (name, "%31[^-]-%31[^-]-%31s", foundry, family, cs) != 3)
5947 strcpy(foundry, "Apple"); 5948 strcpy(foundry, "Apple");
5948 strcpy(family, name); 5949 strcpy(family, name);
5949 5950
5950 switch (scriptcode) 5951 switch (scriptcode)
5951 { 5952 {
5952 case smTradChinese: 5953 case smTradChinese: /* == kTextEncodingMacChineseTrad */
5953 strcpy(cs, "big5-0"); 5954 strcpy(cs, "big5-0");
5954 break; 5955 break;
5955 case smSimpChinese: 5956 case smSimpChinese: /* == kTextEncodingMacChineseSimp */
5956 strcpy(cs, "gb2312.1980-0"); 5957 strcpy(cs, "gb2312.1980-0");
5957 break; 5958 break;
5958 case smJapanese: 5959 case smJapanese: /* == kTextEncodingMacJapanese */
5959 strcpy(cs, "jisx0208.1983-sjis"); 5960 strcpy(cs, "jisx0208.1983-sjis");
5960 break; 5961 break;
5961 case -smJapanese: 5962 case -smJapanese:
5962 /* Each Apple Japanese font is entered into the font table 5963 /* Each Apple Japanese font is entered into the font table
5963 twice: once as a jisx0208.1983-sjis font and once as a 5964 twice: once as a jisx0208.1983-sjis font and once as a
5965 the ascii charset and katakana-jisx0201 charset. A 5966 the ascii charset and katakana-jisx0201 charset. A
5966 negative script code signals that the name of this latter 5967 negative script code signals that the name of this latter
5967 font is being built. */ 5968 font is being built. */
5968 strcpy(cs, "jisx0201.1976-0"); 5969 strcpy(cs, "jisx0201.1976-0");
5969 break; 5970 break;
5970 case smKorean: 5971 case smKorean: /* == kTextEncodingMacKorean */
5971 strcpy(cs, "ksc5601.1989-0"); 5972 strcpy(cs, "ksc5601.1989-0");
5972 break; 5973 break;
5974 #if TARGET_API_MAC_CARBON
5975 case kTextEncodingMacCyrillic:
5976 strcpy(cs, "mac-cyrillic");
5977 break;
5978 case kTextEncodingMacCentralEurRoman:
5979 strcpy(cs, "mac-centraleuropean");
5980 break;
5981 case kTextEncodingMacSymbol:
5982 case kTextEncodingMacDingbats:
5983 strcpy(cs, "adobe-fontspecific");
5984 break;
5985 #endif
5973 default: 5986 default:
5974 strcpy(cs, "mac-roman"); 5987 strcpy(cs, "mac-roman");
5975 break; 5988 break;
5976 } 5989 }
5977 } 5990 }
5978 5991
5979 sprintf(xf, "-%s-%s-%s-%c-normal--%d-%d-75-75-m-%d-%s", 5992 sprintf(xf, "-%s-%s-%s-%c-normal--%d-%d-75-75-m-%d-%s",
5980 foundry, family, style & bold ? "bold" : "medium", 5993 foundry, family, style & bold ? "bold" : "medium",
6017 else if (strcmp (cs, "jisx0208.1983-sjis") == 0 6030 else if (strcmp (cs, "jisx0208.1983-sjis") == 0
6018 || strcmp (cs, "jisx0201.1976-0") == 0) 6031 || strcmp (cs, "jisx0201.1976-0") == 0)
6019 coding_system = Qsjis; 6032 coding_system = Qsjis;
6020 else if (strcmp (cs, "ksc5601.1989-0") == 0) 6033 else if (strcmp (cs, "ksc5601.1989-0") == 0)
6021 coding_system = Qeuc_kr; 6034 coding_system = Qeuc_kr;
6022 else if (strcmp (cs, "mac-roman") == 0) 6035 else if (strcmp (cs, "mac-roman") == 0
6036 || strcmp (cs, "mac-cyrillic") == 0
6037 || strcmp (cs, "mac-centraleuropean") == 0
6038 || strcmp (cs, "adobe-fontspecific") == 0)
6023 strcpy (mf, family); 6039 strcpy (mf, family);
6024 else 6040 else
6025 sprintf (mf, "%s-%s-%s", foundry, family, cs); 6041 sprintf (mf, "%s-%s-%s", foundry, family, cs);
6026 6042
6027 if (!NILP (coding_system)) 6043 if (!NILP (coding_system))
6089 { 6105 {
6090 Str255 name; 6106 Str255 name;
6091 FMFont font; 6107 FMFont font;
6092 FMFontStyle style; 6108 FMFontStyle style;
6093 FMFontSize size; 6109 FMFontSize size;
6094 SInt16 sc; 6110 TextEncoding encoding;
6111 TextEncodingBase sc;
6095 6112
6096 if (FMGetFontFamilyName (ff, name) != noErr) 6113 if (FMGetFontFamilyName (ff, name) != noErr)
6097 break; 6114 break;
6098 p2cstr (name); 6115 p2cstr (name);
6099 if (*name == '.') 6116 if (*name == '.')
6100 continue; 6117 continue;
6101 6118
6102 sc = FontToScript (ff); 6119 if (FMGetFontFamilyTextEncoding (ff, &encoding) != noErr)
6120 break;
6121 sc = GetTextEncodingBase (encoding);
6103 decode_mac_font_name (name, sizeof (name), sc); 6122 decode_mac_font_name (name, sizeof (name), sc);
6104 6123
6105 /* Point the instance iterator at the current font family. */ 6124 /* Point the instance iterator at the current font family. */
6106 if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr) 6125 if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr)
6107 break; 6126 break;
6108 6127
6109 while (FMGetNextFontFamilyInstance (&ffii, &font, &style, &size) 6128 while (FMGetNextFontFamilyInstance (&ffii, &font, &style, &size)
8617 8636
8618 if (the_err == noErr) 8637 if (the_err == noErr)
8619 { 8638 {
8620 unsigned char ch = inev.code; 8639 unsigned char ch = inev.code;
8621 ByteCount actual_input_length, actual_output_length; 8640 ByteCount actual_input_length, actual_output_length;
8622 unsigned char outch; 8641 unsigned char outbuf[32];
8623 8642
8624 convert_status = TECConvertText (converter, &ch, 1, 8643 convert_status = TECConvertText (converter, &ch, 1,
8625 &actual_input_length, 8644 &actual_input_length,
8626 &outch, 1, 8645 outbuf, 1,
8627 &actual_output_length); 8646 &actual_output_length);
8628 if (convert_status == noErr 8647 if (convert_status == noErr
8629 && actual_input_length == 1 8648 && actual_input_length == 1
8630 && actual_output_length == 1) 8649 && actual_output_length == 1)
8631 inev.code = outch; 8650 inev.code = *outbuf;
8632 } 8651
8652 /* Reset internal states of the converter object.
8653 If it fails, create another one. */
8654 convert_status = TECFlushText (converter, outbuf,
8655 sizeof (outbuf),
8656 &actual_output_length);
8657 if (convert_status != noErr)
8658 {
8659 TECDisposeConverter (converter);
8660 TECCreateConverter (&converter,
8661 kTextEncodingMacRoman,
8662 mac_keyboard_text_encoding);
8663 }
8664 }
8633 } 8665 }
8634 8666
8635 #if USE_CARBON_EVENTS 8667 #if USE_CARBON_EVENTS
8636 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); 8668 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
8637 #else 8669 #else
9146 x_after_update_window_line, 9178 x_after_update_window_line,
9147 x_update_window_begin, 9179 x_update_window_begin,
9148 x_update_window_end, 9180 x_update_window_end,
9149 x_cursor_to, 9181 x_cursor_to,
9150 x_flush, 9182 x_flush,
9151 x_flush, 9183 0, /* flush_display_optional */
9152 x_clear_window_mouse_face, 9184 x_clear_window_mouse_face,
9153 x_get_glyph_overhangs, 9185 x_get_glyph_overhangs,
9154 x_fix_overlapping_area, 9186 x_fix_overlapping_area,
9155 x_draw_fringe_bitmap, 9187 x_draw_fringe_bitmap,
9156 0, /* define_fringe_bitmap */ 9188 0, /* define_fringe_bitmap */