diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-02-05 23:29:18 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-02-05 23:29:18 +0000 |
commit | d96558db96e63d70e9262d88d4d81890dbcbc653 (patch) | |
tree | e93d51f50eae1542778428629b3fcd489f8f06de /Build/source/texk/web2c/luatexdir/pdf | |
parent | cc6eb49c8f55f231cab753ce5f6289ee62d24c13 (diff) |
web2c/luatexdir: sync with the upstream
git-svn-id: svn://tug.org/texlive/trunk@39581 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/pdf')
-rw-r--r-- | Build/source/texk/web2c/luatexdir/pdf/pdfgen.w | 51 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/pdf/pdfpage.w | 16 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/pdf/pdfrule.w | 4 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/pdf/pdftypes.h | 18 |
4 files changed, 74 insertions, 15 deletions
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w index f14254c1996..a6bf67f3ebb 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w +++ b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w @@ -538,6 +538,7 @@ void pdf_print_int(PDF pdf, longinteger n) } @ @c +/* void print_pdffloat(PDF pdf, pdffloat f) { char a[24]; @@ -561,6 +562,53 @@ void print_pdffloat(PDF pdf, pdffloat f) pdf_puts(pdf, (a + 1)); } } +*/ + +void print_pdffloat(PDF pdf, pdffloat f) +{ + int64_t m = f.m; + if (m == 0) { + pdf_out(pdf, '0'); + } else { + int e = f.e; + if (e == 0) { + /* division by ten_pow[0] == 1 */ + if (m == 1) { + pdf_out(pdf, '1'); + } else { + char a[24]; + snprintf(a, 23, "%ld", m); + pdf_puts(pdf, a); + } + } else { + int t = ten_pow[e] ; + if (t == m) { + pdf_out(pdf, '1'); + } else { + int i; + char a[24]; + int l = m / t; + int w = snprintf(a, 23, "%i", l); + pdf_out_block(pdf, (const char *) a, (size_t) w); + if (m < 0) { + l = - m % t; + } else { + l = m % t; + } + if (l != 0) { + pdf_out(pdf, '.'); + snprintf(a, 23, "%d", l + t); + for (i = e; i > 0; i--) { + if (a[i] != '0') + break; + a[i] = '\0'; + } + pdf_puts(pdf, (a + 1)); + } + } + } + } +} @ print out |s| as string in PDF output @@ -914,7 +962,8 @@ static void init_pdf_outputparameters(PDF pdf) int pk_mode; pdf->draftmode = fix_int(int_par(draft_mode_code), 0, 1); pdf->compress_level = fix_int(pdf_compress_level, 0, 9); - pdf->decimal_digits = fix_int(pdf_decimal_digits, 3, 6); + pdf->decimal_digits = fix_int(pdf_decimal_digits, 3, 5); +/* pdf->decimal_digits = fix_int(pdf_decimal_digits, 3, 6);*//* later, maybe (LS)*/ pdf->gamma = fix_int(pdf_gamma, 0, 1000000); pdf->image_gamma = fix_int(pdf_image_gamma, 0, 1000000); pdf->image_hicolor = fix_int(pdf_image_hicolor, 0, 1); diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w b/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w index 34bb5d1e933..90f63534d32 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w +++ b/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w @@ -105,16 +105,16 @@ boolean calc_pdfpos(pdfstructure * p, scaledpos pos) boolean move_pdfpos = false; switch (p->mode) { case PMODE_PAGE: - new.h = i32round(pos.h * p->k1); - new.v = i32round(pos.v * p->k1); + new.h = i64round(pos.h * p->k1); + new.v = i64round(pos.v * p->k1); p->cm[4].m = new.h - p->pdf.h.m; /* cm is concatenated */ p->cm[5].m = new.v - p->pdf.v.m; if (new.h != p->pdf.h.m || new.v != p->pdf.v.m) move_pdfpos = true; break; case PMODE_TEXT: - new.h = i32round(pos.h * p->k1); - new.v = i32round(pos.v * p->k1); + new.h = i64round(pos.h * p->k1); + new.v = i64round(pos.v * p->k1); p->tm[4].m = new.h - p->pdf_bt_pos.h.m; /* Tm replaces */ p->tm[5].m = new.v - p->pdf_bt_pos.v.m; if (new.h != p->pdf.h.m || new.v != p->pdf.v.m) @@ -124,16 +124,16 @@ boolean calc_pdfpos(pdfstructure * p, scaledpos pos) case PMODE_CHARARRAY: switch (p->wmode) { case WMODE_H: - new.h = i32round((pos.h * p->k1 - (double) p->pdf_tj_pos.h.m) * p->k2); - new.v = i32round(pos.v * p->k1); + new.h = i64round((pos.h * p->k1 - (double) p->pdf_tj_pos.h.m) * p->k2); + new.v = i64round(pos.v * p->k1); p->tj_delta.m = -i64round((double) ((new.h - p->cw.m) / ten_pow[p->cw.e - p->tj_delta.e])); p->tm[5].m = new.v - p->pdf_bt_pos.v.m; /* p->tm[4] is meaningless */ if (p->tj_delta.m != 0 || new.v != p->pdf.v.m) move_pdfpos = true; break; case WMODE_V: - new.h = i32round(pos.h * p->k1); - new.v = i32round(((double) p->pdf_tj_pos.v.m - pos.v * p->k1) * p->k2); + new.h = i64round(pos.h * p->k1); + new.v = i64round(((double) p->pdf_tj_pos.v.m - pos.v * p->k1) * p->k2); p->tm[4].m = new.h - p->pdf_bt_pos.h.m; /* p->tm[5] is meaningless */ p->tj_delta.m = -i64round((double) ((new.v - p->cw.m) / ten_pow[p->cw.e - p->tj_delta.e])); if (p->tj_delta.m != 0 || new.h != p->pdf.h.m) diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w b/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w index e4897dfb04b..2f75b4c761e 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w +++ b/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w @@ -54,7 +54,7 @@ void pdf_place_rule(PDF pdf, halfword q, scaledpos size, int callback_id) dim.v.e = p->pdf.v.e; pdf_puts(pdf, "q\n"); if (size.v <= one_bp) { - pos.v += i32round(0.5 * size.v); + pos.v += i64round(0.5 * size.v); pdf_set_pos_temp(pdf, pos); pdf_puts(pdf, "[]0 d 0 J "); print_pdffloat(pdf, dim.v); @@ -62,7 +62,7 @@ void pdf_place_rule(PDF pdf, halfword q, scaledpos size, int callback_id) print_pdffloat(pdf, dim.h); pdf_puts(pdf, " 0 l S\n"); } else if (size.h <= one_bp) { - pos.h += i32round(0.5 * size.h); + pos.h += i64round(0.5 * size.h); pdf_set_pos_temp(pdf, pos); pdf_puts(pdf, "[]0 d 0 J "); print_pdffloat(pdf, dim.h); diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h b/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h index 8a670a5274f..71f843e00f3 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h +++ b/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h @@ -36,7 +36,14 @@ # define pdfkeyprefix "PTEX" # define i32round(a) (int) floor((a) + 0.5) -# define i64round(a) (int64_t) floor((a) + 0.5) +/*# define i64round(a) (int64_t) floor((a) + 0.5)*/ +/*# define i64round(a) (int64_t) ( (double)(a+0.5) - ((int64_t)(a+0.5))%1 ) */ +#ifdef _WIN32 +# define i64round(a) (int64_t) win32_floor((a) + 0.5) +#else +# define i64round(a) (int64_t) lround((a)) +#endif + # define MAX_OBJ_COMPRESS_LEVEL 3 /* maximum/clipping value for \pdfobjcompresslevel */ # define OBJSTM_UNSET -1 /* initial value */ @@ -81,9 +88,12 @@ typedef struct { # define scaled int typedef struct scaledpos_ { - scaled h; - scaled v; -} scaledpos; + int64_t h; + int64_t v; + } scaledpos; + + + typedef struct scaled_whd_ { scaled wd; /* TeX width */ |