summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2019-05-23 08:26:32 +0300
committerEli Zaretskii <eliz@gnu.org>2019-05-31 11:32:24 +0300
commit2ffec6b48e282fd7b25c6ebf31c05ac6b75ff6ac (patch)
tree50846bfe79848c7e0cfa925801a66ad50625f54e
parentfba3687db414306da780d1faeb13fe947d2e6da6 (diff)
downloademacs-2ffec6b48e282fd7b25c6ebf31c05ac6b75ff6ac.tar.gz
Unbreak display of characters on MS-Windows
* src/w32font.c (w32font_draw): Convert the glyph_string's char2b array to 16-bit WCHAR data that ExtTextOutW needs. (cherry picked from commit 38564f8a664347c42f7614d9c91e0d49e4a073e8)
-rw-r--r--src/w32font.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/w32font.c b/src/w32font.c
index 2576df64b6f..14d49b24d9b 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -704,11 +704,23 @@ w32font_draw (struct glyph_string *s, int from, int to,
int i;
for (i = 0; i < len; i++)
- ExtTextOutW (s->hdc, x + i, y, options, NULL,
- s->char2b + from + i, 1, NULL);
+ {
+ WCHAR c = s->char2b[from + i] & 0xFFFF;
+ ExtTextOutW (s->hdc, x + i, y, options, NULL, &c, 1, NULL);
+ }
}
else
- ExtTextOutW (s->hdc, x, y, options, NULL, s->char2b + from, len, NULL);
+ {
+ /* The number of glyphs in a glyph_string cannot be larger than
+ the maximum value of the 'used' member of a glyph_row, so we
+ are OK using alloca here. */
+ eassert (len <= SHRT_MAX);
+ WCHAR *chars = alloca (len * sizeof (WCHAR));
+ int j;
+ for (j = 0; j < len; j++)
+ chars[j] = s->char2b[from + j] & 0xFFFF;
+ ExtTextOutW (s->hdc, x, y, options, NULL, chars, len, NULL);
+ }
/* Restore clip region. */
if (s->num_clips > 0)