Index: src/dispextern.h =================================================================== RCS file: /cvsroot/emacs/emacs/src/dispextern.h,v retrieving revision 1.140 diff -u -r1.140 dispextern.h *** src/dispextern.h 25 Oct 2002 06:49:15 -0000 1.140 --- src/dispextern.h 16 Nov 2002 15:10:41 -0000 *************** *** 1359,1364 **** --- 1359,1367 ---- realize_x_face). */ unsigned colors_copied_bitwise_p : 1; + /* If non-zero, use overstrike (to simulate bold-face). */ + unsigned overstrike : 1; + /* Next and previous face in hash collision list of face cache. */ struct face *next, *prev; Index: src/xfaces.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/xfaces.c,v retrieving revision 1.265 diff -u -r1.265 xfaces.c *** src/xfaces.c 23 Oct 2002 16:55:19 -0000 1.265 --- src/xfaces.c 16 Nov 2002 15:14:10 -0000 *************** *** 522,528 **** static int face_numeric_slant P_ ((Lisp_Object)); static int face_numeric_swidth P_ ((Lisp_Object)); static int face_fontset P_ ((Lisp_Object *)); ! static char *choose_face_font P_ ((struct frame *, Lisp_Object *, int, int)); static void merge_face_vectors P_ ((struct frame *, Lisp_Object *, Lisp_Object*, Lisp_Object)); static void merge_face_inheritance P_ ((struct frame *f, Lisp_Object, Lisp_Object *, Lisp_Object)); --- 522,528 ---- static int face_numeric_slant P_ ((Lisp_Object)); static int face_numeric_swidth P_ ((Lisp_Object)); static int face_fontset P_ ((Lisp_Object *)); ! static char *choose_face_font P_ ((struct frame *, Lisp_Object *, int, int, int*)); static void merge_face_vectors P_ ((struct frame *, Lisp_Object *, Lisp_Object*, Lisp_Object)); static void merge_face_inheritance P_ ((struct frame *f, Lisp_Object, Lisp_Object *, Lisp_Object)); *************** *** 534,540 **** static struct face *make_realized_face P_ ((Lisp_Object *)); static void free_realized_faces P_ ((struct face_cache *)); static char *best_matching_font P_ ((struct frame *, Lisp_Object *, ! struct font_name *, int, int)); static void cache_face P_ ((struct face_cache *, struct face *, unsigned)); static void uncache_face P_ ((struct face_cache *, struct face *)); static int xlfd_numeric_slant P_ ((struct font_name *)); --- 534,540 ---- static struct face *make_realized_face P_ ((Lisp_Object *)); static void free_realized_faces P_ ((struct face_cache *)); static char *best_matching_font P_ ((struct frame *, Lisp_Object *, ! struct font_name *, int, int, int *)); static void cache_face P_ ((struct face_cache *, struct face *, unsigned)); static void uncache_face P_ ((struct face_cache *, struct face *)); static int xlfd_numeric_slant P_ ((struct font_name *)); *************** *** 1257,1267 **** { struct font_info *font_info = NULL; char *font_name; face->font_info_id = -1; face->font = NULL; ! font_name = choose_face_font (f, face->lface, face->fontset, c); if (!font_name) return; --- 1257,1269 ---- { struct font_info *font_info = NULL; char *font_name; + int needs_overstrike; face->font_info_id = -1; face->font = NULL; ! font_name = choose_face_font (f, face->lface, face->fontset, c, ! &needs_overstrike); if (!font_name) return; *************** *** 1274,1279 **** --- 1276,1282 ---- face->font_info_id = font_info->font_idx; face->font = font_info->font; face->font_name = font_info->full_name; + face->overstrike = needs_overstrike; if (face->gc) { x_free_gc (f, face->gc); *************** *** 4313,4319 **** /* Choose a font name that reflects LFACE's attributes and has the registry and encoding pattern specified in the default fontset (3rd arg: -1) for ASCII characters (4th arg: 0). */ ! font = choose_face_font (f, XVECTOR (lface)->contents, -1, 0); if (!font) error ("No font matches the specified attribute"); font_name = build_string (font); --- 4316,4322 ---- /* Choose a font name that reflects LFACE's attributes and has the registry and encoding pattern specified in the default fontset (3rd arg: -1) for ASCII characters (4th arg: 0). */ ! font = choose_face_font (f, XVECTOR (lface)->contents, -1, 0, 0); if (!font) error ("No font matches the specified attribute"); font_name = build_string (font); *************** *** 6140,6154 **** widths if ATTRS specifies such a width. Value is a font name which is allocated from the heap. FONTS is ! freed by this function. */ static char * ! best_matching_font (f, attrs, fonts, nfonts, width_ratio) struct frame *f; Lisp_Object *attrs; struct font_name *fonts; int nfonts; int width_ratio; { char *font_name; struct font_name *best; --- 6143,6162 ---- widths if ATTRS specifies such a width. Value is a font name which is allocated from the heap. FONTS is ! freed by this function. ! ! If NEEDS_OVERSTRIKE is non-zero, a boolean is returned in it to ! indicate whether the resulting font should be drawn using overstrike ! to simulate bold-face. */ static char * ! best_matching_font (f, attrs, fonts, nfonts, width_ratio, needs_overstrike) struct frame *f; Lisp_Object *attrs; struct font_name *fonts; int nfonts; int width_ratio; + int *needs_overstrike; { char *font_name; struct font_name *best; *************** *** 6183,6188 **** --- 6191,6199 ---- exact_p = 0; + if (needs_overstrike) + *needs_overstrike = 0; + /* Start with the first non-scalable font in the list. */ for (i = 0; i < nfonts; ++i) if (!font_scalable_p (fonts + i)) *************** *** 6203,6209 **** if (exact_p) break; } - } else best = NULL; --- 6214,6219 ---- *************** *** 6236,6241 **** --- 6246,6269 ---- && !better_font_p (specified, best, fonts + i, 0, 0))) best = fonts + i; } + + if (needs_overstrike) + { + enum xlfd_weight want_weight = specified[XLFD_WEIGHT]; + enum xlfd_weight got_weight = best->numeric[XLFD_WEIGHT]; + + if (want_weight > XLFD_WEIGHT_MEDIUM && want_weight > got_weight) + { + /* We want a bold font, but didn't get one; try to use + overstriking instead to simulate bold-face. However, + don't overstrike an already-bold fontn unless the + desired weight grossly exceeds the available weight. */ + if (got_weight > XLFD_WEIGHT_MEDIUM) + *needs_overstrike = (got_weight - want_weight) > 2; + else + *needs_overstrike = 1; + } + } } if (font_scalable_p (best)) *************** *** 6393,6405 **** allocated from the heap and must be freed by the caller, or NULL if we can get no information about the font name of C. It is assured that we always get some information for a single byte ! character. */ static char * ! choose_face_font (f, attrs, fontset, c) struct frame *f; Lisp_Object *attrs; int fontset, c; { Lisp_Object pattern; char *font_name = NULL; --- 6421,6438 ---- allocated from the heap and must be freed by the caller, or NULL if we can get no information about the font name of C. It is assured that we always get some information for a single byte ! character. ! ! If NEEDS_OVERSTRIKE is non-zero, a boolean is returned in it to ! indicate whether the resulting font should be drawn using overstrike ! to simulate bold-face. */ static char * ! choose_face_font (f, attrs, fontset, c, needs_overstrike) struct frame *f; Lisp_Object *attrs; int fontset, c; + int *needs_overstrike; { Lisp_Object pattern; char *font_name = NULL; *************** *** 6427,6433 **** width_ratio = (SINGLE_BYTE_CHAR_P (c) ? 1 : CHARSET_WIDTH (CHAR_CHARSET (c))); ! font_name = best_matching_font (f, attrs, fonts, nfonts, width_ratio); return font_name; } --- 6460,6467 ---- width_ratio = (SINGLE_BYTE_CHAR_P (c) ? 1 : CHARSET_WIDTH (CHAR_CHARSET (c))); ! font_name = best_matching_font (f, attrs, fonts, nfonts, width_ratio, ! needs_overstrike); return font_name; } Index: src/xterm.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/xterm.c,v retrieving revision 1.763 diff -u -r1.763 xterm.c *** src/xterm.c 14 Nov 2002 14:21:34 -0000 1.763 --- src/xterm.c 16 Nov 2002 15:16:53 -0000 *************** *** 3222,3227 **** --- 3222,3239 ---- XDrawImageString (s->display, s->window, s->gc, x, s->ybase - boff, char1b, s->nchars); } + + if (s->face->overstrike) + { + /* For overstriking (to simulate bold-face), draw the + characters again shifted to the right by one pixel. */ + if (s->two_byte_p) + XDrawString16 (s->display, s->window, s->gc, x + 1, + s->ybase - boff, s->char2b, s->nchars); + else + XDrawString (s->display, s->window, s->gc, x + 1, + s->ybase - boff, char1b, s->nchars); + } } } *************** *** 3257,3266 **** else { for (i = 0; i < s->nchars; i++, ++s->gidx) ! XDrawString16 (s->display, s->window, s->gc, ! x + s->cmp->offsets[s->gidx * 2], ! s->ybase - s->cmp->offsets[s->gidx * 2 + 1], ! s->char2b + i, 1); } } --- 3269,3285 ---- else { for (i = 0; i < s->nchars; i++, ++s->gidx) ! { ! XDrawString16 (s->display, s->window, s->gc, ! x + s->cmp->offsets[s->gidx * 2], ! s->ybase - s->cmp->offsets[s->gidx * 2 + 1], ! s->char2b + i, 1); ! if (s->face->overstrike) ! XDrawString16 (s->display, s->window, s->gc, ! x + s->cmp->offsets[s->gidx * 2] + 1, ! s->ybase - s->cmp->offsets[s->gidx * 2 + 1], ! s->char2b + i, 1); ! } } }