Pattern: Reduce row clue spacing if there are lots of them

Normally, we put two spaces between row clues, but if there are a lot
then even with a smaller font size they might overflow the left edge
of the window.  To compensate, go down to one space between clues
instead of two if there are a lot of them.  On my laptop the GTK build
demonstrates overflow with "13x1:1//1//1//1//1//1//1/1.1.1.1.1.1.1".
This commit is contained in:
Ben Harris
2023-04-24 22:25:12 +01:00
parent fcf1d274c3
commit bbbbc8b22b

View File

@ -1853,11 +1853,15 @@ static void draw_numbers(
} else {
int x, y;
size_t off = 0;
const char *spaces = " ";
assert(rowlen <= state->common->rowsize);
*ds->strbuf = '\0';
/* Squish up a bit if there are lots of clues. */
if (rowlen > TLBORDER(state->common->w)) spaces++;
for (j = 0; j < rowlen; j++)
off += sprintf(ds->strbuf + off, "%s%d", j ? " " : "", rowdata[j]);
off += sprintf(ds->strbuf + off, "%s%d",
j ? spaces : "", rowdata[j]);
y = ry;
x = BORDER + TILE_SIZE * (TLBORDER(state->common->w)-1);
draw_text(dr, x+TILE_SIZE, y+TILE_SIZE/2, FONT_VARIABLE,