From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier" Newsgroups: gmane.emacs.devel Subject: Re: earn $100 and reduce the Emacs TODO list Date: Tue, 07 May 2002 20:12:18 -0400 Sender: emacs-devel-admin@gnu.org Message-ID: <200205080012.g480CIg08628@rum.cs.yale.edu> References: <1020746269.5138.170.camel@space-ghost> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed ; boundary="==_Exmh_3031885080" X-Trace: main.gmane.org 1020816925 14080 127.0.0.1 (8 May 2002 00:15:25 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 8 May 2002 00:15:25 +0000 (UTC) Cc: emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 175F76-0003ey-00 for ; Wed, 08 May 2002 02:15:24 +0200 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 175FEy-0003m3-00 for ; Wed, 08 May 2002 02:23:32 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 175F6y-000232-00; Tue, 07 May 2002 20:15:16 -0400 Original-Received: from rum.cs.yale.edu ([128.36.229.169]) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 175F46-0001sC-00; Tue, 07 May 2002 20:12:19 -0400 Original-Received: (from monnier@localhost) by rum.cs.yale.edu (8.11.6/8.11.6) id g480CIg08628; Tue, 7 May 2002 20:12:18 -0400 X-Mailer: exmh version 2.4 06/23/2000 with nmh-1.0.4 Original-To: Colin Walters Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.9 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:3691 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:3691 This is a multipart MIME message. --==_Exmh_3031885080 Content-Type: text/plain; charset=us-ascii > One feature I've been wanting to see in Emacs for quite a while is > support for the new XRender extension for XFree86. This would allow us > to have antialiased fonts under X. Given how much time I spend working > in Emacs, this would be a big win, I think. > > I've added it to etc/TODO, but I am so interested in seeing this feature > that I am willing to ask the FSF to give my yearly donation of $100 for > this year to whoever implements this feature. It may not be a large > amount, but hopefully it will help motivate someone to do it. It shouldn't be too difficult from what I understand (but I don't understand much of Xlib programming). For what it's worth I have appended a quick-hack "anti-aliased fonts for XEmacs" patch posted to the XEmacs list a while back. Stefan --==_Exmh_3031885080 Content-Type: application/x-patch ; name="xemacs-aa-render.patch" Content-Description: xemacs-aa-render.patch Content-Disposition: attachment; filename="xemacs-aa-render.patch" Index: ChangeLog =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/ChangeLog,v retrieving revision 1.155.2.222 diff -u -r1.155.2.222 ChangeLog --- ChangeLog 2000/12/11 22:05:01 1.155.2.222 +++ ChangeLog 2000/12/17 20:08:30 @@ -1,3 +1,7 @@ +2000-12-17 Vladimir Vukicevic + + * configure.in: add with-xrender option to enable usage of Xft/Xrender + 2000-12-11 Andy Piper * configure.in (XE_COMPUTE_RUNPATH): add netinstall as a subdirectory. Index: configure.in =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/configure.in,v retrieving revision 1.111.2.134 diff -u -r1.111.2.134 configure.in --- configure.in 2000/12/11 21:59:32 1.111.2.134 +++ configure.in 2000/12/17 20:09:15 @@ -511,6 +511,7 @@ with_hesiod | \ with_dnet | \ with_infodock | \ + with_xrender | \ external_widget | \ verbose | \ extra_verbose | \ @@ -2685,7 +2686,7 @@ fi libs_x="-lX11" test "$extra_verbose" = "yes" && echo " Setting libs_x to \"-lX11\"" - +p dnl Autodetect -lXext AC_CHECK_LIB(Xext, XShapeSelectInput, XE_PREPEND(-lXext, libs_x)) @@ -2753,6 +2754,19 @@ fi fi + dnl include xrender/ttf support? + + if test "$with_xrender" = "yes"; then + AC_CHECK_LIB(Xrender, XRenderQueryExtension, XE_PREPEND(-lXrender, libs_x), + [USAGE_ERROR(["Unable to find libXrender for --with-xrender"])]) + AC_CHECK_LIB(freetype, FT_Open_Face, XE_APPEND(-lfreetype, libs_x), + [USAGE_ERROR(["Unable to find libfreetype >= 2.0 for --with-xrender"])]) + AC_CHECK_LIB(Xft, XftFontOpen, XE_PREPEND(-lXft, libs_x), + [USAGE_ERROR(["Unable to find libXft for --with-xrender"])]) + AC_DEFINE(XRENDERFONT) + fi + + fi dnl $with_x11 = yes if test "$with_msw" != "no"; then @@ -4627,6 +4641,9 @@ fi if test "$with_xmu" != yes; then echo " - Xmu library not available; substituting equivalent routines." + fi + if test "$with_xrender" != no; then + echo " - Using Xft and Xrender for antialiased font rendering." fi if test "$with_wmcommand" != no; then echo " - Handling WM_COMMAND properly." Index: lwlib/ChangeLog =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/lwlib/ChangeLog,v retrieving revision 1.1.2.104 diff -u -r1.1.2.104 ChangeLog --- ChangeLog 2000/12/05 06:37:29 1.1.2.104 +++ ChangeLog 2000/12/17 20:09:22 @@ -1,3 +1,8 @@ +2000-12-17 Vladimir Vukicevic + + * xlwtabs.c (TabsAllocFgGC, TabsAllocGreyGC): don't segv + if the font is NULL for whatever reason + 2000-12-05 Martin Buchholz * XEmacs 21.2.38 is released. Index: lwlib/xlwtabs.c =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/lwlib/Attic/xlwtabs.c,v retrieving revision 1.1.2.29 diff -u -r1.1.2.29 xlwtabs.c --- xlwtabs.c 2000/11/24 21:53:38 1.1.2.29 +++ xlwtabs.c 2000/12/17 20:09:30 @@ -2071,7 +2071,10 @@ XGCValues values ; values.background = tw->core.background_pixel ; - values.font = tw->tabs.font->fid ; + if (tw->tabs.font) + values.font = tw->tabs.font->fid ; + else + values.font = 0; values.line_style = LineOnOffDash ; values.line_style = LineSolid ; @@ -2090,7 +2093,10 @@ XGCValues values ; values.background = tw->core.background_pixel ; - values.font = tw->tabs.font->fid ; + if (tw->tabs.font) + values.font = tw->tabs.font->fid ; + else + values.font = 0; #ifdef HAVE_XMU if( tw->tabs.be_nice_to_cmap || w->core.depth == 1) { Index: src/ChangeLog =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/ChangeLog,v retrieving revision 1.154.2.787 diff -u -r1.154.2.787 ChangeLog --- ChangeLog 2000/12/16 20:41:47 1.154.2.787 +++ ChangeLog 2000/12/17 20:09:53 @@ -1,3 +1,26 @@ +2000-12-17 Vladimir Vukicevic + + * config.h.in: Add XRENDERFONT #define + + * console-x.h: Add XRENDERFONT includes, and an xftDrawContext + member to the frame struct + + * glyphs-x.c (update_widget_face): initialize widget fonts properly + if the main font is coming from Xft by finding corresponding X core + font + + * objects-x.c (x_initialize_font_instance): Try to get an + AA font from Xft first, fall back to core fonts. + (x_finalize_font_instance): free the Xft + font, if present + (x_font_instance_properties): return Qnil for + Xft fonts (needs to be fixed) + + * objects-x.h: add renderFont to X font instance struct + + * redisplay-x.c (x_text_width_single_run, x_get_gc, + x_output_string): Render Xft fonts + 2000-12-09 Dan Holmsand * nt.c (mswindows_fstat): Report file permissions, volume serial Index: src/config.h.in =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/config.h.in,v retrieving revision 1.49.2.55 diff -u -r1.49.2.55 config.h.in --- config.h.in 2000/11/17 10:42:25 1.49.2.55 +++ config.h.in 2000/12/17 20:09:55 @@ -560,6 +560,9 @@ #undef XIM_MOTIF #undef USE_XFONTSET +/* Do we optionally use XRender/Xft for text? */ +#undef XRENDERFONT + /* Non-XIM input methods for use with Mule. */ #undef HAVE_CANNA #undef HAVE_WNN Index: src/console-x.h =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/console-x.h,v retrieving revision 1.11.2.12 diff -u -r1.11.2.12 console-x.h --- console-x.h 2000/11/07 08:20:42 1.11.2.12 +++ console-x.h 2000/12/17 20:09:57 @@ -57,6 +57,11 @@ #include #endif +#ifdef XRENDERFONT +#include +#include +#endif + /* R5 defines the XPointer type, but R4 doesn't. R4 also doesn't define a version number, but R5 does. */ #if (XlibSpecificationRelease < 5) @@ -325,6 +330,10 @@ the window manager. */ unsigned int top_level_frame_p :1; +#ifdef XRENDERFONT + XftDraw *xftDrawContext; +#endif + #ifdef EXTERNAL_WIDGET /* Are we using somebody else's window for our shell window? This means that our shell is an ExternalShell. If this flag is set, then @@ -358,6 +367,10 @@ #define FRAME_X_TOTALLY_VISIBLE_P(f) (FRAME_X_DATA (f)->totally_visible_p) #define FRAME_X_TOP_LEVEL_FRAME_P(f) (FRAME_X_DATA (f)->top_level_frame_p) + +#ifdef XRENDERFONT +#define FRAME_X_XFT_DRAWCONTEXT(f) (FRAME_X_DATA (f)->xftDrawContext) +#endif #ifdef EXTERNAL_WIDGET #define FRAME_X_EXTERNAL_WINDOW_P(f) (FRAME_X_DATA (f)->external_window_p) Index: src/glyphs-x.c =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/glyphs-x.c,v retrieving revision 1.49.2.85 diff -u -r1.49.2.85 glyphs-x.c --- glyphs-x.c 2000/11/28 17:15:13 1.49.2.85 +++ glyphs-x.c 2000/12/17 20:10:04 @@ -2361,6 +2361,7 @@ update_widget_face (widget_value* wv, Lisp_Image_Instance *ii, Lisp_Object domain) { + XFontStruct *xfont; #ifdef LWLIB_WIDGETS_MOTIF XmFontList fontList; #endif @@ -2377,21 +2378,44 @@ bcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (pixel)); lw_add_widget_value_arg (wv, XtNbackground, bcolor.pixel); + xfont = FONT_INSTANCE_X_FONT + (XFONT_INSTANCE (query_string_font + (IMAGE_INSTANCE_WIDGET_TEXT (ii), + IMAGE_INSTANCE_WIDGET_FACE (ii), + domain))); +#ifdef XRENDERFONT + if (!xfont) + { + XftFont *xft_font = FONT_INSTANCE_X_RENDERFONT + (XFONT_INSTANCE (query_string_font + (IMAGE_INSTANCE_WIDGET_TEXT (ii), + IMAGE_INSTANCE_WIDGET_FACE (ii), + domain))); + if (xft_font) + { + /* So the font is an Xft font. Try to grab it as a core font. */ + XFontStruct *core_font; + /* hack? */ + core_font = XftCoreOpen (XtDisplay (FRAME_X_SHELL_WIDGET(XFRAME(DOMAIN_FRAME (domain)))), + xft_font->pattern); + if (core_font) + xfont = core_font; + else + /* ??? */ + xfont = XLoadQueryFont (XtDisplay (FRAME_X_SHELL_WIDGET(XFRAME(DOMAIN_FRAME (domain)))), + "fixed"); + } + } +#endif + + #ifdef LWLIB_WIDGETS_MOTIF - fontList = XmFontListCreate - (FONT_INSTANCE_X_FONT - (XFONT_INSTANCE (query_string_font - (IMAGE_INSTANCE_WIDGET_TEXT (ii), - IMAGE_INSTANCE_WIDGET_FACE (ii), - domain))), XmSTRING_DEFAULT_CHARSET); + fontList = XmFontListCreate + (xfont, XmSTRING_DEFAULT_CHARSET); lw_add_widget_value_arg (wv, XmNfontList, (XtArgVal)fontList); #endif lw_add_widget_value_arg - (wv, XtNfont, (XtArgVal)FONT_INSTANCE_X_FONT - (XFONT_INSTANCE (query_string_font - (IMAGE_INSTANCE_WIDGET_TEXT (ii), - IMAGE_INSTANCE_WIDGET_FACE (ii), - domain)))); + (wv, XtNfont, (XtArgVal)xfont); wv->change = VISIBLE_CHANGE; /* #### Megahack - but its just getting too complicated to do this in the right place. */ Index: src/objects-x.c =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/objects-x.c,v retrieving revision 1.9.2.12 diff -u -r1.9.2.12 objects-x.c --- objects-x.c 2000/10/12 04:59:05 1.9.2.12 +++ objects-x.c 2000/12/17 20:10:07 @@ -368,8 +368,84 @@ Display *dpy = DEVICE_X_DISPLAY (XDEVICE (device)); XFontStruct *xf; const Extbyte *extname; +#ifdef XRENDERFONT + static int can_renderfont = 2; +#endif LISP_STRING_TO_EXTERNAL (f->name, extname, Qx_font_name_encoding); + +#ifdef XRENDERFONT + if (can_renderfont == 2) + { + if (XRenderFindVisualFormat (dpy, DefaultVisual + (dpy, DefaultScreen (dpy)))) + can_renderfont = 1; + else + can_renderfont = 0; + } + + if (can_renderfont) + { + /* try to get a font via Xft and XRender */ + // if (!strncmp (extname, "-xft-", strlen ("-xft-"))) + if (*extname == '-') + { + XftPattern *pat = NULL, *match = NULL; + XftResult res; + XftFont *renderFont = NULL; + + pat = XftXlfdParse (extname, 0, 1); + if (pat) + { + match = XftFontMatch (dpy, DefaultScreen (dpy), pat, &res); + + /* res seems to come back with junk in it, why? */ + if (match) + { + Bool is_core; + XftPatternGetBool (match, XFT_CORE, 0, &is_core); + if (!is_core) + { + /* match is internalized into the renderFont structure */ + /* This is a font that can be rendered */ + renderFont = XftFontOpenPattern (dpy, match); + } + else + { + XftPatternDestroy (match); + } + } + } + if (pat) + XftPatternDestroy (pat); + + if (renderFont) + { + /* Found one */ + f->data = xnew (struct x_font_instance_data); + /* We have to set the truename here, because the + * truename routines don't understand renderfonts yet. + */ + FONT_INSTANCE_X_TRUENAME (f) = build_string (extname); + + if (renderFont->core) + FONT_INSTANCE_X_FONT (f) = renderFont->u.core.font; + else + FONT_INSTANCE_X_FONT (f) = NULL; + FONT_INSTANCE_X_RENDERFONT (f) = renderFont; + f->ascent = renderFont->ascent; + f->descent = renderFont->descent; + /* XXX fixme -- use same hack with 'n' as used below */ + f->width = renderFont->max_advance_width; + f->height = renderFont->height; + f->proportional_p = 0; + + return 1; + } + } + } +#endif + xf = XLoadQueryFont (dpy, extname); if (!xf) @@ -392,6 +468,9 @@ or the finalize method may get fucked. */ f->data = xnew (struct x_font_instance_data); FONT_INSTANCE_X_TRUENAME (f) = Qnil; +#ifdef XRENDERFONT + FONT_INSTANCE_X_RENDERFONT (f) = NULL; +#endif FONT_INSTANCE_X_FONT (f) = xf; f->ascent = xf->ascent; f->descent = xf->descent; @@ -480,8 +559,14 @@ if (DEVICE_LIVE_P (XDEVICE (f->device))) { Display *dpy = DEVICE_X_DISPLAY (XDEVICE (f->device)); - +#ifdef XRENDERFONT + if (FONT_INSTANCE_X_RENDERFONT (f)) + XftFontClose (dpy, FONT_INSTANCE_X_RENDERFONT (f)); + else /* dangerous to leave this dangling, beware */ + XFreeFont (dpy, FONT_INSTANCE_X_FONT (f)); +#else XFreeFont (dpy, FONT_INSTANCE_X_FONT (f)); +#endif } xfree (f->data); f->data = 0; @@ -809,7 +894,15 @@ int i; Lisp_Object result = Qnil; Display *dpy = DEVICE_X_DISPLAY (d); - XFontProp *props = FONT_INSTANCE_X_FONT (f)->properties; + XFontProp *props; + +#ifdef XRENDERFONT + /* XXX FIXME */ + if (FONT_INSTANCE_X_RENDERFONT (f)) + return Qnil; +#endif + + props = FONT_INSTANCE_X_FONT (f)->properties; for (i = FONT_INSTANCE_X_FONT (f)->n_properties - 1; i >= 0; i--) { Index: src/objects-x.h =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/objects-x.h,v retrieving revision 1.2.2.2 diff -u -r1.2.2.2 objects-x.h --- objects-x.h 2000/07/21 10:17:06 1.2.2.2 +++ objects-x.h 2000/12/17 20:10:07 @@ -57,10 +57,16 @@ /* X-specific information */ Lisp_Object truename; XFontStruct *font; +#ifdef XRENDERFONT + XftFont *renderFont; +#endif }; #define X_FONT_INSTANCE_DATA(f) ((struct x_font_instance_data *) (f)->data) #define FONT_INSTANCE_X_FONT(f) (X_FONT_INSTANCE_DATA (f)->font) +#ifdef XRENDERFONT +#define FONT_INSTANCE_X_RENDERFONT(f) (X_FONT_INSTANCE_DATA (f)->renderFont) +#endif #define FONT_INSTANCE_X_TRUENAME(f) (X_FONT_INSTANCE_DATA (f)->truename) #endif /* HAVE_X_WINDOWS */ Index: src/redisplay-x.c =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/redisplay-x.c,v retrieving revision 1.23.2.29 diff -u -r1.23.2.29 redisplay-x.c --- redisplay-x.c 2000/10/12 10:14:10 1.23.2.29 +++ redisplay-x.c 2000/12/17 20:10:12 @@ -72,6 +72,9 @@ int xpos, face_index findex); static void x_clear_frame (struct frame *f); static void x_clear_frame_windows (Lisp_Object window); +#ifdef XRENDERFONT +static XftColor *x_xft_getColor(Display *dpy, Colormap cmap, Pixel pixel); +#endif /* Note: We do not use the Xmb*() functions and XFontSets. @@ -216,7 +219,7 @@ /****************************************************************************/ static int -x_text_width_single_run (struct face_cachel *cachel, struct textual_run *run) +x_text_width_single_run (struct frame *f, struct face_cachel *cachel, struct textual_run *run) { Lisp_Object font_inst = FACE_CACHEL_FONT (cachel, run->charset); Lisp_Font_Instance *fi = XFONT_INSTANCE (font_inst); @@ -224,12 +227,34 @@ return fi->width * run->len; else { +#ifdef XRENDERFONT + struct device *d = XDEVICE (f->device); + Display *dpy = DEVICE_X_DISPLAY (d); + + if (FONT_INSTANCE_X_RENDERFONT (fi)) { + XGlyphInfo glyphinfo; + if (run->dimension == 2) { + XftTextExtents16 (dpy, + FONT_INSTANCE_X_RENDERFONT (fi), + (XftChar16 *) run->ptr, run->len, &glyphinfo); + } else { + XftTextExtents8 (dpy, + FONT_INSTANCE_X_RENDERFONT (fi), + run->ptr, run->len, &glyphinfo); + } + + return glyphinfo.width; + } else { +#endif if (run->dimension == 2) return XTextWidth16 (FONT_INSTANCE_X_FONT (fi), (XChar2b *) run->ptr, run->len); else return XTextWidth (FONT_INSTANCE_X_FONT (fi), (char *) run->ptr, run->len); +#ifdef XRENDERFONT + } +#endif } } @@ -253,7 +278,7 @@ nruns = separate_textual_runs (text_storage, runs, str, len); for (i = 0; i < nruns; i++) - width_so_far += x_text_width_single_run (cachel, runs + i); + width_so_far += x_text_width_single_run (f, cachel, runs + i); return width_so_far; } @@ -661,8 +686,18 @@ if (!NILP (font)) { +#ifdef XRENDERFONT + /* Only set the font if it's a core font */ + /* the renderfont will be set elsewhere (not part of gc) */ + if (FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font))) + { + gcv.font = FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font))->fid; + mask |= GCFont; + } +#else gcv.font = FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font))->fid; mask |= GCFont; +#endif } /* evil kludge! */ @@ -875,7 +910,7 @@ if (EQ (font, Vthe_null_font_instance)) continue; - this_width = x_text_width_single_run (cachel, runs + i); + this_width = x_text_width_single_run (f, cachel, runs + i); need_clipping = (dl->clip || clip_start > xpos || clip_end < xpos + this_width); @@ -945,6 +980,14 @@ gc = x_get_gc (d, font, cachel->foreground, cachel->background, Qnil, Qnil); +#ifdef XRENDERFONT + if (FRAME_X_XFT_DRAWCONTEXT (f) == NULL) { + FRAME_X_XFT_DRAWCONTEXT (f) = XftDrawCreate (dpy, x_win, + DEVICE_X_VISUAL (d), + DEVICE_X_COLORMAP (d)); + } +#endif + if (need_clipping) { XRectangle clip_box[1]; @@ -956,8 +999,47 @@ XSetClipRectangles (dpy, gc, clip_start, DISPLAY_LINE_YPOS (dl), clip_box, 1, Unsorted); +#ifdef XRENDERFONT + { + Region rgn; + rgn = XCreateRegion (); + XUnionRectWithRegion (&clip_box[0], rgn, rgn); + XftDrawSetClip (FRAME_X_XFT_DRAWCONTEXT (f), rgn); + XDestroyRegion (rgn); + } +#endif } +#ifdef XRENDERFONT + if (FONT_INSTANCE_X_RENDERFONT (fi)) + { + XftFont *renderFont = FONT_INSTANCE_X_RENDERFONT (fi); + XGCValues values; + Colormap cmap = DEVICE_X_COLORMAP (d); + + XGetGCValues (dpy, gc, GCForeground|GCBackground, &values); + XftDrawRect (FRAME_X_XFT_DRAWCONTEXT (f), x_xft_getColor (dpy, cmap, values.background), + xpos, dl->ypos - FONT_INSTANCE_ASCENT(fi), + runs[i].len * FONT_INSTANCE_WIDTH(fi), + FONT_INSTANCE_HEIGHT(fi)); + + if (runs[i].dimension == 1) + XftDrawString8 (FRAME_X_XFT_DRAWCONTEXT (f), + x_xft_getColor (dpy, cmap, values.foreground), + renderFont, + xpos, dl->ypos, + runs[i].ptr, runs[i].len); + else + XftDrawString16 (FRAME_X_XFT_DRAWCONTEXT (f), + x_xft_getColor (dpy, cmap, values.foreground), + renderFont, + xpos, dl->ypos, + (XftChar16 *) runs[i].ptr, runs[i].len); + + } + else + { +#endif if (runs[i].dimension == 1) (bgc ? XDrawString : XDrawImageString) (dpy, x_win, gc, xpos, dl->ypos, (char *) runs[i].ptr, @@ -967,11 +1049,15 @@ dl->ypos, (XChar2b *) runs[i].ptr, runs[i].len); +#ifdef XRENDERFONT + } +#endif /* We draw underlines in the same color as the text. */ if (cachel->underline) { unsigned long upos, uthick; +#ifndef XRENDERFONT XFontStruct *xfont; xfont = FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font)); @@ -979,7 +1065,10 @@ upos = dl->descent / 2; if (!XGetFontProperty (xfont, XA_UNDERLINE_THICKNESS, &uthick)) uthick = 1; - +#else + upos = dl->descent / 2; + uthick = 1; +#endif if (dl->ypos + upos < dl->ypos + dl->descent - dl->clip) { if (dl->ypos + upos + uthick > dl->ypos + dl->descent - dl->clip) @@ -1000,6 +1089,7 @@ if (cachel->strikethru) { unsigned long ascent,descent,upos, uthick; +#ifndef XRENDERFONT XFontStruct *xfont; xfont = FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font)); @@ -1010,6 +1100,11 @@ descent = xfont->descent; if (!XGetFontProperty (xfont, XA_UNDERLINE_THICKNESS, &uthick)) uthick = 1; +#else + ascent = FONT_INSTANCE_ASCENT (fi); + descent = FONT_INSTANCE_DESCENT (fi); + uthick = 1; +#endif upos = ascent - ((ascent + descent) / 2) + 1; @@ -1037,6 +1132,11 @@ { XSetClipMask (dpy, gc, None); XSetClipOrigin (dpy, gc, 0, 0); +#ifdef XRENDERFONT + { + XftDrawSetClip (FRAME_X_XFT_DRAWCONTEXT (f), NULL); + } +#endif } /* If we are actually superimposing the cursor then redraw with just @@ -2078,6 +2178,53 @@ XSync (display, 0); } } + +/* xtf color cache */ +#ifdef XRENDERFONT +static XftColor * +x_xft_getColor(Display *dpy, Colormap cmap, Pixel pixel) +{ +#define CACHE_SIZE 32 + static struct { + XftColor color; + int use; + } cache[CACHE_SIZE]; + static int use; + int i; + int oldest, oldestuse; + XColor color; + + oldestuse = 0x7fffffff; + oldest = 0; + for (i = 0; i < CACHE_SIZE; i++) + { + if (cache[i].use) + { + if (cache[i].color.pixel == pixel) + { + cache[i].use = ++use; + return &cache[i].color; + } + } + if (cache[i].use < oldestuse) + { + oldestuse = cache[i].use; + oldest = i; + } + } + i = oldest; + color.pixel = pixel; + XQueryColor (dpy, cmap, &color); + cache[i].color.color.red = color.red; + cache[i].color.color.green = color.green; + cache[i].color.color.blue = color.blue; + cache[i].color.color.alpha = 0xffff; + cache[i].color.pixel = pixel; + cache[i].use = ++use; + return &cache[i].color; +} +#endif + /************************************************************************/ --==_Exmh_3031885080--