diff options
| author | Jason Rumney | 2008-07-25 11:25:43 +0000 |
|---|---|---|
| committer | Jason Rumney | 2008-07-25 11:25:43 +0000 |
| commit | f31cf550ca95e76bbff474487c68bb36992f96c3 (patch) | |
| tree | 05a8e5b42151bc213d212609a3ce603fe6924dd8 /src/w32font.c | |
| parent | 6f79c90b19ef0fa073a07e515db7639a2a81fb03 (diff) | |
| download | emacs-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/w32font.c')
| -rw-r--r-- | src/w32font.c | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/src/w32font.c b/src/w32font.c index 4a4c7625787..380bead2e74 100644 --- a/src/w32font.c +++ b/src/w32font.c | |||
| @@ -327,8 +327,13 @@ w32font_encode_char (font, c) | |||
| 327 | 327 | ||
| 328 | if (c > 0xFFFF) | 328 | if (c > 0xFFFF) |
| 329 | { | 329 | { |
| 330 | /* TODO: Encode as surrogate pair and lookup the glyph. */ | 330 | DWORD surrogate = c - 0x10000; |
| 331 | return FONT_INVALID_CODE; | 331 | |
| 332 | /* High surrogate: U+D800 - U+DBFF. */ | ||
| 333 | in[0] = 0xD800 + ((surrogate >> 10) & 0x03FF); | ||
| 334 | /* Low surrogate: U+DC00 - U+DFFF. */ | ||
| 335 | in[1] = 0xDC00 + (surrogate & 0x03FF); | ||
| 336 | len = 2; | ||
| 332 | } | 337 | } |
| 333 | else | 338 | else |
| 334 | { | 339 | { |
| @@ -394,7 +399,7 @@ w32font_text_extents (font, code, nglyphs, metrics) | |||
| 394 | HDC dc = NULL; | 399 | HDC dc = NULL; |
| 395 | struct frame * f; | 400 | struct frame * f; |
| 396 | int total_width = 0; | 401 | int total_width = 0; |
| 397 | WORD *wcode = NULL; | 402 | WORD *wcode; |
| 398 | SIZE size; | 403 | SIZE size; |
| 399 | 404 | ||
| 400 | struct w32font_info *w32_font = (struct w32font_info *) font; | 405 | struct w32font_info *w32_font = (struct w32font_info *) font; |
| @@ -484,19 +489,27 @@ w32font_text_extents (font, code, nglyphs, metrics) | |||
| 484 | /* For non-truetype fonts, GetGlyphOutlineW is not supported, so | 489 | /* For non-truetype fonts, GetGlyphOutlineW is not supported, so |
| 485 | fallback on other methods that will at least give some of the metric | 490 | fallback on other methods that will at least give some of the metric |
| 486 | information. */ | 491 | information. */ |
| 487 | if (!wcode) { | 492 | |
| 488 | wcode = alloca (nglyphs * sizeof (WORD)); | 493 | /* Make array big enough to hold surrogates. */ |
| 489 | for (i = 0; i < nglyphs; i++) | 494 | wcode = alloca (nglyphs * sizeof (WORD) * 2); |
| 490 | { | 495 | for (i = 0; i < nglyphs; i++) |
| 491 | if (code[i] < 0x10000) | 496 | { |
| 492 | wcode[i] = code[i]; | 497 | if (code[i] < 0x10000) |
| 493 | else | 498 | wcode[i] = code[i]; |
| 494 | { | 499 | else |
| 495 | /* TODO: Convert to surrogate, reallocating array if needed */ | 500 | { |
| 496 | wcode[i] = 0xffff; | 501 | DWORD surrogate = code[i] - 0x10000; |
| 497 | } | 502 | |
| 498 | } | 503 | /* High surrogate: U+D800 - U+DBFF. */ |
| 499 | } | 504 | wcode[i++] = 0xD800 + ((surrogate >> 10) & 0x03FF); |
| 505 | /* Low surrogate: U+DC00 - U+DFFF. */ | ||
| 506 | wcode[i] = 0xDC00 + (surrogate & 0x03FF); | ||
| 507 | /* An extra glyph. wcode is already double the size of code to | ||
| 508 | cope with this. */ | ||
| 509 | nglyphs++; | ||
| 510 | } | ||
| 511 | } | ||
| 512 | |||
| 500 | if (dc == NULL) | 513 | if (dc == NULL) |
| 501 | { | 514 | { |
| 502 | /* TODO: Frames can come and go, and their fonts outlive | 515 | /* TODO: Frames can come and go, and their fonts outlive |