From e44956f15bba619f1c3ad8fa5927ae1862ef83c0 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Sun, 7 Sep 2014 23:28:29 +0200 Subject: [PATCH] Let GTK build pay attention to font arguments Multi-line text edits now use the initial value of the Option.textValue field as a pointer to a (char*) holding a font name, to be used for the text displayed in it. (After which they overwrite the field with the textView handle.) The font options -tagsFont, -commentFont, icsFont, -moveHistoryFont and -gameListFont are now activated in the GTK build, to control the corresponding memos. --- dialogs.c | 4 ++-- dialogs.h | 4 ++-- gtk/xboard.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++------ gtk/xoptions.c | 7 ++++++- xboard.texi | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 5 files changed, 105 insertions(+), 15 deletions(-) diff --git a/dialogs.c b/dialogs.c index 3a1769c..4de988b 100644 --- a/dialogs.c +++ b/dialogs.c @@ -1096,7 +1096,7 @@ NewComCallback (int n) } Option commentOptions[] = { -{ 200, T_VSCRL | T_FILL | T_WRAP | T_TOP, 250, NULL, (void*) &commentText, "", (char **) &CommentClick, TextBox, "" }, +{ 200, T_VSCRL | T_FILL | T_WRAP | T_TOP, 250, NULL, (void*) &commentText, (char*) &appData.commentFont, (char **) &CommentClick, TextBox, "" }, { 0, 0, 50, NULL, (void*) &ClearComment, NULL, NULL, Button, N_("clear") }, { 0, SAME_ROW, 100, NULL, (void*) &SaveChanges, NULL, NULL, Button, N_("save changes") }, { 0, SAME_ROW, 0, NULL, (void*) &NewComCallback, "", NULL, EndMark , "" } @@ -1195,7 +1195,7 @@ NewMove () static Option tagsOptions[] = { { 0, 0, 0, NULL, NULL, NULL, NULL, Label, NULL }, -{ 200, T_VSCRL | T_FILL | T_WRAP | T_TOP, 200, NULL, (void*) &tagsText, "", (char **) &TagsClick, TextBox, "" }, +{ 200, T_VSCRL | T_FILL | T_WRAP | T_TOP, 200, NULL, (void*) &tagsText, (char*) &appData.tagsFont, (char **) &TagsClick, TextBox, "" }, { 0, 0, 100, NULL, (void*) &NewMove, NULL, NULL, Button, N_("add next move") }, { 0,SAME_ROW,100,NULL, (void*) &changeTags, NULL, NULL, Button, N_("save changes") }, { 0,SAME_ROW, 0, NULL, (void*) &NewTagsCallback, "", NULL, EndMark , "" } diff --git a/dialogs.h b/dialogs.h index 1a27354..1e4861c 100644 --- a/dialogs.h +++ b/dialogs.h @@ -32,8 +32,8 @@ // int max X/E (w) (w) (w) (w) (w) (w) (w) (w) // void* handle X/E X/E X/E X/E X/E X X X X X // void* target X X X X/C C X X C C -// char* textValue E X/E * -// char ** choice X/E * X +// char* textValue X/E X/E * +// char ** choice C X/E * X // enum type X/E X/E X/E X/E X X X X X X X X // char[] name X/E X/E X/E X/E X X X X X // File and Path options are like String (but get a browse button added in the dialog), and Slider diff --git a/gtk/xboard.c b/gtk/xboard.c index de8c897..5dcbaf3 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -386,10 +386,9 @@ ParseFont (char *name, int number) // defer processing it until we know if it matches our board size if(!strstr(name, "-*-") && // ignore X-fonts size >= 0 && sizehandle, NULL, "font", "Monospace normal", NULL); + font = gtk_text_buffer_create_tag(opt->handle, NULL, "font", appData.icsFont, NULL); gtk_widget_modify_base(GTK_WIDGET(opt->textValue), GTK_STATE_NORMAL, &backgroundColor); } @@ -1349,6 +1349,11 @@ if(appData.debugMode) printf("n=%d, h=%d, w=%d\n",n,height,width); /* no label so let textview occupy all columns */ Pack(hbox, table, sw, left, left+r, top, GTK_EXPAND); } + if ( option[i].textValue != NULL ) { + PangoFontDescription *pfd; + pfd = pango_font_description_from_string(*(char**)option[i].textValue); + gtk_widget_modify_font(textview, pfd); + } if ( *(char**)option[i].target != NULL ) gtk_text_buffer_set_text (textbuffer, *(char**)option[i].target, -1); else diff --git a/xboard.texi b/xboard.texi index c3a32d6..2c00362 100644 --- a/xboard.texi +++ b/xboard.texi @@ -3102,7 +3102,8 @@ Default: true. The font used for the clocks. If the option value is a pattern that does not specify the font size, XBoard tries to choose an appropriate font for the board size being used. -Default: -*-helvetica-bold-r-normal--*-*-*-*-*-*-*-*. +Default Xaw: -*-helvetica-bold-r-normal--*-*-*-*-*-*-*-*. +Default GTK: Sans Bold %d. @item -coordFont font @cindex coordFont, option @cindex Font, coordinates @@ -3110,15 +3111,56 @@ The font used for rank and file coordinate labels if @code{showCoords} is true. If the option value is a pattern that does not specify the font size, XBoard tries to choose an appropriate font for the board size being used. -Default: -*-helvetica-bold-r-normal--*-*-*-*-*-*-*-*. +Default Xaw: -*-helvetica-bold-r-normal--*-*-*-*-*-*-*-*. +Default GTK: Sans Bold %d. @item -messageFont font @cindex messageFont, option @cindex Font, message -The font used for popup dialogs, menus, comments, etc. +The font used for popup dialogs, menus, etc. If the option value is a pattern that does not specify the font size, XBoard tries to choose an appropriate font for the board size being used. -Default: -*-helvetica-medium-r-normal--*-*-*-*-*-*-*-*. +Default Xaw: -*-helvetica-medium-r-normal--*-*-*-*-*-*-*-*. +Default GTK: Sans Bold %d. +@cindex tagsFont, option +@cindex Font, tags +The font used in the Edit Tags dialog. +If the option value contains %d, XBoard will replace it by +an appropriate font for the board size being used. +(Only used in GTK build.) +Default: Sans Normal %d. +@cindex commentFont, option +@cindex Font, comment +The font used in the Edit Comment dialog. +If the option value contains %d, XBoard will replace it by +an appropriate font for the board size being used. +(Only used in GTK build.) +Default: Sans Normal %d. +@cindex icsFont, option +@cindex Font, ics +The font used to display ICS output in the ICS Chat window. +As ICS output often contains tables aligned by spaces, +a mono-space font is recommended here. +If the option value contains %d, XBoard will replace it by +an appropriate font for the board size being used. +(Only used in GTK build.) +Default: Monospace Normal %d. +@cindex moveHistoryFont, option +@cindex Font, moveHistory +The font used in Move History and Engine Output windows. +As these windows display mainly moves, +one could use a figurine font here. +If the option value contains %d, XBoard will replace it by +an appropriate font for the board size being used. +(Only used in GTK build.) +Default: Sans Normal %d. +@cindex gameListFont, option +@cindex Font, gameList +The font used in the listbox of the Game List window. +If the option value contains %d, XBoard will replace it by +an appropriate font for the board size being used. +(Only used in GTK build.) +Default: Sans Bold %d. @item -fontSizeTolerance tol @cindex fontSizeTolerance, option In the font selection algorithm, a nonscalable font will be preferred -- 1.7.0.4