{
char buf[4096];
va_list ap;
+ static int debugging = -1;
- va_start(ap, fmt);
- _vsnprintf(buf, 4095, fmt, ap);
- dputs(buf);
- va_end(ap);
+ if (debugging == -1)
+ debugging = getenv("DEBUG_PUZZLES") ? 1 : 0;
+
+ if (debugging) {
+ va_start(ap, fmt);
+ _vsnprintf(buf, 4095, fmt, ap);
+ dputs(buf);
+ va_end(ap);
+ }
}
#endif
int printoffsetx, printoffsety;
float printpixelscale;
int fontstart;
- int linewidth;
+ int linewidth, linedotted;
drawing *dr;
int xmin, ymin;
float puzz_scale;
sfree(fe->brushes);
sfree(fe->pens);
sfree(fe->presets);
+ sfree(fe->fonts);
sfree(fe);
}
float r, g, b;
int width = thin ? 0 : fe->linewidth;
+ if (fe->linedotted)
+ width = 0;
+
print_get_colour(fe->dr, colour, fe->printcolour, &hatch, &r, &g, &b);
/*
* Stroking in hatched colours is not permitted.
*/
assert(hatch < 0);
- pen = CreatePen(PS_SOLID, width, RGB(r * 255, g * 255, b * 255));
+ pen = CreatePen(fe->linedotted ? PS_DOT : PS_SOLID,
+ width, RGB(r * 255, g * 255, b * 255));
} else {
pen = fe->pens[colour];
}
HFONT oldfont;
TEXTMETRIC tm;
SIZE size;
-#ifdef _WIN32_WCE
TCHAR wText[256];
- MultiByteToWideChar (CP_ACP, 0, text, -1, wText, 256);
-#endif
+ MultiByteToWideChar (CP_UTF8, 0, text, -1, wText, 256);
oldfont = SelectObject(fe->hdc, fe->fonts[i].font);
if (GetTextMetrics(fe->hdc, &tm)) {
else
xy.y -= tm.tmAscent;
}
-#ifndef _WIN32_WCE
- if (GetTextExtentPoint32(fe->hdc, text, strlen(text), &size))
-#else
- if (GetTextExtentPoint32(fe->hdc, wText, wcslen(wText), &size))
-#endif
+ if (GetTextExtentPoint32W(fe->hdc, wText, wcslen(wText), &size))
{
if (align & ALIGN_HCENTRE)
xy.x -= size.cx / 2;
}
SetBkMode(fe->hdc, TRANSPARENT);
win_text_colour(fe, colour);
-#ifndef _WIN32_WCE
- TextOut(fe->hdc, xy.x, xy.y, text, strlen(text));
-#else
- ExtTextOut(fe->hdc, xy.x, xy.y, 0, NULL, wText, wcslen(wText), NULL);
-#endif
+ ExtTextOutW(fe->hdc, xy.x, xy.y, 0, NULL, wText, wcslen(wText), NULL);
SelectObject(fe->hdc, oldfont);
}
}
fe->linewidth = (int)(width * fe->printpixelscale);
}
+static void win_line_dotted(void *handle, int dotted)
+{
+ frontend *fe = (frontend *)handle;
+
+ assert(fe->drawstatus != DRAWING);
+ if (fe->drawstatus == NOTHING)
+ return;
+
+ fe->linedotted = dotted;
+}
+
static void win_begin_doc(void *handle, int pages)
{
frontend *fe = (frontend *)handle;
fe->printpixelscale = scale;
fe->linewidth = 1;
+ fe->linedotted = FALSE;
}
static void win_end_puzzle(void *handle)
}
}
+char *win_text_fallback(void *handle, const char *const *strings, int nstrings)
+{
+ /*
+ * We assume Windows can cope with any UTF-8 likely to be
+ * emitted by a puzzle.
+ */
+ return dupstr(strings[0]);
+}
+
const struct drawing_api win_drawing = {
win_draw_text,
win_draw_rect,
win_end_page,
win_end_doc,
win_line_width,
+ win_line_dotted,
+ win_text_fallback,
};
void print(frontend *fe)
DispatchMessage(&msg);
}
+ DestroyWindow(fe->hwnd);
cleanup_help();
return msg.wParam;