aboutsummaryrefslogtreecommitdiff
path: root/windows.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2009-12-27 10:01:16 +0000
committerSimon Tatham <anakin@pobox.com>2009-12-27 10:01:16 +0000
commit9fbb365684ef662fc183ebd45c2eeb50f40589b5 (patch)
tree494e77cfaa8402d920bd6615db0a31dbdbc59183 /windows.c
parent72922b307822874862d943893b10ac75d01689d2 (diff)
downloadpuzzles-9fbb365684ef662fc183ebd45c2eeb50f40589b5.zip
puzzles-9fbb365684ef662fc183ebd45c2eeb50f40589b5.tar.gz
puzzles-9fbb365684ef662fc183ebd45c2eeb50f40589b5.tar.bz2
puzzles-9fbb365684ef662fc183ebd45c2eeb50f40589b5.tar.xz
Introduce, and implement as usefully as I can in all front ends, a
new function in the drawing API which permits the display of text from outside basic ASCII. A fallback mechanism is provided so that puzzles can give a list of strings they'd like to display in order of preference and the system will return the best one it can manage; puzzles are required to cope with ASCII-only front ends. [originally from svn r8793]
Diffstat (limited to 'windows.c')
-rw-r--r--windows.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/windows.c b/windows.c
index 7fe11f3..1fb14b9 100644
--- a/windows.c
+++ b/windows.c
@@ -601,10 +601,8 @@ static void win_draw_text(void *handle, int x, int y, int fonttype,
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)) {
@@ -613,11 +611,7 @@ static void win_draw_text(void *handle, int x, int y, int fonttype,
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;
@@ -626,11 +620,7 @@ static void win_draw_text(void *handle, int x, int y, int fonttype,
}
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);
}
}
@@ -956,6 +946,15 @@ static void win_end_doc(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,
@@ -980,6 +979,7 @@ const struct drawing_api win_drawing = {
win_end_doc,
win_line_width,
win_line_dotted,
+ win_text_fallback,
};
void print(frontend *fe)