From: H.G. Muller Date: Mon, 25 Jan 2010 12:54:40 +0000 (+0100) Subject: Save fonts in XBoard settings file per boardSize X-Git-Tag: master-20100206~22 X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=dc0bff62fbb2d491ed088ba2abdf1e5c99ec2755;p=xboard.git Save fonts in XBoard settings file per boardSize Each -boardSize now can have its own font specified in the settings file (and thus by a command-line option, although it would in general not be very useful to specify a font for a size other than the selected). E.g. a prefix "size33:" to the font name will apply it only to -size 33. An unspecified-size font option (not normally in the settings file) will always prevail over a font option specific for the current size. A font of some size must have been used or specified in order to be saved. --- diff --git a/xboard.c b/xboard.c index a9f8991..59800f9 100644 --- a/xboard.c +++ b/xboard.c @@ -1296,9 +1296,25 @@ colorVariable[] = { NULL }; +// [HGM] font: keep a font for each square size, even non-stndard ones +#define NUM_SIZES 18 +#define MAX_SIZE 130 +Boolean fontSet[NUM_FONTS], fontValid[NUM_FONTS][MAX_SIZE]; +char *fontTable[NUM_FONTS][MAX_SIZE]; + void ParseFont(char *name, int number) { // in XBoard, only 2 of the fonts are currently implemented, and we just copy their name + int size; + 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 && sizeargLoc) { + char *name, buf[MSG_SIZ]; + int i, n = (int)ad->argLoc; + switch(n) { case 0: // CLOCK_FONT name = appData.clockFont; break; @@ -1373,9 +1391,14 @@ SaveFontArg(FILE *f, ArgDescriptor *ad) default: return; } -// Do not save fonts for now, as the saved font would be board-size specific -// and not suitable for a re-start at another board size -// fprintf(f, OPTCHAR "%s" SEPCHAR "%s\n", ad->argName, name); + for(i=0; iargName, i, fontTable[n][i]); } void @@ -1816,7 +1839,14 @@ main(argc, argv) fontPxlSize = szd->fontPxlSize; smallLayout = szd->smallLayout; tinyLayout = szd->tinyLayout; - } + // [HGM] font: use defaults from settings file if available and not overruled + } + if(!fontSet[CLOCK_FONT] && fontValid[CLOCK_FONT][squareSize]) + appData.clockFont = fontTable[CLOCK_FONT][squareSize]; + if(!fontSet[MESSAGE_FONT] && fontValid[MESSAGE_FONT][squareSize]) + appData.font = fontTable[MESSAGE_FONT][squareSize]; + if(!fontSet[COORD_FONT] && fontValid[COORD_FONT][squareSize]) + appData.coordFont = fontTable[COORD_FONT][squareSize]; /* Now, using squareSize as a hint, find a good XPM/XIM set size */ if (strlen(appData.pixmapDirectory) > 0) {