diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2012-03-05 14:38:14 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2012-03-05 14:38:14 +0000 |
commit | de78cac20606a5487809f4c7d8bb6c50ecf09204 (patch) | |
tree | af5bc03d1ceebeed25afc73b0ca394c834d3ba06 /Build/source/texk/xdvipdfmx | |
parent | edc562bfa3e97201709f690ae5c738b150dc365c (diff) |
(x)dvipdfmx: Handle UTP-16 surrogates for UCS-4 supplementary planes
git-svn-id: svn://tug.org/texlive/trunk@25568 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/xdvipdfmx')
-rw-r--r-- | Build/source/texk/xdvipdfmx/ChangeLog.TL | 6 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/pdfdev.c | 27 |
2 files changed, 27 insertions, 6 deletions
diff --git a/Build/source/texk/xdvipdfmx/ChangeLog.TL b/Build/source/texk/xdvipdfmx/ChangeLog.TL index b571158605c..ea1a38b7520 100644 --- a/Build/source/texk/xdvipdfmx/ChangeLog.TL +++ b/Build/source/texk/xdvipdfmx/ChangeLog.TL @@ -1,6 +1,12 @@ ChangeLog.TL: TeX Live (TL) changes for xdvipdfmx ================================================= +2012-03-05 Peter Breitenlohner <peb@mppmu.mpg.de> + + * pdfdev.c (handle_multibyte_string): Handle UTP-16 surrogates + for UCS-4 supplementary planes. + Based on patch from Tanaka Takuji-san. + 2012-03-04 Peter Breitenlohner <peb@mppmu.mpg.de> Avoid 'the address of XXX will always evaluate as true' warnings. diff --git a/Build/source/texk/xdvipdfmx/src/pdfdev.c b/Build/source/texk/xdvipdfmx/src/pdfdev.c index e74a60f7296..24727d12944 100644 --- a/Build/source/texk/xdvipdfmx/src/pdfdev.c +++ b/Build/source/texk/xdvipdfmx/src/pdfdev.c @@ -918,17 +918,32 @@ handle_multibyte_string (struct dev_font *font, } length *= 4; } else if (ctype == 2) { + int len = 0; + if (length * 2 >= FORMAT_BUF_SIZE) { WARN("Too long string..."); return -1; } - for (i = 0; i < length; i += 2) { - sbuf1[i*2 ] = font->ucs_group; - sbuf1[i*2+1] = font->ucs_plane; - sbuf1[i*2+2] = p[i]; - sbuf1[i*2+3] = p[i+1]; + for (i = 0; i < length; i += 2, len += 4) { + sbuf1[len ] = font->ucs_group; + if ((p[i] & 0xf8) == 0xd8) { + int c; + /* Check for valid surrogate pair. */ + if ((p[i] & 0xfc) != 0xd8 || i + 2 >= length || (p[i+2] & 0xfc) != 0xdc) { + WARN("Invalid surrogate p[%d]=%02X...", i, p[i]); + return -1; + } + c = (((p[i] & 0x03) << 10) | (p[i+1] << 2) | (p[i+2] & 0x03)) + 0x100; + sbuf1[len+1] = (c >> 8) & 0xff; + sbuf1[len+2] = c & 0xff; + i += 2; + } else { + sbuf1[len+1] = font->ucs_plane; + sbuf1[len+2] = p[i]; + } + sbuf1[len+3] = p[i+1]; } - length *= 2; + length = len; } p = sbuf1; } else if (ctype == 1 && font->mapc >= 0) { |