From 51af0717099806507c09bab2416cfbc67c30224e Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sun, 2 Mar 2014 23:10:50 +0100 Subject: [PATCH] Implement (clock-)font handling in GTK The options -clockFont, -coordFont and -messageFont are activated, and supposed to have string values like "Sans Bold 12". The default values have the point size as 'wild-card' %d, however "Sans Bold %d", and are expanded by a printf with the point size taken from the defaults table. The expanded versions are saved back into the settings file, prefixed with a size tag, as usual. So far -clockFont is the only font that is actually applied while writing. The 'clock kludge' was interfering with the initial sizing, as for some sizes the initial clock-widget height happened to be equal to the final height. It was therefore abandoned, and we seem to be able to live without it. Sizes smaller than 49 were dominated (for 8-wide boards) by the menu bar. Therefore tinyLayout now uses single-letter menu labels. --- gtk/xboard.c | 45 +++++++++++++++++++++++++++++++++------------ gtk/xboard.h | 31 ++++++++----------------------- gtk/xoptions.c | 1 + 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/gtk/xboard.c b/gtk/xboard.c index 23e8951..76cd57d 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -384,7 +384,8 @@ ParseFont (char *name, int number) if(sscanf(name, "size%d:", &size)) { // [HGM] font: font is meant for specific boardSize (likely from settings file); // defer processing it until we know if it matches our board size - if(size >= 0 && size= 0 && sizeheight = BOARD_HEIGHT * (squareSize + lineGap) + lineGap + marginH + hc; - } + wp->height = BOARD_HEIGHT * (squareSize + lineGap) + lineGap + marginH + hc; if(wp->width == wpMain.width && wp->height == wpMain.height) return; // not sized sqx = (wp->width - lg - marginW) / BOARD_WIDTH - lg; sqy = (wp->height - lg - marginH - hc) / BOARD_HEIGHT - lg; @@ -1920,11 +1937,15 @@ DisplayTimerLabel (Option *opt, char *color, long timer, int highlight) gtk_widget_modify_bg(gtk_widget_get_parent(opt->handle), GTK_STATE_NORMAL, &col); if (appData.clockMode) { - markup = g_markup_printf_escaped("%s:%s%s", + markup = g_markup_printf_escaped("%s:%s%s", appData.clockFont, bgcolor, fgcolor, color, appData.logoSize && !partnerUp ? "\n" : " ", TimeString(timer)); +// markup = g_markup_printf_escaped("%s:%s%s", +// bgcolor, fgcolor, color, appData.logoSize && !partnerUp ? "\n" : " ", TimeString(timer)); } else { - markup = g_markup_printf_escaped("%s ", + markup = g_markup_printf_escaped("%s ", appData.clockFont, bgcolor, fgcolor, color); +// markup = g_markup_printf_escaped("%s ", +// bgcolor, fgcolor, color); } gtk_label_set_markup(GTK_LABEL(w), markup); g_free(markup); diff --git a/gtk/xboard.h b/gtk/xboard.h index ca8968e..89dcaf7 100644 --- a/gtk/xboard.h +++ b/gtk/xboard.h @@ -53,24 +53,9 @@ #define ICS_LOGON ".icsrc" #define MANPAGE "xboard.6" -#if ENABLE_NLS -#define CLOCK_FONT_NAME \ - "-*-helvetica-bold-r-normal--*-*-*-*-*-*-*-*," \ - "-misc-fixed-bold-r-normal--*-*-*-*-*-*-*-*," \ - "-*-*-*-*-*-*-*-*-*-*-*-*-*-*" -#define COORD_FONT_NAME \ - "-*-helvetica-bold-r-normal--*-*-*-*-*-*-*-*," \ - "-misc-fixed-bold-r-normal--*-*-*-*-*-*-*-*," \ - "-*-*-*-*-*-*-*-*-*-*-*-*-*-*" -#define DEFAULT_FONT_NAME \ - "-*-helvetica-medium-r-normal--*-*-*-*-*-*-*-*," \ - "-misc-fixed-medium-r-normal--*-*-*-*-*-*-*-*," \ - "-*-*-*-*-*-*-*-*-*-*-*-*-*-*" -#else -#define CLOCK_FONT_NAME "-*-helvetica-bold-r-normal--*-*-*-*-*-*-*-*" -#define COORD_FONT_NAME "-*-helvetica-bold-r-normal--*-*-*-*-*-*-*-*" -#define DEFAULT_FONT_NAME "-*-helvetica-medium-r-normal--*-*-*-*-*-*-*-*" -#endif +#define CLOCK_FONT_NAME "Sans Bold %d" +#define COORD_FONT_NAME "Sans Bold %d" +#define DEFAULT_FONT_NAME "Sans Normal %d" #define COLOR_SHOUT "green" #define COLOR_SSHOUT "green,black,1" #define COLOR_CHANNEL1 "cyan" @@ -107,11 +92,11 @@ typedef struct { { "Moderate", 58, 3, 34, 12, 14, 1, 0, 768 }, \ { "Average", 54, 2, 30, 11, 12, 1, 0, 600 }, \ { "Middling", 49, 2, 24, 10, 12, 1, 0, 600 }, \ - { "Mediocre", 45, 2, 20, 10, 12, 1, 0, 600 }, \ - { "Small", 40, 2, 20, 10, 12, 1, 0, 480 }, \ - { "Slim", 37, 2, 20, 10, 12, 1, 0, 480 }, \ - { "Petite", 33, 1, 15, 9, 11, 1, 0, 480 }, \ - { "Dinky", 29, 1, 15, 9, 11, 1, 0, 480 }, \ + { "Mediocre", 45, 2, 20, 10, 12, 1, 1, 600 }, \ + { "Small", 40, 2, 20, 10, 12, 1, 1, 480 }, \ + { "Slim", 37, 2, 20, 10, 12, 1, 1, 480 }, \ + { "Petite", 33, 1, 15, 9, 11, 1, 1, 480 }, \ + { "Dinky", 29, 1, 15, 9, 11, 1, 1, 480 }, \ { "Teeny", 25, 1, 12, 8, 11, 1, 1, 480 }, \ { "Tiny", 21, 1, 12, 8, 11, 1, 1, 0 }, \ { NULL, 0, 0, 0, 0, 0, 0, 0, 0 } } diff --git a/gtk/xoptions.c b/gtk/xoptions.c index 46b10ba..c089c9e 100644 --- a/gtk/xoptions.c +++ b/gtk/xoptions.c @@ -1549,6 +1549,7 @@ if(appData.debugMode) printf("n=%d, h=%d, w=%d\n",n,height,width); case DropDown: top--; msg = _(option[i].name); // write name on the menu button + if(tinyLayout) { strncpy(def, msg, 1); msg = def; } // XtSetArg(args[j], XtNmenuName, XtNewString(option[i].name)); j++; // XtSetArg(args[j], XtNlabel, msg); j++; option[i].handle = (void*) -- 1.7.0.4