mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 16:05:44 -07:00
Pattern: switch to small font when there are many row clues
If you have a particularly large number of clues in a row, they can end up falling off the left edge of the window. This used not to be a problem because the rendering code would squash them closer together if necessary. But then I switched to drawing them all as a single string (so that two-digit row clues would get enough space with a large font) and that broke the old mechanism. Now we detect if there are enough clues that our conservative guess at the string length looks like overflowing in the big font, and switch to the small one if necessary. If we had a drawing call to measure a string then we could be cleverer about this, but we don't. This problem can be demonstrated with "7x1:1//1//1//1/1.1.1.1" in the GTK port with the fonts my laptop has. I think overflow can still occur even with a small font, so once I've demonstrated that I'll try to fix it.
This commit is contained in:
10
pattern.c
10
pattern.c
@ -1025,6 +1025,16 @@ static game_state *new_game(midend *me, const game_params *params,
|
||||
for (j = 0; j < state->common->rowlen[i]; j++)
|
||||
if (state->common->rowdata[state->common->rowsize * i + j] >= 10)
|
||||
state->common->fontsize = FS_SMALL;
|
||||
/*
|
||||
* We might also need to use the small font if there are lots of
|
||||
* row clues. We assume that all clues are one digit and that a
|
||||
* single-digit clue takes up 1.5 tiles, of which the clue is 0.5
|
||||
* tiles and the space is 1.0 tiles.
|
||||
*/
|
||||
for (i = params->w; i < params->w + params->h; i++)
|
||||
if ((state->common->rowlen[i] * 3 - 2) >
|
||||
TLBORDER(state->common->w) * 2)
|
||||
state->common->fontsize = FS_SMALL;
|
||||
|
||||
if (desc[-1] == ',') {
|
||||
/*
|
||||
|
Reference in New Issue
Block a user