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 | |
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')
5 files changed, 97 insertions, 12 deletions
diff --git a/Build/source/texk/dvipdfmx/dvipdfmx-20110311-PATCHES/ChangeLog b/Build/source/texk/dvipdfmx/dvipdfmx-20110311-PATCHES/ChangeLog index 5c76be80116..a0579a900f3 100644 --- a/Build/source/texk/dvipdfmx/dvipdfmx-20110311-PATCHES/ChangeLog +++ b/Build/source/texk/dvipdfmx/dvipdfmx-20110311-PATCHES/ChangeLog @@ -1,3 +1,8 @@ +2012-03-05 Peter Breitenlohner <peb@mppmu.mpg.de> + + * patch-07-surrogates (new): Handle UTP-16 surrogates for UCS-4 + supplementary planes. Based on patch from Tanaka Takuji-san. + 2012-01-17 Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp> * patch-06-dtou (new): Support for (e-)(u)pTeX dtou direction. diff --git a/Build/source/texk/dvipdfmx/dvipdfmx-20110311-PATCHES/patch-07-surrogates b/Build/source/texk/dvipdfmx/dvipdfmx-20110311-PATCHES/patch-07-surrogates new file mode 100644 index 00000000000..22c547b19aa --- /dev/null +++ b/Build/source/texk/dvipdfmx/dvipdfmx-20110311-PATCHES/patch-07-surrogates @@ -0,0 +1,44 @@ + Handle UTP-16 surrogates for UCS-4 supplementary planes. + +diff -ur dvipdfmx-20110311.orig/src/pdfdev.c dvipdfmx-20110311/src/pdfdev.c +--- dvipdfmx-20110311.orig/src/pdfdev.c 2012-01-17 19:27:40.000000000 +0100 ++++ dvipdfmx-20110311/src/pdfdev.c 2012-03-05 13:44:30.000000000 +0100 +@@ -960,17 +960,32 @@ + } + 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) { diff --git a/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/pdfdev.c b/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/pdfdev.c index 3e0c3e0fd62..ff7a83e728f 100644 --- a/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/pdfdev.c +++ b/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/pdfdev.c @@ -960,17 +960,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) { 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) { |