From 418e072593e78839d701e7dc0634e8ebc08113af Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Tue, 5 Apr 2016 20:23:12 +0200 Subject: [PATCH] Adapt clock and message font after board-window sizing The clock and message font are now adapted to the new -boardSize value determined after sizing of the board window. When a valid font for the new size was already available (e.g. read from the settings file), it uses that. If not it uses the hard-coded default font name. In both cases a %d in the name is expanded based on the size-table indication for that font. This makes the clock font adpat even without prior history. --- gtk/xboard.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gtk/xboard.c b/gtk/xboard.c index eb7457d..f9163b8 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -1662,7 +1662,7 @@ void ReSize (WindowPlacement *wp) { GtkAllocation a; - int sqx, sqy, w, h, lg = lineGap; + int sqx, sqy, i, w, h, lg = lineGap; static int first = 1; // DisplayBothClocks(); if(wp->width == wpMain.width && wp->height == wpMain.height && !first) return; // not sized @@ -1691,9 +1691,18 @@ ReSize (WindowPlacement *wp) if(sqx == oldSqx + 1 && lg == lineGap + 1) sqx = oldSqx, squareSize = 0; // prevent oscillations, force resize by kludge } for(h=0; sizeDefaults[h].name && sizeDefaults[h].squareSize*8 > sqx*BOARD_WIDTH; h++) {} + if(initialSquareSize != sizeDefaults[h].squareSize) { // boardSize changed + initialSquareSize = sizeDefaults[h].squareSize; // used for saving font + if(!fontValid[CLOCK_FONT][initialSquareSize]) fontTable[CLOCK_FONT][initialSquareSize] = CLOCK_FONT_NAME; + appData.clockFont = InsertPxlSize(fontTable[CLOCK_FONT][initialSquareSize], 2*(sizeDefaults[h].clockFontPxlSize+1)/3); + if(!fontValid[MESSAGE_FONT][initialSquareSize]) fontTable[MESSAGE_FONT][initialSquareSize] = DEFAULT_FONT_NAME; + appData.font = InsertPxlSize(fontTable[MESSAGE_FONT][initialSquareSize], sizeDefaults[h].coordFontPxlSize); + DisplayBothClocks(); + ApplyFont(&mainOptions[W_MESSG], NULL); + for(i=1; i<6; i++) ApplyFont(&mainOptions[W_BUTTON+i], NULL); + } if(!strchr(appData.boardSize, ',')) { ASSIGN(appData.boardSize, sizeDefaults[h].name); - initialSquareSize = sizeDefaults[h].squareSize; // used for saving font } if(sizeDefaults[h].tinyLayout != tinyLayout) { // alter clipping of menu names to conform to board width int clip = (tinyLayout = sizeDefaults[h].tinyLayout) + 1; -- 1.7.0.4