diff options
Diffstat (limited to 'src/macterm.c')
| -rw-r--r-- | src/macterm.c | 134 |
1 files changed, 61 insertions, 73 deletions
diff --git a/src/macterm.c b/src/macterm.c index 719b703a77c..126fe513533 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -893,12 +893,13 @@ mac_invert_rectangle (f, x, y, width, height) | |||
| 893 | 893 | ||
| 894 | 894 | ||
| 895 | static void | 895 | static void |
| 896 | mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char) | 896 | mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, |
| 897 | overstrike_p, bytes_per_char) | ||
| 897 | struct frame *f; | 898 | struct frame *f; |
| 898 | GC gc; | 899 | GC gc; |
| 899 | int x, y; | 900 | int x, y; |
| 900 | char *buf; | 901 | char *buf; |
| 901 | int nchars, bg_width, bytes_per_char; | 902 | int nchars, bg_width, overstrike_p, bytes_per_char; |
| 902 | { | 903 | { |
| 903 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); | 904 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| 904 | 905 | ||
| @@ -948,6 +949,13 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char) | |||
| 948 | ATSUDrawText (text_layout, | 949 | ATSUDrawText (text_layout, |
| 949 | kATSUFromTextBeginning, kATSUToTextEnd, | 950 | kATSUFromTextBeginning, kATSUToTextEnd, |
| 950 | kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc); | 951 | kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc); |
| 952 | if (overstrike_p) | ||
| 953 | { | ||
| 954 | MoveTo (x + 1, y); | ||
| 955 | ATSUDrawText (text_layout, | ||
| 956 | kATSUFromTextBeginning, kATSUToTextEnd, | ||
| 957 | kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc); | ||
| 958 | } | ||
| 951 | mac_end_clip (gc); | 959 | mac_end_clip (gc); |
| 952 | #ifdef MAC_OSX | 960 | #ifdef MAC_OSX |
| 953 | } | 961 | } |
| @@ -991,9 +999,15 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char) | |||
| 991 | sizeof (tags) / sizeof (tags[0]), | 999 | sizeof (tags) / sizeof (tags[0]), |
| 992 | tags, sizes, values); | 1000 | tags, sizes, values); |
| 993 | if (err == noErr) | 1001 | if (err == noErr) |
| 994 | ATSUDrawText (text_layout, | 1002 | { |
| 995 | kATSUFromTextBeginning, kATSUToTextEnd, | 1003 | ATSUDrawText (text_layout, |
| 996 | Long2Fix (x), Long2Fix (port_height - y)); | 1004 | kATSUFromTextBeginning, kATSUToTextEnd, |
| 1005 | Long2Fix (x), Long2Fix (port_height - y)); | ||
| 1006 | if (overstrike_p) | ||
| 1007 | ATSUDrawText (text_layout, | ||
| 1008 | kATSUFromTextBeginning, kATSUToTextEnd, | ||
| 1009 | Long2Fix (x + 1), Long2Fix (port_height - y)); | ||
| 1010 | } | ||
| 997 | #if USE_CG_DRAWING | 1011 | #if USE_CG_DRAWING |
| 998 | mac_end_cg_clip (f); | 1012 | mac_end_cg_clip (f); |
| 999 | context = NULL; | 1013 | context = NULL; |
| @@ -1059,6 +1073,12 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char) | |||
| 1059 | TextFace (GC_FONT (gc)->mac_fontface); | 1073 | TextFace (GC_FONT (gc)->mac_fontface); |
| 1060 | MoveTo (x, y); | 1074 | MoveTo (x, y); |
| 1061 | DrawText (buf, 0, nchars * bytes_per_char); | 1075 | DrawText (buf, 0, nchars * bytes_per_char); |
| 1076 | if (overstrike_p) | ||
| 1077 | { | ||
| 1078 | TextMode (srcOr); | ||
| 1079 | MoveTo (x + 1, y); | ||
| 1080 | DrawText (buf, 0, nchars * bytes_per_char); | ||
| 1081 | } | ||
| 1062 | if (bg_width) | 1082 | if (bg_width) |
| 1063 | RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f))); | 1083 | RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f))); |
| 1064 | mac_end_clip (gc); | 1084 | mac_end_clip (gc); |
| @@ -1071,59 +1091,33 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char) | |||
| 1071 | } | 1091 | } |
| 1072 | 1092 | ||
| 1073 | 1093 | ||
| 1074 | /* Mac replacement for XDrawString. */ | ||
| 1075 | |||
| 1076 | static void | ||
| 1077 | mac_draw_string (f, gc, x, y, buf, nchars) | ||
| 1078 | struct frame *f; | ||
| 1079 | GC gc; | ||
| 1080 | int x, y; | ||
| 1081 | char *buf; | ||
| 1082 | int nchars; | ||
| 1083 | { | ||
| 1084 | mac_draw_string_common (f, gc, x, y, buf, nchars, 0, 1); | ||
| 1085 | } | ||
| 1086 | |||
| 1087 | |||
| 1088 | /* Mac replacement for XDrawString16. */ | ||
| 1089 | |||
| 1090 | static void | ||
| 1091 | mac_draw_string_16 (f, gc, x, y, buf, nchars) | ||
| 1092 | struct frame *f; | ||
| 1093 | GC gc; | ||
| 1094 | int x, y; | ||
| 1095 | XChar2b *buf; | ||
| 1096 | int nchars; | ||
| 1097 | { | ||
| 1098 | mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, 0, 2); | ||
| 1099 | } | ||
| 1100 | |||
| 1101 | |||
| 1102 | /* Mac replacement for XDrawImageString. */ | 1094 | /* Mac replacement for XDrawImageString. */ |
| 1103 | 1095 | ||
| 1104 | static void | 1096 | static void |
| 1105 | mac_draw_image_string (f, gc, x, y, buf, nchars, bg_width) | 1097 | mac_draw_image_string (f, gc, x, y, buf, nchars, bg_width, overstrike_p) |
| 1106 | struct frame *f; | 1098 | struct frame *f; |
| 1107 | GC gc; | 1099 | GC gc; |
| 1108 | int x, y; | 1100 | int x, y; |
| 1109 | char *buf; | 1101 | char *buf; |
| 1110 | int nchars, bg_width; | 1102 | int nchars, bg_width, overstrike_p; |
| 1111 | { | 1103 | { |
| 1112 | mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, 1); | 1104 | mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, |
| 1105 | overstrike_p, 1); | ||
| 1113 | } | 1106 | } |
| 1114 | 1107 | ||
| 1115 | 1108 | ||
| 1116 | /* Mac replacement for XDrawString16. */ | 1109 | /* Mac replacement for XDrawImageString16. */ |
| 1117 | 1110 | ||
| 1118 | static void | 1111 | static void |
| 1119 | mac_draw_image_string_16 (f, gc, x, y, buf, nchars, bg_width) | 1112 | mac_draw_image_string_16 (f, gc, x, y, buf, nchars, bg_width, overstrike_p) |
| 1120 | struct frame *f; | 1113 | struct frame *f; |
| 1121 | GC gc; | 1114 | GC gc; |
| 1122 | int x, y; | 1115 | int x, y; |
| 1123 | XChar2b *buf; | 1116 | XChar2b *buf; |
| 1124 | int nchars, bg_width; | 1117 | int nchars, bg_width, overstrike_p; |
| 1125 | { | 1118 | { |
| 1126 | mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, bg_width, 2); | 1119 | mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, bg_width, |
| 1120 | overstrike_p, 2); | ||
| 1127 | } | 1121 | } |
| 1128 | 1122 | ||
| 1129 | 1123 | ||
| @@ -1297,12 +1291,12 @@ init_cg_text_anti_aliasing_threshold () | |||
| 1297 | } | 1291 | } |
| 1298 | 1292 | ||
| 1299 | static int | 1293 | static int |
| 1300 | mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width) | 1294 | mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width, overstrike_p) |
| 1301 | struct frame *f; | 1295 | struct frame *f; |
| 1302 | GC gc; | 1296 | GC gc; |
| 1303 | int x, y; | 1297 | int x, y; |
| 1304 | XChar2b *buf; | 1298 | XChar2b *buf; |
| 1305 | int nchars, bg_width; | 1299 | int nchars, bg_width, overstrike_p; |
| 1306 | { | 1300 | { |
| 1307 | CGrafPtr port; | 1301 | CGrafPtr port; |
| 1308 | float port_height, gx, gy; | 1302 | float port_height, gx, gy; |
| @@ -1364,10 +1358,17 @@ mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width) | |||
| 1364 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 | 1358 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 |
| 1365 | CGContextSetTextPosition (context, gx, gy); | 1359 | CGContextSetTextPosition (context, gx, gy); |
| 1366 | CGContextShowGlyphsWithAdvances (context, glyphs, advances, nchars); | 1360 | CGContextShowGlyphsWithAdvances (context, glyphs, advances, nchars); |
| 1361 | if (overstrike_p) | ||
| 1362 | { | ||
| 1363 | CGContextSetTextPosition (context, gx + 1.0f, gy); | ||
| 1364 | CGContextShowGlyphsWithAdvances (context, glyphs, advances, nchars); | ||
| 1365 | } | ||
| 1367 | #else | 1366 | #else |
| 1368 | for (i = 0; i < nchars; i++) | 1367 | for (i = 0; i < nchars; i++) |
| 1369 | { | 1368 | { |
| 1370 | CGContextShowGlyphsAtPoint (context, gx, gy, glyphs + i, 1); | 1369 | CGContextShowGlyphsAtPoint (context, gx, gy, glyphs + i, 1); |
| 1370 | if (overstrike_p) | ||
| 1371 | CGContextShowGlyphsAtPoint (context, gx + 1.0f, gy, glyphs + i, 1); | ||
| 1371 | gx += advances[i].width; | 1372 | gx += advances[i].width; |
| 1372 | } | 1373 | } |
| 1373 | #endif | 1374 | #endif |
| @@ -2773,15 +2774,18 @@ x_draw_glyph_string_foreground (s) | |||
| 2773 | #if USE_CG_TEXT_DRAWING | 2774 | #if USE_CG_TEXT_DRAWING |
| 2774 | if (!s->two_byte_p | 2775 | if (!s->two_byte_p |
| 2775 | && mac_draw_image_string_cg (s->f, s->gc, x, s->ybase - boff, | 2776 | && mac_draw_image_string_cg (s->f, s->gc, x, s->ybase - boff, |
| 2776 | s->char2b, s->nchars, bg_width)) | 2777 | s->char2b, s->nchars, bg_width, |
| 2778 | s->face->overstrike)) | ||
| 2777 | ; | 2779 | ; |
| 2778 | else | 2780 | else |
| 2779 | #endif | 2781 | #endif |
| 2780 | mac_draw_image_string_16 (s->f, s->gc, x, s->ybase - boff, | 2782 | mac_draw_image_string_16 (s->f, s->gc, x, s->ybase - boff, |
| 2781 | s->char2b, s->nchars, bg_width); | 2783 | s->char2b, s->nchars, bg_width, |
| 2784 | s->face->overstrike); | ||
| 2782 | else | 2785 | else |
| 2783 | mac_draw_image_string (s->f, s->gc, x, s->ybase - boff, | 2786 | mac_draw_image_string (s->f, s->gc, x, s->ybase - boff, |
| 2784 | char1b, s->nchars, bg_width); | 2787 | char1b, s->nchars, bg_width, |
| 2788 | s->face->overstrike); | ||
| 2785 | } | 2789 | } |
| 2786 | } | 2790 | } |
| 2787 | 2791 | ||
| @@ -2817,10 +2821,10 @@ x_draw_composite_glyph_string_foreground (s) | |||
| 2817 | else | 2821 | else |
| 2818 | { | 2822 | { |
| 2819 | for (i = 0; i < s->nchars; i++, ++s->gidx) | 2823 | for (i = 0; i < s->nchars; i++, ++s->gidx) |
| 2820 | mac_draw_string_16 (s->f, s->gc, | 2824 | mac_draw_image_string_16 (s->f, s->gc, |
| 2821 | x + s->cmp->offsets[s->gidx * 2], | 2825 | x + s->cmp->offsets[s->gidx * 2], |
| 2822 | s->ybase - s->cmp->offsets[s->gidx * 2 + 1], | 2826 | s->ybase - s->cmp->offsets[s->gidx * 2 + 1], |
| 2823 | s->char2b + i, 1); | 2827 | s->char2b + i, 1, 0, s->face->overstrike); |
| 2824 | } | 2828 | } |
| 2825 | } | 2829 | } |
| 2826 | 2830 | ||
| @@ -7801,14 +7805,16 @@ is_fully_specified_xlfd (char *p) | |||
| 7801 | } | 7805 | } |
| 7802 | 7806 | ||
| 7803 | 7807 | ||
| 7804 | /* XLoadQueryFont creates and returns an internal representation for a | 7808 | /* mac_load_query_font creates and returns an internal representation |
| 7805 | font in a MacFontStruct struct. There is really no concept | 7809 | for a font in a MacFontStruct struct. There is really no concept |
| 7806 | corresponding to "loading" a font on the Mac. But we check its | 7810 | corresponding to "loading" a font on the Mac. But we check its |
| 7807 | existence and find the font number and all other information for it | 7811 | existence and find the font number and all other information for it |
| 7808 | and store them in the returned MacFontStruct. */ | 7812 | and store them in the returned MacFontStruct. */ |
| 7809 | 7813 | ||
| 7810 | static MacFontStruct * | 7814 | static MacFontStruct * |
| 7811 | XLoadQueryFont (Display *dpy, char *fontname) | 7815 | mac_load_query_font (f, fontname) |
| 7816 | struct frame *f; | ||
| 7817 | char *fontname; | ||
| 7812 | { | 7818 | { |
| 7813 | int size; | 7819 | int size; |
| 7814 | char *name; | 7820 | char *name; |
| @@ -8019,26 +8025,13 @@ XLoadQueryFont (Display *dpy, char *fontname) | |||
| 8019 | else | 8025 | else |
| 8020 | #endif | 8026 | #endif |
| 8021 | { | 8027 | { |
| 8022 | GrafPtr port; | ||
| 8023 | SInt16 old_fontnum, old_fontsize; | ||
| 8024 | Style old_fontface; | ||
| 8025 | FontInfo the_fontinfo; | 8028 | FontInfo the_fontinfo; |
| 8026 | int is_two_byte_font; | 8029 | int is_two_byte_font; |
| 8027 | 8030 | ||
| 8028 | #if USE_CG_DRAWING | 8031 | #if USE_CG_DRAWING |
| 8029 | mac_prepare_for_quickdraw (NULL); | 8032 | mac_prepare_for_quickdraw (f); |
| 8030 | #endif | ||
| 8031 | /* Save the current font number used. */ | ||
| 8032 | GetPort (&port); | ||
| 8033 | #if TARGET_API_MAC_CARBON | ||
| 8034 | old_fontnum = GetPortTextFont (port); | ||
| 8035 | old_fontsize = GetPortTextSize (port); | ||
| 8036 | old_fontface = GetPortTextFace (port); | ||
| 8037 | #else | ||
| 8038 | old_fontnum = port->txFont; | ||
| 8039 | old_fontsize = port->txSize; | ||
| 8040 | old_fontface = port->txFace; | ||
| 8041 | #endif | 8033 | #endif |
| 8034 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); | ||
| 8042 | 8035 | ||
| 8043 | TextFont (fontnum); | 8036 | TextFont (fontnum); |
| 8044 | TextSize (size); | 8037 | TextSize (size); |
| @@ -8120,11 +8113,6 @@ XLoadQueryFont (Display *dpy, char *fontname) | |||
| 8120 | for (c = 0x21, pcm = space_bounds + 1; c <= 0xff; c++, pcm++) | 8113 | for (c = 0x21, pcm = space_bounds + 1; c <= 0xff; c++, pcm++) |
| 8121 | mac_query_char_extents (NULL, c, NULL, NULL, pcm, NULL); | 8114 | mac_query_char_extents (NULL, c, NULL, NULL, pcm, NULL); |
| 8122 | } | 8115 | } |
| 8123 | |||
| 8124 | /* Restore previous font number, size and face. */ | ||
| 8125 | TextFont (old_fontnum); | ||
| 8126 | TextSize (old_fontsize); | ||
| 8127 | TextFace (old_fontface); | ||
| 8128 | } | 8116 | } |
| 8129 | 8117 | ||
| 8130 | if (space_bounds) | 8118 | if (space_bounds) |
| @@ -8264,7 +8252,7 @@ x_load_font (f, fontname, size) | |||
| 8264 | fontname = (char *) SDATA (XCAR (font_names)); | 8252 | fontname = (char *) SDATA (XCAR (font_names)); |
| 8265 | 8253 | ||
| 8266 | BLOCK_INPUT; | 8254 | BLOCK_INPUT; |
| 8267 | font = (MacFontStruct *) XLoadQueryFont (FRAME_MAC_DISPLAY (f), fontname); | 8255 | font = mac_load_query_font (f, fontname); |
| 8268 | UNBLOCK_INPUT; | 8256 | UNBLOCK_INPUT; |
| 8269 | if (!font) | 8257 | if (!font) |
| 8270 | return NULL; | 8258 | return NULL; |