diff --git a/include/winX.h b/include/winX.h index dc34bd572..1c1521074 100644 --- a/include/winX.h +++ b/include/winX.h @@ -11,6 +11,9 @@ #ifdef USE_XFT #include +typedef XftFont X11_Font; +#else +typedef XFontStruct X11_Font; #endif #ifndef COLOR_H @@ -529,6 +532,7 @@ extern void X11_set_attrs(Widget, unsigned); extern void X11_set_highlight(Widget, boolean); extern void X11_set_percent(Widget, unsigned, Pixel); extern void X11_blink_labels(void); +extern int X11_font_height(X11_Font *); /* * These are for widgets that use the enhanced label services only for text diff --git a/win/X11/winX.c b/win/X11/winX.c index c59ab5fab..0f63a5761 100644 --- a/win/X11/winX.c +++ b/win/X11/winX.c @@ -794,7 +794,7 @@ nhFontHeight(Widget w, int win_type) #ifdef USE_XFT XftFont *font = X11_new_font(w, 0, win_type); - Dimension height = font->height; + Dimension height = X11_font_height(font); X11_release_font(w, font); return height; diff --git a/win/X11/winlabel.c b/win/X11/winlabel.c index e7a673a7a..662644f13 100644 --- a/win/X11/winlabel.c +++ b/win/X11/winlabel.c @@ -19,13 +19,7 @@ #include "winX.h" /* Declarations depending on Xft support or none */ -#ifdef USE_XFT -typedef XftFont X11_Font; -#else -typedef XFontStruct X11_Font; -#endif static int X11_text_width(Display *, X11_Font *, const char *, size_t); -static int X11_font_height(X11_Font *); /* Data attached to a wrapped widget */ typedef struct WidgetData { @@ -383,7 +377,7 @@ update_label(Widget w, WidgetData *data) /* Render the line */ #ifdef USE_XFT - XftDrawRect(draw, &bgcolor, x, y - font->ascent, lwidth, font->height); + XftDrawRect(draw, &bgcolor, x, y - font->ascent, lwidth, X11_font_height(font)); XftDrawString8(draw, &fgcolor, font, x, y, (const FcChar8 *) (label + i), line2); #else @@ -507,10 +501,10 @@ X11_text_width(Display *display, X11_Font *font, const char *text, size_t length return extents.width - extents.x; } -static int +int X11_font_height(X11_Font *font) { - return font->height; + return max(font->height, font->ascent + font->descent); } #else /* !USE_XFT */ static int @@ -520,7 +514,7 @@ X11_text_width(Display *display, X11_Font *font, const char *text, size_t length return XTextWidth(font, text, length); } -static int +int X11_font_height(X11_Font *font) { return font->ascent + font->descent; diff --git a/win/X11/winmap.c b/win/X11/winmap.c index a09691957..6e92eda63 100644 --- a/win/X11/winmap.c +++ b/win/X11/winmap.c @@ -1048,7 +1048,7 @@ get_char_info(struct xwindow *wp) struct text_map_info_t *text_map = &map_info->text_map; XftFont *font = X11_new_font(wp->w, 0, NHW_MAP); text_map->square_width = font->max_advance_width; - text_map->square_height = font->height; + text_map->square_height = X11_font_height(font); text_map->square_ascent = 0; text_map->square_lbearing = 0; X11_release_font(wp->w, font); @@ -1546,7 +1546,7 @@ X11_draw_image_string( { XftDrawRect(draw, bgcolor, x, y, length * font->max_advance_width, - font->height); + X11_font_height(font)); int xt = x; int yt = y + font->ascent; diff --git a/win/X11/winmesg.c b/win/X11/winmesg.c index aa707a186..ed172c4f8 100644 --- a/win/X11/winmesg.c +++ b/win/X11/winmesg.c @@ -158,7 +158,7 @@ create_message_window(struct xwindow *wp, /* window pointer */ XftFont *font = X11_new_font(wp->w, 0, NHW_MESSAGE); XGlyphInfo extents; mesg_info->char_width = font->max_advance_width; - mesg_info->char_height = font->height; + mesg_info->char_height = X11_font_height(font); mesg_info->char_ascent = font->ascent; mesg_info->char_lbearing = 0; /* Xft seems to offer no direct way to distinguish proportional from diff --git a/win/X11/winstat.c b/win/X11/winstat.c index 2fa32ae6b..5224522b3 100644 --- a/win/X11/winstat.c +++ b/win/X11/winstat.c @@ -785,6 +785,7 @@ tty_render_text(Widget w, const XRectangle *clip, int x, int y, /* Get the font */ XftFont *font = X11_new_font(w, attr, NHW_STATUS); + int height = X11_font_height(font); /* Get the drawing resources */ Display *display = XtDisplay(w); @@ -827,7 +828,7 @@ tty_render_text(Widget w, const XRectangle *clip, int x, int y, goldwidth = extents.width - extents.x; /* Render the gold symbol */ - XftDrawRect(draw, &bgcolor, x, y, goldwidth, font->height); + XftDrawRect(draw, &bgcolor, x, y, goldwidth, height); #ifdef ENHANCED_SYMBOLS XftDrawString32(draw, &fgcolor, font, x, y + font->ascent, &goldch, 1); #else /* !ENHANCED_SYMBOLS */ @@ -857,7 +858,7 @@ tty_render_text(Widget w, const XRectangle *clip, int x, int y, } /* Render the string */ - XftDrawRect(draw, &bgcolor, x + goldwidth, y, width, font->height); + XftDrawRect(draw, &bgcolor, x + goldwidth, y, width, height); XftDrawString8(draw, &fgcolor, font, x + goldwidth, y + font->ascent, (const FcChar8 *) text, strlen(text));