diff options
| author | YAMAMOTO Mitsuharu | 2006-10-08 07:48:02 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2006-10-08 07:48:02 +0000 |
| commit | bb420759aca8931a39d9edc64e8d0629fc5c9470 (patch) | |
| tree | ced0befbd76afd0ee4f566665a7a27e004487ec8 /src | |
| parent | 117dde84668f90a0549adb898babd270b633f798 (diff) | |
| download | emacs-bb420759aca8931a39d9edc64e8d0629fc5c9470.tar.gz emacs-bb420759aca8931a39d9edc64e8d0629fc5c9470.zip | |
(mac_draw_image_string, mac_draw_image_string_16): Add
argument OVERSTRIKE_P.
(mac_draw_string_common, mac_draw_image_string_cg): Likewise.
Support overstrike.
(mac_draw_string, mac_draw_string_16): Remove functions.
(x_draw_glyph_string_foreground): Use overstrike when needed.
(x_draw_composite_glyph_string_foreground): Likewise. Use
mac_draw_image_string_16 instead of mac_draw_string_16.
(mac_load_query_font): Rename from XLoadQueryFont. Take argument F
instead of DPY. All uses changed. Don't save/restore font.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 13 | ||||
| -rw-r--r-- | src/macterm.c | 134 |
2 files changed, 74 insertions, 73 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index c20c577615f..91e7fff4347 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2006-10-08 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | ||
| 2 | |||
| 3 | * macterm.c (mac_draw_image_string, mac_draw_image_string_16): Add | ||
| 4 | argument OVERSTRIKE_P. | ||
| 5 | (mac_draw_string_common, mac_draw_image_string_cg): Likewise. | ||
| 6 | Support overstrike. | ||
| 7 | (mac_draw_string, mac_draw_string_16): Remove functions. | ||
| 8 | (x_draw_glyph_string_foreground): Use overstrike when needed. | ||
| 9 | (x_draw_composite_glyph_string_foreground): Likewise. Use | ||
| 10 | mac_draw_image_string_16 instead of mac_draw_string_16. | ||
| 11 | (mac_load_query_font): Rename from XLoadQueryFont. Take argument F | ||
| 12 | instead of DPY. All uses changed. Don't save/restore font. | ||
| 13 | |||
| 1 | 2006-10-07 Ralf Angeli <angeli@caeruleus.net> | 14 | 2006-10-07 Ralf Angeli <angeli@caeruleus.net> |
| 2 | 15 | ||
| 3 | * w32fns.c (w32_createwindow): Honour left and top positions if | 16 | * w32fns.c (w32_createwindow): Honour left and top positions if |
diff --git a/src/macterm.c b/src/macterm.c index 72812d38304..86f4c46c4c6 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -891,12 +891,13 @@ mac_invert_rectangle (f, x, y, width, height) | |||
| 891 | 891 | ||
| 892 | 892 | ||
| 893 | static void | 893 | static void |
| 894 | mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char) | 894 | mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, |
| 895 | overstrike_p, bytes_per_char) | ||
| 895 | struct frame *f; | 896 | struct frame *f; |
| 896 | GC gc; | 897 | GC gc; |
| 897 | int x, y; | 898 | int x, y; |
| 898 | char *buf; | 899 | char *buf; |
| 899 | int nchars, bg_width, bytes_per_char; | 900 | int nchars, bg_width, overstrike_p, bytes_per_char; |
| 900 | { | 901 | { |
| 901 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); | 902 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| 902 | 903 | ||
| @@ -946,6 +947,13 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char) | |||
| 946 | ATSUDrawText (text_layout, | 947 | ATSUDrawText (text_layout, |
| 947 | kATSUFromTextBeginning, kATSUToTextEnd, | 948 | kATSUFromTextBeginning, kATSUToTextEnd, |
| 948 | kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc); | 949 | kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc); |
| 950 | if (overstrike_p) | ||
| 951 | { | ||
| 952 | MoveTo (x + 1, y); | ||
| 953 | ATSUDrawText (text_layout, | ||
| 954 | kATSUFromTextBeginning, kATSUToTextEnd, | ||
| 955 | kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc); | ||
| 956 | } | ||
| 949 | mac_end_clip (gc); | 957 | mac_end_clip (gc); |
| 950 | #ifdef MAC_OSX | 958 | #ifdef MAC_OSX |
| 951 | } | 959 | } |
| @@ -989,9 +997,15 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char) | |||
| 989 | sizeof (tags) / sizeof (tags[0]), | 997 | sizeof (tags) / sizeof (tags[0]), |
| 990 | tags, sizes, values); | 998 | tags, sizes, values); |
| 991 | if (err == noErr) | 999 | if (err == noErr) |
| 992 | ATSUDrawText (text_layout, | 1000 | { |
| 993 | kATSUFromTextBeginning, kATSUToTextEnd, | 1001 | ATSUDrawText (text_layout, |
| 994 | Long2Fix (x), Long2Fix (port_height - y)); | 1002 | kATSUFromTextBeginning, kATSUToTextEnd, |
| 1003 | Long2Fix (x), Long2Fix (port_height - y)); | ||
| 1004 | if (overstrike_p) | ||
| 1005 | ATSUDrawText (text_layout, | ||
| 1006 | kATSUFromTextBeginning, kATSUToTextEnd, | ||
| 1007 | Long2Fix (x + 1), Long2Fix (port_height - y)); | ||
| 1008 | } | ||
| 995 | #if USE_CG_DRAWING | 1009 | #if USE_CG_DRAWING |
| 996 | mac_end_cg_clip (f); | 1010 | mac_end_cg_clip (f); |
| 997 | context = NULL; | 1011 | context = NULL; |
| @@ -1057,6 +1071,12 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char) | |||
| 1057 | TextFace (GC_FONT (gc)->mac_fontface); | 1071 | TextFace (GC_FONT (gc)->mac_fontface); |
| 1058 | MoveTo (x, y); | 1072 | MoveTo (x, y); |
| 1059 | DrawText (buf, 0, nchars * bytes_per_char); | 1073 | DrawText (buf, 0, nchars * bytes_per_char); |
| 1074 | if (overstrike_p) | ||
| 1075 | { | ||
| 1076 | TextMode (srcOr); | ||
| 1077 | MoveTo (x + 1, y); | ||
| 1078 | DrawText (buf, 0, nchars * bytes_per_char); | ||
| 1079 | } | ||
| 1060 | if (bg_width) | 1080 | if (bg_width) |
| 1061 | RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f))); | 1081 | RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f))); |
| 1062 | mac_end_clip (gc); | 1082 | mac_end_clip (gc); |
| @@ -1069,59 +1089,33 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char) | |||
| 1069 | } | 1089 | } |
| 1070 | 1090 | ||
| 1071 | 1091 | ||
| 1072 | /* Mac replacement for XDrawString. */ | ||
| 1073 | |||
| 1074 | static void | ||
| 1075 | mac_draw_string (f, gc, x, y, buf, nchars) | ||
| 1076 | struct frame *f; | ||
| 1077 | GC gc; | ||
| 1078 | int x, y; | ||
| 1079 | char *buf; | ||
| 1080 | int nchars; | ||
| 1081 | { | ||
| 1082 | mac_draw_string_common (f, gc, x, y, buf, nchars, 0, 1); | ||
| 1083 | } | ||
| 1084 | |||
| 1085 | |||
| 1086 | /* Mac replacement for XDrawString16. */ | ||
| 1087 | |||
| 1088 | static void | ||
| 1089 | mac_draw_string_16 (f, gc, x, y, buf, nchars) | ||
| 1090 | struct frame *f; | ||
| 1091 | GC gc; | ||
| 1092 | int x, y; | ||
| 1093 | XChar2b *buf; | ||
| 1094 | int nchars; | ||
| 1095 | { | ||
| 1096 | mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, 0, 2); | ||
| 1097 | } | ||
| 1098 | |||
| 1099 | |||
| 1100 | /* Mac replacement for XDrawImageString. */ | 1092 | /* Mac replacement for XDrawImageString. */ |
| 1101 | 1093 | ||
| 1102 | static void | 1094 | static void |
| 1103 | mac_draw_image_string (f, gc, x, y, buf, nchars, bg_width) | 1095 | mac_draw_image_string (f, gc, x, y, buf, nchars, bg_width, overstrike_p) |
| 1104 | struct frame *f; | 1096 | struct frame *f; |
| 1105 | GC gc; | 1097 | GC gc; |
| 1106 | int x, y; | 1098 | int x, y; |
| 1107 | char *buf; | 1099 | char *buf; |
| 1108 | int nchars, bg_width; | 1100 | int nchars, bg_width, overstrike_p; |
| 1109 | { | 1101 | { |
| 1110 | mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, 1); | 1102 | mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, |
| 1103 | overstrike_p, 1); | ||
| 1111 | } | 1104 | } |
| 1112 | 1105 | ||
| 1113 | 1106 | ||
| 1114 | /* Mac replacement for XDrawString16. */ | 1107 | /* Mac replacement for XDrawImageString16. */ |
| 1115 | 1108 | ||
| 1116 | static void | 1109 | static void |
| 1117 | mac_draw_image_string_16 (f, gc, x, y, buf, nchars, bg_width) | 1110 | mac_draw_image_string_16 (f, gc, x, y, buf, nchars, bg_width, overstrike_p) |
| 1118 | struct frame *f; | 1111 | struct frame *f; |
| 1119 | GC gc; | 1112 | GC gc; |
| 1120 | int x, y; | 1113 | int x, y; |
| 1121 | XChar2b *buf; | 1114 | XChar2b *buf; |
| 1122 | int nchars, bg_width; | 1115 | int nchars, bg_width, overstrike_p; |
| 1123 | { | 1116 | { |
| 1124 | mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, bg_width, 2); | 1117 | mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, bg_width, |
| 1118 | overstrike_p, 2); | ||
| 1125 | } | 1119 | } |
| 1126 | 1120 | ||
| 1127 | 1121 | ||
| @@ -1295,12 +1289,12 @@ init_cg_text_anti_aliasing_threshold () | |||
| 1295 | } | 1289 | } |
| 1296 | 1290 | ||
| 1297 | static int | 1291 | static int |
| 1298 | mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width) | 1292 | mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width, overstrike_p) |
| 1299 | struct frame *f; | 1293 | struct frame *f; |
| 1300 | GC gc; | 1294 | GC gc; |
| 1301 | int x, y; | 1295 | int x, y; |
| 1302 | XChar2b *buf; | 1296 | XChar2b *buf; |
| 1303 | int nchars, bg_width; | 1297 | int nchars, bg_width, overstrike_p; |
| 1304 | { | 1298 | { |
| 1305 | CGrafPtr port; | 1299 | CGrafPtr port; |
| 1306 | float port_height, gx, gy; | 1300 | float port_height, gx, gy; |
| @@ -1362,10 +1356,17 @@ mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width) | |||
| 1362 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 | 1356 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 |
| 1363 | CGContextSetTextPosition (context, gx, gy); | 1357 | CGContextSetTextPosition (context, gx, gy); |
| 1364 | CGContextShowGlyphsWithAdvances (context, glyphs, advances, nchars); | 1358 | CGContextShowGlyphsWithAdvances (context, glyphs, advances, nchars); |
| 1359 | if (overstrike_p) | ||
| 1360 | { | ||
| 1361 | CGContextSetTextPosition (context, gx + 1.0f, gy); | ||
| 1362 | CGContextShowGlyphsWithAdvances (context, glyphs, advances, nchars); | ||
| 1363 | } | ||
| 1365 | #else | 1364 | #else |
| 1366 | for (i = 0; i < nchars; i++) | 1365 | for (i = 0; i < nchars; i++) |
| 1367 | { | 1366 | { |
| 1368 | CGContextShowGlyphsAtPoint (context, gx, gy, glyphs + i, 1); | 1367 | CGContextShowGlyphsAtPoint (context, gx, gy, glyphs + i, 1); |
| 1368 | if (overstrike_p) | ||
| 1369 | CGContextShowGlyphsAtPoint (context, gx + 1.0f, gy, glyphs + i, 1); | ||
| 1369 | gx += advances[i].width; | 1370 | gx += advances[i].width; |
| 1370 | } | 1371 | } |
| 1371 | #endif | 1372 | #endif |
| @@ -2771,15 +2772,18 @@ x_draw_glyph_string_foreground (s) | |||
| 2771 | #if USE_CG_TEXT_DRAWING | 2772 | #if USE_CG_TEXT_DRAWING |
| 2772 | if (!s->two_byte_p | 2773 | if (!s->two_byte_p |
| 2773 | && mac_draw_image_string_cg (s->f, s->gc, x, s->ybase - boff, | 2774 | && mac_draw_image_string_cg (s->f, s->gc, x, s->ybase - boff, |
| 2774 | s->char2b, s->nchars, bg_width)) | 2775 | s->char2b, s->nchars, bg_width, |
| 2776 | s->face->overstrike)) | ||
| 2775 | ; | 2777 | ; |
| 2776 | else | 2778 | else |
| 2777 | #endif | 2779 | #endif |
| 2778 | mac_draw_image_string_16 (s->f, s->gc, x, s->ybase - boff, | 2780 | mac_draw_image_string_16 (s->f, s->gc, x, s->ybase - boff, |
| 2779 | s->char2b, s->nchars, bg_width); | 2781 | s->char2b, s->nchars, bg_width, |
| 2782 | s->face->overstrike); | ||
| 2780 | else | 2783 | else |
| 2781 | mac_draw_image_string (s->f, s->gc, x, s->ybase - boff, | 2784 | mac_draw_image_string (s->f, s->gc, x, s->ybase - boff, |
| 2782 | char1b, s->nchars, bg_width); | 2785 | char1b, s->nchars, bg_width, |
| 2786 | s->face->overstrike); | ||
| 2783 | } | 2787 | } |
| 2784 | } | 2788 | } |
| 2785 | 2789 | ||
| @@ -2815,10 +2819,10 @@ x_draw_composite_glyph_string_foreground (s) | |||
| 2815 | else | 2819 | else |
| 2816 | { | 2820 | { |
| 2817 | for (i = 0; i < s->nchars; i++, ++s->gidx) | 2821 | for (i = 0; i < s->nchars; i++, ++s->gidx) |
| 2818 | mac_draw_string_16 (s->f, s->gc, | 2822 | mac_draw_image_string_16 (s->f, s->gc, |
| 2819 | x + s->cmp->offsets[s->gidx * 2], | 2823 | x + s->cmp->offsets[s->gidx * 2], |
| 2820 | s->ybase - s->cmp->offsets[s->gidx * 2 + 1], | 2824 | s->ybase - s->cmp->offsets[s->gidx * 2 + 1], |
| 2821 | s->char2b + i, 1); | 2825 | s->char2b + i, 1, 0, s->face->overstrike); |
| 2822 | } | 2826 | } |
| 2823 | } | 2827 | } |
| 2824 | 2828 | ||
| @@ -7782,14 +7786,16 @@ is_fully_specified_xlfd (char *p) | |||
| 7782 | } | 7786 | } |
| 7783 | 7787 | ||
| 7784 | 7788 | ||
| 7785 | /* XLoadQueryFont creates and returns an internal representation for a | 7789 | /* mac_load_query_font creates and returns an internal representation |
| 7786 | font in a MacFontStruct struct. There is really no concept | 7790 | for a font in a MacFontStruct struct. There is really no concept |
| 7787 | corresponding to "loading" a font on the Mac. But we check its | 7791 | corresponding to "loading" a font on the Mac. But we check its |
| 7788 | existence and find the font number and all other information for it | 7792 | existence and find the font number and all other information for it |
| 7789 | and store them in the returned MacFontStruct. */ | 7793 | and store them in the returned MacFontStruct. */ |
| 7790 | 7794 | ||
| 7791 | static MacFontStruct * | 7795 | static MacFontStruct * |
| 7792 | XLoadQueryFont (Display *dpy, char *fontname) | 7796 | mac_load_query_font (f, fontname) |
| 7797 | struct frame *f; | ||
| 7798 | char *fontname; | ||
| 7793 | { | 7799 | { |
| 7794 | int size; | 7800 | int size; |
| 7795 | char *name; | 7801 | char *name; |
| @@ -8000,26 +8006,13 @@ XLoadQueryFont (Display *dpy, char *fontname) | |||
| 8000 | else | 8006 | else |
| 8001 | #endif | 8007 | #endif |
| 8002 | { | 8008 | { |
| 8003 | GrafPtr port; | ||
| 8004 | SInt16 old_fontnum, old_fontsize; | ||
| 8005 | Style old_fontface; | ||
| 8006 | FontInfo the_fontinfo; | 8009 | FontInfo the_fontinfo; |
| 8007 | int is_two_byte_font; | 8010 | int is_two_byte_font; |
| 8008 | 8011 | ||
| 8009 | #if USE_CG_DRAWING | 8012 | #if USE_CG_DRAWING |
| 8010 | mac_prepare_for_quickdraw (NULL); | 8013 | mac_prepare_for_quickdraw (f); |
| 8011 | #endif | ||
| 8012 | /* Save the current font number used. */ | ||
| 8013 | GetPort (&port); | ||
| 8014 | #if TARGET_API_MAC_CARBON | ||
| 8015 | old_fontnum = GetPortTextFont (port); | ||
| 8016 | old_fontsize = GetPortTextSize (port); | ||
| 8017 | old_fontface = GetPortTextFace (port); | ||
| 8018 | #else | ||
| 8019 | old_fontnum = port->txFont; | ||
| 8020 | old_fontsize = port->txSize; | ||
| 8021 | old_fontface = port->txFace; | ||
| 8022 | #endif | 8014 | #endif |
| 8015 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); | ||
| 8023 | 8016 | ||
| 8024 | TextFont (fontnum); | 8017 | TextFont (fontnum); |
| 8025 | TextSize (size); | 8018 | TextSize (size); |
| @@ -8101,11 +8094,6 @@ XLoadQueryFont (Display *dpy, char *fontname) | |||
| 8101 | for (c = 0x21, pcm = space_bounds + 1; c <= 0xff; c++, pcm++) | 8094 | for (c = 0x21, pcm = space_bounds + 1; c <= 0xff; c++, pcm++) |
| 8102 | mac_query_char_extents (NULL, c, NULL, NULL, pcm, NULL); | 8095 | mac_query_char_extents (NULL, c, NULL, NULL, pcm, NULL); |
| 8103 | } | 8096 | } |
| 8104 | |||
| 8105 | /* Restore previous font number, size and face. */ | ||
| 8106 | TextFont (old_fontnum); | ||
| 8107 | TextSize (old_fontsize); | ||
| 8108 | TextFace (old_fontface); | ||
| 8109 | } | 8097 | } |
| 8110 | 8098 | ||
| 8111 | if (space_bounds) | 8099 | if (space_bounds) |
| @@ -8245,7 +8233,7 @@ x_load_font (f, fontname, size) | |||
| 8245 | fontname = (char *) SDATA (XCAR (font_names)); | 8233 | fontname = (char *) SDATA (XCAR (font_names)); |
| 8246 | 8234 | ||
| 8247 | BLOCK_INPUT; | 8235 | BLOCK_INPUT; |
| 8248 | font = (MacFontStruct *) XLoadQueryFont (FRAME_MAC_DISPLAY (f), fontname); | 8236 | font = mac_load_query_font (f, fontname); |
| 8249 | UNBLOCK_INPUT; | 8237 | UNBLOCK_INPUT; |
| 8250 | if (!font) | 8238 | if (!font) |
| 8251 | return NULL; | 8239 | return NULL; |