jed-users mailing list

[2006 Date Index] [2006 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

XJed: support for charcell fonts


Hi,

I don't know what charcell fonts are, but they look the same as
mono-spaced fonts and it exist many of these fonts. Therefore XJed should
support them:

#v+
--- /home/joerg/svn/jed-upstream/src/xterm.c	2006-06-30 17:01:01.000000000 +0200
+++ src/xterm.c	2006-06-30 19:01:55.684579805 +0200
@@ -1647,6 +1647,8 @@
    static XFontStruct *xfont;
 
 #if XJED_HAS_XRENDERFONT
+   FcChar8 *real_font;
+
    if (XWin->face_size > 0)
      {
 	/* the user wants xrender */
@@ -1654,8 +1656,24 @@
 				    XFT_FAMILY, XftTypeString, font, 
 				    XFT_SIZE, XftTypeDouble, XWin->face_size,
 				    XFT_SPACING, XftTypeInteger, XFT_MONO,
-				    0);
+				    NULL);
 	if (XWin->xftfont == NULL) return -1;
+        FcPatternGetString(XWin->xftfont->pattern, FC_FAMILY, 0, &real_font);
+        if (strcmp(font, (char*)real_font) != 0)
+         {
+             XftFontClose(This_XDisplay, XWin->xftfont);
+             XWin->xftfont = XftFontOpen(This_XDisplay, This_XScreen,
+                                         XFT_FAMILY, XftTypeString, font,
+                                     XFT_SIZE, XftTypeDouble, XWin->face_size,
+                                    XFT_SPACING, XftTypeInteger, XFT_CHARCELL,
+                                         NULL);
+             if (XWin->xftfont == NULL) return -1;
+             FcPatternGetString(XWin->xftfont->pattern, FC_FAMILY, 0,
+                                &real_font);
+             if (strcmp(font, (char*)real_font) != 0)
+               (void) fprintf(stderr, "xjed: cannot load font %s, "
+                              "Xft proposed %s.\n", font, real_font);
+         }
 	XWin->font_name = font;
 	XWin->font_height = XWin->xftfont->ascent + XWin->xftfont->descent;
 	XWin->font_width = XWin->xftfont->max_advance_width;
#v-

This patch also adds a warning if the font selected by xft has a
different name than the font requested by the user. Because Xft has a
fallback wherefor it seems that XftFontOpen() never fails. The user see
only an different font and may guess it is not the right one.

The replacement of 0 by NULL is because a warning from gcc, because the
XftFontOpen() has the __atribute__ sentinel.

Bye, Jörg.
-- 
Man soll Denken lehren, nicht Gedachtes.

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2006 date index] [2006 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]