diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2012-01-18 07:34:45 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2012-01-18 07:34:45 +0000 |
commit | 31accee3d73f4b87a333844e128eb9258f5f8f11 (patch) | |
tree | f5cd89f6bd7385e53562868a48e9a4bfcb5c9788 | |
parent | 7ed3cb6de087f39952c7c885eb351bcadbac26d6 (diff) |
dvipdfmx: dtou patch for pTeX support from Kitagawa-san
git-svn-id: svn://tug.org/texlive/trunk@25139 c570f23f-e606-0410-a88d-b1316a301751
5 files changed, 386 insertions, 45 deletions
diff --git a/Build/source/texk/dvipdfmx/dvipdfmx-20110311-PATCHES/ChangeLog b/Build/source/texk/dvipdfmx/dvipdfmx-20110311-PATCHES/ChangeLog index bec2876c2f9..5c76be80116 100644 --- a/Build/source/texk/dvipdfmx/dvipdfmx-20110311-PATCHES/ChangeLog +++ b/Build/source/texk/dvipdfmx/dvipdfmx-20110311-PATCHES/ChangeLog @@ -1,3 +1,7 @@ +2012-01-17 Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp> + + * patch-06-dtou (new): Support for (e-)(u)pTeX dtou direction. + 2011-11-05 Akira Kakuto <kakuto@fuk.kindai.ac.jp> * patch-04-uptex: remove incompatible lines and erase #ifdef upTeX. diff --git a/Build/source/texk/dvipdfmx/dvipdfmx-20110311-PATCHES/patch-04-uptex b/Build/source/texk/dvipdfmx/dvipdfmx-20110311-PATCHES/patch-04-uptex index f0cbbde6424..82651fe8fcc 100644 --- a/Build/source/texk/dvipdfmx/dvipdfmx-20110311-PATCHES/patch-04-uptex +++ b/Build/source/texk/dvipdfmx/dvipdfmx-20110311-PATCHES/patch-04-uptex @@ -1,6 +1,6 @@ diff -ur dvipdfmx-20110311.orig/src/dvi.c dvipdfmx-20110311/src/dvi.c ---- dvipdfmx-20110311.orig/src/dvi.c Wed Mar 09 16:43:18 2011 -+++ dvipdfmx-20110311/src/dvi.c Sat Nov 05 22:25:11 2011 +--- dvipdfmx-20110311.orig/src/dvi.c 2011-03-09 08:43:18.000000000 +0100 ++++ dvipdfmx-20110311/src/dvi.c 2011-11-05 14:58:04.000000000 +0100 @@ -58,6 +58,10 @@ #define TEX_FONTS_ALLOC_SIZE 16u #define VF_NESTING_MAX 16u @@ -113,8 +113,8 @@ diff -ur dvipdfmx-20110311.orig/src/dvi.c dvipdfmx-20110311/src/dvi.c case PUT_RULE: diff -ur dvipdfmx-20110311.orig/src/tfm.c dvipdfmx-20110311/src/tfm.c ---- dvipdfmx-20110311.orig/src/tfm.c Sat Mar 05 13:44:49 2011 -+++ dvipdfmx-20110311/src/tfm.c Sat Nov 05 22:33:49 2011 +--- dvipdfmx-20110311.orig/src/tfm.c 2011-03-05 05:44:49.000000000 +0100 ++++ dvipdfmx-20110311/src/tfm.c 2011-11-05 14:58:04.000000000 +0100 @@ -55,6 +55,12 @@ #define IS_JFM(i) ((i) == JFM_ID || (i) == JFMV_ID) #endif /* !WITHOUT_ASCII_PTEX */ @@ -190,8 +190,8 @@ diff -ur dvipdfmx-20110311.orig/src/tfm.c dvipdfmx-20110311/src/tfm.c fm->source = SOURCE_TYPE_JFM; } diff -ur dvipdfmx-20110311.orig/src/vf.c dvipdfmx-20110311/src/vf.c ---- dvipdfmx-20110311.orig/src/vf.c Sat Mar 05 13:44:49 2011 -+++ dvipdfmx-20110311/src/vf.c Sat Nov 05 22:35:40 2011 +--- dvipdfmx-20110311.orig/src/vf.c 2011-03-05 05:44:49.000000000 +0100 ++++ dvipdfmx-20110311/src/vf.c 2011-11-05 14:58:04.000000000 +0100 @@ -238,11 +238,11 @@ ch = get_unsigned_quad (vf_file); /* Skip over TFM width since we already know it */ diff --git a/Build/source/texk/dvipdfmx/dvipdfmx-20110311-PATCHES/patch-06-dtou b/Build/source/texk/dvipdfmx/dvipdfmx-20110311-PATCHES/patch-06-dtou new file mode 100644 index 00000000000..de03c7c134f --- /dev/null +++ b/Build/source/texk/dvipdfmx/dvipdfmx-20110311-PATCHES/patch-06-dtou @@ -0,0 +1,268 @@ +diff -ur dvipdfmx-20110311.orig/src/dvi.c dvipdfmx-20110311/src/dvi.c +--- dvipdfmx-20110311.orig/src/dvi.c 2011-11-05 14:58:04.000000000 +0100 ++++ dvipdfmx-20110311/src/dvi.c 2012-01-17 19:27:40.000000000 +0100 +@@ -654,19 +654,25 @@ + + void dvi_right (SIGNED_QUAD x) + { +- if (!dvi_state.d) { +- dvi_state.h += x; +- } else { +- dvi_state.v += x; ++ switch (dvi_state.d) { ++ case 0: ++ dvi_state.h += x; break; ++ case 1: ++ dvi_state.v += x; break; ++ case 3: ++ dvi_state.v -= x; break; + } + } + + void dvi_down (SIGNED_QUAD y) + { +- if (!dvi_state.d) { +- dvi_state.v += y; +- } else { +- dvi_state.h -= y; ++ switch (dvi_state.d) { ++ case 0: ++ dvi_state.v += y; break; ++ case 1: ++ dvi_state.h -= y; break; ++ case 3: ++ dvi_state.h += y; break; + } + } + +@@ -721,10 +727,13 @@ + } + dvi_pop(); + } +- if (!dvi_state.d) { +- dvi_state.h += width; +- } else { +- dvi_state.v += width; ++ switch (dvi_state.d) { ++ case 0: ++ dvi_state.h += width; break; ++ case 1: ++ dvi_state.v += width; break; ++ case 3: ++ dvi_state.v -= width; break; + } + } + +@@ -803,11 +812,13 @@ + vf_set_char(ch, font->font_id); /* push/pop invoked */ + break; + } +- +- if (!dvi_state.d) { +- dvi_state.h += width; +- } else { +- dvi_state.v += width; ++ switch (dvi_state.d) { ++ case 0: ++ dvi_state.h += width; break; ++ case 1: ++ dvi_state.v += width; break; ++ case 3: ++ dvi_state.v -= width; break; + } + } + +@@ -890,17 +901,24 @@ + { + do_moveto(dvi_state.h, dvi_state.v); + +- if (!dvi_state.d) { ++ switch (dvi_state.d) { ++ case 0: + pdf_dev_set_rule(dvi_state.h, -dvi_state.v, width, height); +- } else { /* right ? */ ++ break; ++ case 1: + pdf_dev_set_rule(dvi_state.h, -dvi_state.v - width, height, width); ++ break; ++ case 3: ++ pdf_dev_set_rule(dvi_state.h - height, -dvi_state.v , height, width); ++ break; + } + } + + void +-dvi_dir (UNSIGNED_BYTE dir) ++dvi_dir (UNSIGNED_BYTE dir) /* how? */ + { +- dvi_state.d = dir ? 1 : 0; ++ fprintf(stderr, " > dvi_dir %d\n", dir); ++ dvi_state.d = dir; + pdf_dev_set_dirmode(dvi_state.d); /* 0: horizontal, 1: vertical */ + } + +@@ -1385,7 +1403,7 @@ + static void + do_dir (void) + { +- dvi_state.d = get_unsigned_byte(dvi_file) ? 1 : 0; ++ dvi_state.d = get_unsigned_byte(dvi_file); + pdf_dev_set_dirmode(dvi_state.d); /* 0: horizontal, 1: vertical */ + } + +diff -ur dvipdfmx-20110311.orig/src/pdfdev.c dvipdfmx-20110311/src/pdfdev.c +--- dvipdfmx-20110311.orig/src/pdfdev.c 2011-03-06 04:14:14.000000000 +0100 ++++ dvipdfmx-20110311/src/pdfdev.c 2012-01-17 19:27:40.000000000 +0100 +@@ -332,19 +332,23 @@ + * is vertical font. While ASCII pTeX manages current writing direction + * and font's WMode separately. + * +- * 00/11 WMODE_HH/VV h(v) font, h(v) direction. +- * 01 WMODE_HV -90 deg. rotated +- * 10 WMODE_VH +90 deg. rotated +- * ++ * 000/101 WMODE_HH/VV h(v) font, h(v) direction. ++ * 001 WMODE_HV -90 deg. rotated ++ * 100 WMODE_VH +90 deg. rotated ++ * 011 WMODE_HD +90 deg. rotated ++ * 111 WMODE_VD 180 deg. rotated ++ + * In MetaPost PostScript file processing (mp_mode = 1), only HH/VV mode + * is applied. + */ + #define TEXT_WMODE_HH 0 + #define TEXT_WMODE_HV 1 +-#define TEXT_WMODE_VH 2 +-#define TEXT_WMODE_VV 3 ++#define TEXT_WMODE_VH 4 ++#define TEXT_WMODE_VV 5 ++#define TEXT_WMODE_HD 3 ++#define TEXT_WMODE_VD 7 + +-#define ANGLE_CHANGES(m1,m2) ((abs((m1)-(m2)) % 3) == 0 ? 0 : 1) ++#define ANGLE_CHANGES(m1,m2) ((abs((m1)-(m2)) % 5) == 0 ? 0 : 1) + #define ROTATE_TEXT(m) ((m) != TEXT_WMODE_HH && (m) != TEXT_WMODE_VV) + + static struct { +@@ -526,6 +530,16 @@ + tm.a = 1.0; tm.b = -slant; + tm.c = 0.0; tm.d = extend; + break; ++ case TEXT_WMODE_HD: ++ /* Horizontal font */ ++ tm.a = 0.0; tm.b = extend; ++ tm.c = -1.0; tm.d = slant ; ++ break; ++ case TEXT_WMODE_VD: ++ /* Vertical font */ ++ tm.a = -1.0; tm.b = slant; ++ tm.c = 0.0; tm.d = -extend; ++ break; + } + tm.e = xpos * dev_unit.dvi2pts; + tm.f = ypos * dev_unit.dvi2pts; +@@ -730,6 +744,39 @@ + format_buffer[len++] = ' '; + len += dev_sprint_bp(format_buffer+len, desired_dely, &error_dely); + break; ++ case TEXT_WMODE_HD: ++ /* Horizontal font in down-to-up mode: rot = +90 ++ * ++ * | s/e -1| ++ * d_user = d x -I_hv = d x | | ++ * | 1/e 0| ++ */ ++ desired_delx = -(spt_t)(-(dely + delx*slant)/extend); ++ desired_dely = -delx; ++ ++ format_buffer[len++] = ' '; ++ len += dev_sprint_bp(format_buffer+len, desired_delx, &error_dely); ++ format_buffer[len++] = ' '; ++ len += dev_sprint_bp(format_buffer+len, desired_dely, &error_delx); ++ error_delx = -error_delx; ++ error_dely = -error_dely; ++ break; ++ case TEXT_WMODE_VD: ++ /* Vertical font in down-to-up mode: rot = 180 ++ * |-1 -s/e| ++ * d_user = d x -I_vv = d x | | ++ * | 0 -1/e| ++ */ ++ desired_delx = -delx; ++ desired_dely = -(spt_t)((dely + delx*slant)/extend); ++ ++ format_buffer[len++] = ' '; ++ len += dev_sprint_bp(format_buffer+len, desired_delx, &error_delx); ++ format_buffer[len++] = ' '; ++ len += dev_sprint_bp(format_buffer+len, desired_dely, &error_dely); ++ error_delx = -error_delx; ++ error_dely = -error_dely; ++ break; + } + pdf_doc_add_page_content(format_buffer, len); /* op: */ + /* +@@ -798,11 +845,11 @@ + + vert_font = font->wmode ? 1 : 0; + if (dev_param.autorotate) { +- vert_dir = text_state.dir_mode ? 1 : 0; ++ vert_dir = text_state.dir_mode; + } else { + vert_dir = vert_font; + } +- text_rotate = (vert_font << 1)|vert_dir; ++ text_rotate = (vert_font << 2)|vert_dir; + + if (font->slant != text_state.matrix.slant || + font->extend != text_state.matrix.extend || +@@ -1085,14 +1132,18 @@ + * (in 1000 units per em) but dvipdfmx does not take into account of this... + */ + +- if (text_state.dir_mode) { ++ if (text_state.dir_mode==0) { ++ /* Left-to-right */ ++ delh = text_xorigin + text_state.offset - xpos; ++ delv = ypos - text_yorigin; ++ } else if (text_state.dir_mode==1) { + /* Top-to-bottom */ + delh = ypos - text_yorigin + text_state.offset; + delv = xpos - text_xorigin; + } else { +- /* Left-to-right */ +- delh = text_xorigin + text_state.offset - xpos; +- delv = ypos - text_yorigin; ++ /* Bottom-to-top */ ++ delh = ypos + text_yorigin + text_state.offset; ++ delv = xpos + text_xorigin; + } + + /* White-space more than 3em is not considered as a part of single text. +@@ -1615,11 +1666,11 @@ + + vert_font = (font && font->wmode) ? 1 : 0; + if (dev_param.autorotate) { +- vert_dir = text_dir ? 1 : 0; ++ vert_dir = text_dir; + } else { + vert_dir = vert_font; + } +- text_rotate = (vert_font << 1)|vert_dir; ++ text_rotate = (vert_font << 2)|vert_dir; + + if (font && + ANGLE_CHANGES(text_rotate, text_state.matrix.rotate)) { +@@ -1640,11 +1691,11 @@ + + vert_font = (font && font->wmode) ? 1 : 0; + if (auto_rotate) { +- vert_dir = text_state.dir_mode ? 1 : 0; ++ vert_dir = text_state.dir_mode; + } else { + vert_dir = vert_font; + } +- text_rotate = (vert_font << 1)|vert_dir; ++ text_rotate = (vert_font << 2)|vert_dir; + + if (ANGLE_CHANGES(text_rotate, text_state.matrix.rotate)) { + text_state.force_reset = 1; diff --git a/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/dvi.c b/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/dvi.c index 3da43b19a8a..13b84e6d683 100644 --- a/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/dvi.c +++ b/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/dvi.c @@ -654,19 +654,25 @@ static void do_moveto (SIGNED_QUAD x, SIGNED_QUAD y) void dvi_right (SIGNED_QUAD x) { - if (!dvi_state.d) { - dvi_state.h += x; - } else { - dvi_state.v += x; + switch (dvi_state.d) { + case 0: + dvi_state.h += x; break; + case 1: + dvi_state.v += x; break; + case 3: + dvi_state.v -= x; break; } } void dvi_down (SIGNED_QUAD y) { - if (!dvi_state.d) { - dvi_state.v += y; - } else { - dvi_state.h -= y; + switch (dvi_state.d) { + case 0: + dvi_state.v += y; break; + case 1: + dvi_state.h -= y; break; + case 3: + dvi_state.h += y; break; } } @@ -721,10 +727,13 @@ do_string (unsigned char *s, int len) } dvi_pop(); } - if (!dvi_state.d) { - dvi_state.h += width; - } else { - dvi_state.v += width; + switch (dvi_state.d) { + case 0: + dvi_state.h += width; break; + case 1: + dvi_state.v += width; break; + case 3: + dvi_state.v -= width; break; } } @@ -803,11 +812,13 @@ dvi_set (SIGNED_QUAD ch) vf_set_char(ch, font->font_id); /* push/pop invoked */ break; } - - if (!dvi_state.d) { - dvi_state.h += width; - } else { - dvi_state.v += width; + switch (dvi_state.d) { + case 0: + dvi_state.h += width; break; + case 1: + dvi_state.v += width; break; + case 3: + dvi_state.v -= width; break; } } @@ -890,17 +901,24 @@ dvi_rule (SIGNED_QUAD width, SIGNED_QUAD height) { do_moveto(dvi_state.h, dvi_state.v); - if (!dvi_state.d) { + switch (dvi_state.d) { + case 0: pdf_dev_set_rule(dvi_state.h, -dvi_state.v, width, height); - } else { /* right ? */ + break; + case 1: pdf_dev_set_rule(dvi_state.h, -dvi_state.v - width, height, width); + break; + case 3: + pdf_dev_set_rule(dvi_state.h - height, -dvi_state.v , height, width); + break; } } void -dvi_dir (UNSIGNED_BYTE dir) +dvi_dir (UNSIGNED_BYTE dir) /* how? */ { - dvi_state.d = dir ? 1 : 0; + fprintf(stderr, " > dvi_dir %d\n", dir); + dvi_state.d = dir; pdf_dev_set_dirmode(dvi_state.d); /* 0: horizontal, 1: vertical */ } @@ -1385,7 +1403,7 @@ do_eop (void) static void do_dir (void) { - dvi_state.d = get_unsigned_byte(dvi_file) ? 1 : 0; + dvi_state.d = get_unsigned_byte(dvi_file); pdf_dev_set_dirmode(dvi_state.d); /* 0: horizontal, 1: vertical */ } diff --git a/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/pdfdev.c b/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/pdfdev.c index b98d1c9fc90..3e0c3e0fd62 100644 --- a/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/pdfdev.c +++ b/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/pdfdev.c @@ -332,19 +332,23 @@ static char format_buffer[FORMAT_BUF_SIZE]; * is vertical font. While ASCII pTeX manages current writing direction * and font's WMode separately. * - * 00/11 WMODE_HH/VV h(v) font, h(v) direction. - * 01 WMODE_HV -90 deg. rotated - * 10 WMODE_VH +90 deg. rotated - * + * 000/101 WMODE_HH/VV h(v) font, h(v) direction. + * 001 WMODE_HV -90 deg. rotated + * 100 WMODE_VH +90 deg. rotated + * 011 WMODE_HD +90 deg. rotated + * 111 WMODE_VD 180 deg. rotated + * In MetaPost PostScript file processing (mp_mode = 1), only HH/VV mode * is applied. */ #define TEXT_WMODE_HH 0 #define TEXT_WMODE_HV 1 -#define TEXT_WMODE_VH 2 -#define TEXT_WMODE_VV 3 +#define TEXT_WMODE_VH 4 +#define TEXT_WMODE_VV 5 +#define TEXT_WMODE_HD 3 +#define TEXT_WMODE_VD 7 -#define ANGLE_CHANGES(m1,m2) ((abs((m1)-(m2)) % 3) == 0 ? 0 : 1) +#define ANGLE_CHANGES(m1,m2) ((abs((m1)-(m2)) % 5) == 0 ? 0 : 1) #define ROTATE_TEXT(m) ((m) != TEXT_WMODE_HH && (m) != TEXT_WMODE_VV) static struct { @@ -526,6 +530,16 @@ dev_set_text_matrix (spt_t xpos, spt_t ypos, double slant, double extend, int ro tm.a = 1.0; tm.b = -slant; tm.c = 0.0; tm.d = extend; break; + case TEXT_WMODE_HD: + /* Horizontal font */ + tm.a = 0.0; tm.b = extend; + tm.c = -1.0; tm.d = slant ; + break; + case TEXT_WMODE_VD: + /* Vertical font */ + tm.a = -1.0; tm.b = slant; + tm.c = 0.0; tm.d = -extend; + break; } tm.e = xpos * dev_unit.dvi2pts; tm.f = ypos * dev_unit.dvi2pts; @@ -730,6 +744,39 @@ start_string (spt_t xpos, spt_t ypos, double slant, double extend, int rotate) format_buffer[len++] = ' '; len += dev_sprint_bp(format_buffer+len, desired_dely, &error_dely); break; + case TEXT_WMODE_HD: + /* Horizontal font in down-to-up mode: rot = +90 + * + * | s/e -1| + * d_user = d x -I_hv = d x | | + * | 1/e 0| + */ + desired_delx = -(spt_t)(-(dely + delx*slant)/extend); + desired_dely = -delx; + + format_buffer[len++] = ' '; + len += dev_sprint_bp(format_buffer+len, desired_delx, &error_dely); + format_buffer[len++] = ' '; + len += dev_sprint_bp(format_buffer+len, desired_dely, &error_delx); + error_delx = -error_delx; + error_dely = -error_dely; + break; + case TEXT_WMODE_VD: + /* Vertical font in down-to-up mode: rot = 180 + * |-1 -s/e| + * d_user = d x -I_vv = d x | | + * | 0 -1/e| + */ + desired_delx = -delx; + desired_dely = -(spt_t)((dely + delx*slant)/extend); + + format_buffer[len++] = ' '; + len += dev_sprint_bp(format_buffer+len, desired_delx, &error_delx); + format_buffer[len++] = ' '; + len += dev_sprint_bp(format_buffer+len, desired_dely, &error_dely); + error_delx = -error_delx; + error_dely = -error_dely; + break; } pdf_doc_add_page_content(format_buffer, len); /* op: */ /* @@ -798,11 +845,11 @@ dev_set_font (int font_id) vert_font = font->wmode ? 1 : 0; if (dev_param.autorotate) { - vert_dir = text_state.dir_mode ? 1 : 0; + vert_dir = text_state.dir_mode; } else { vert_dir = vert_font; } - text_rotate = (vert_font << 1)|vert_dir; + text_rotate = (vert_font << 2)|vert_dir; if (font->slant != text_state.matrix.slant || font->extend != text_state.matrix.extend || @@ -1085,14 +1132,18 @@ pdf_dev_set_string (spt_t xpos, spt_t ypos, * (in 1000 units per em) but dvipdfmx does not take into account of this... */ - if (text_state.dir_mode) { + if (text_state.dir_mode==0) { + /* Left-to-right */ + delh = text_xorigin + text_state.offset - xpos; + delv = ypos - text_yorigin; + } else if (text_state.dir_mode==1) { /* Top-to-bottom */ delh = ypos - text_yorigin + text_state.offset; delv = xpos - text_xorigin; } else { - /* Left-to-right */ - delh = text_xorigin + text_state.offset - xpos; - delv = ypos - text_yorigin; + /* Bottom-to-top */ + delh = ypos + text_yorigin + text_state.offset; + delv = xpos + text_xorigin; } /* White-space more than 3em is not considered as a part of single text. @@ -1615,11 +1666,11 @@ pdf_dev_set_dirmode (int text_dir) vert_font = (font && font->wmode) ? 1 : 0; if (dev_param.autorotate) { - vert_dir = text_dir ? 1 : 0; + vert_dir = text_dir; } else { vert_dir = vert_font; } - text_rotate = (vert_font << 1)|vert_dir; + text_rotate = (vert_font << 2)|vert_dir; if (font && ANGLE_CHANGES(text_rotate, text_state.matrix.rotate)) { @@ -1640,11 +1691,11 @@ dev_set_param_autorotate (int auto_rotate) vert_font = (font && font->wmode) ? 1 : 0; if (auto_rotate) { - vert_dir = text_state.dir_mode ? 1 : 0; + vert_dir = text_state.dir_mode; } else { vert_dir = vert_font; } - text_rotate = (vert_font << 1)|vert_dir; + text_rotate = (vert_font << 2)|vert_dir; if (ANGLE_CHANGES(text_rotate, text_state.matrix.rotate)) { text_state.force_reset = 1; |