aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32uniscribe.c
diff options
context:
space:
mode:
authorJason Rumney2008-07-25 11:25:43 +0000
committerJason Rumney2008-07-25 11:25:43 +0000
commitf31cf550ca95e76bbff474487c68bb36992f96c3 (patch)
tree05a8e5b42151bc213d212609a3ce603fe6924dd8 /src/w32uniscribe.c
parent6f79c90b19ef0fa073a07e515db7639a2a81fb03 (diff)
downloademacs-f31cf550ca95e76bbff474487c68bb36992f96c3.tar.gz
emacs-f31cf550ca95e76bbff474487c68bb36992f96c3.zip
* w32font.c (w32font_encode_char): Encode characters outside BMP as
surrogates before looking up glyph index. (w32font_text_extents): Encode as surrogates if falling back to functions that need UTF-16 wide chars. * w32uniscribe.c (uniscribe_encode_char): Encode characters outside BMP as surrogates before looking up glyph index.
Diffstat (limited to 'src/w32uniscribe.c')
-rw-r--r--src/w32uniscribe.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c
index 0e0a4e8d143..fc9f48b3a17 100644
--- a/src/w32uniscribe.c
+++ b/src/w32uniscribe.c
@@ -411,25 +411,36 @@ uniscribe_encode_char (font, c)
411 struct font *font; 411 struct font *font;
412 int c; 412 int c;
413{ 413{
414 wchar_t chars[1]; 414 wchar_t chars[2];
415 int len;
415 WORD indices[1]; 416 WORD indices[1];
416 HDC context; 417 HDC context;
417 struct frame *f; 418 struct frame *f;
418 HFONT old_font; 419 HFONT old_font;
419 DWORD retval; 420 DWORD retval;
420 421
421 /* TODO: surrogates. */
422 if (c > 0xFFFF) 422 if (c > 0xFFFF)
423 return FONT_INVALID_CODE; 423 {
424 DWORD surrogate = c - 0x10000;
424 425
425 chars[0] = (wchar_t) c; 426 /* High surrogate: U+D800 - U+DBFF. */
427 chars[0] = 0xD800 + ((surrogate >> 10) & 0x03FF);
428 /* Low surrogate: U+DC00 - U+DFFF. */
429 chars[1] = 0xDC00 + (surrogate & 0x03FF);
430 len = 2;
431 }
432 else
433 {
434 chars[0] = (wchar_t) c;
435 len = 1;
436 }
426 437
427 /* Use selected frame until API is updated to pass the frame. */ 438 /* Use selected frame until API is updated to pass the frame. */
428 f = XFRAME (selected_frame); 439 f = XFRAME (selected_frame);
429 context = get_frame_dc (f); 440 context = get_frame_dc (f);
430 old_font = SelectObject (context, FONT_HANDLE(font)); 441 old_font = SelectObject (context, FONT_HANDLE(font));
431 442
432 retval = GetGlyphIndicesW (context, chars, 1, indices, 443 retval = GetGlyphIndicesW (context, chars, len, indices,
433 GGI_MARK_NONEXISTING_GLYPHS); 444 GGI_MARK_NONEXISTING_GLYPHS);
434 445
435 SelectObject (context, old_font); 446 SelectObject (context, old_font);