summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/pdf
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/pdf')
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pagetree.w10
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfaction.h4
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfaction.w4
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfannot.w19
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.h5
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w19
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfdest.w15
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdffont.w25
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfgen.h49
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfgen.w688
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w17
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfimage.w2
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdflink.w19
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdflistout.w16
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w28
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.h30
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.w115
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfobj.h4
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfobj.w44
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w25
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfpage.w9
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfrule.w2
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w8
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w10
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfshipout.h6
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w41
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdftables.h33
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdftables.w89
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfthread.h3
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfthread.w29
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdftypes.h32
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfxform.w11
32 files changed, 785 insertions, 626 deletions
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pagetree.w b/Build/source/texk/web2c/luatexdir/pdf/pagetree.w
index 8063d6a103b..b126d8a7a25 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pagetree.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pagetree.w
@@ -21,8 +21,8 @@
#include "ptexlib.h"
static const char _svn_version[] =
- "$Id: pagetree.w 3573 2010-04-02 14:10:54Z hhenkel $ "
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.60.x/source/texk/web2c/luatexdir/pdf/pagetree.w $";
+ "$Id: pagetree.w 3887 2010-09-14 21:32:23Z hhenkel $ "
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pagetree.w $";
@* Page diversions.
@@ -71,8 +71,7 @@ static pages_entry *new_pages_entry(PDF pdf)
for (i = 0; i < PAGES_TREE_KIDSMAX; i++)
p->kids[i] = 0;
p->next = NULL;
- pdf_create_obj(pdf, obj_type_pages, 0);
- p->objnum = pdf->obj_ptr;
+ p->objnum = pdf_create_obj(pdf, obj_type_pages, 0);
return p;
}
@@ -223,8 +222,7 @@ static void write_pages(PDF pdf, pages_entry * p, int parent)
if (parent == 0) { /* it's root */
if (pdf_pages_attr != null)
pdf_print_toks_ln(pdf, pdf_pages_attr);
- if (pdf_pagesattributes_toks != null) /* from Lua */
- pdf_print_toks_ln(pdf, pdf_pagesattributes_toks);
+ print_pdf_table_string(pdf, "pagesattributes");
} else
pdf_printf(pdf, "/Parent %d 0 R\n", parent);
pdf_printf(pdf, "/Count %d\n/Kids [", (int) p->number_of_pages);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfaction.h b/Build/source/texk/web2c/luatexdir/pdf/pdfaction.h
index 77944dd3f5b..2ea3a175403 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfaction.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfaction.h
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
-/* $Id: pdfaction.h 2801 2009-07-10 13:12:59Z taco $ */
+/* $Id: pdfaction.h 3891 2010-09-14 23:02:24Z hhenkel $ */
#ifndef PDFACTION_H
# define PDFACTION_H
@@ -59,7 +59,7 @@ typedef enum {
if (pdf_action_refcount(a) == null) { \
delete_action_node(a); \
} else { \
- decr(pdf_action_refcount(a)); \
+ pdf_action_refcount(a)--; \
} \
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfaction.w b/Build/source/texk/web2c/luatexdir/pdf/pdfaction.w
index 46992866f21..4bef7c1d087 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfaction.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfaction.w
@@ -21,8 +21,8 @@
#include "ptexlib.h"
static const char _svn_version[] =
- "$Id: pdfaction.w 3612 2010-04-13 09:29:42Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.60.x/source/texk/web2c/luatexdir/pdf/pdfaction.w $";
+ "$Id: pdfaction.w 3615 2010-04-13 21:59:59Z oneiros $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfaction.w $";
@ @c
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w b/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w
index a33de9e1905..b112c1a5447 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w
@@ -19,8 +19,8 @@
@ @c
static const char _svn_version[] =
- "$Id: pdfannot.w 3571 2010-04-02 13:50:45Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.60.x/source/texk/web2c/luatexdir/pdf/pdfannot.w $";
+ "$Id: pdfannot.w 3908 2010-10-13 19:22:02Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfannot.w $";
#include "ptexlib.h"
@@ -30,14 +30,15 @@ static const char _svn_version[] =
void do_annot(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
{
scaled_whd alt_rule;
- if (!is_shipping_page)
+ int k;
+ if (global_shipping_mode == SHIPPING_FORM)
pdf_error("ext4", "annotations cannot be inside an XForm");
if (doing_leaders)
return;
if (is_obj_scheduled(pdf, pdf_annot_objnum(p))) {
- pdf_create_obj(pdf, obj_type_annot, pdf->sys_obj_ptr + 1);
+ k = pdf_create_obj(pdf, obj_type_annot, pdf->obj_ptr + 1);
obj_annot_ptr(pdf, pdf_annot_objnum(p)) = p;
- pdf_annot_objnum(p) = pdf->sys_obj_ptr;
+ pdf_annot_objnum(p) = k;
}
alt_rule.wd = width(p);
alt_rule.ht = height(p);
@@ -72,8 +73,7 @@ void scan_annot(PDF pdf)
{
int k;
if (scan_keyword("reserveobjnum")) {
- pdf_create_obj(pdf, obj_type_annot, pdf->sys_obj_ptr + 1);
- k = pdf->sys_obj_ptr;
+ k = pdf_create_obj(pdf, obj_type_annot, pdf->obj_ptr + 1);
/* Scan an optional space */
get_x_token();
if (cur_cmd != spacer_cmd)
@@ -82,12 +82,11 @@ void scan_annot(PDF pdf)
if (scan_keyword("useobjnum")) {
scan_int();
k = cur_val;
- check_obj_exists(pdf, obj_type_annot, k);
+ check_obj_type(pdf, obj_type_annot, k);
if (obj_annot_ptr(pdf, k) != 0)
pdf_error("ext1", "annot object in use");
} else {
- pdf_create_obj(pdf, obj_type_annot, pdf->sys_obj_ptr + 1);
- k = pdf->sys_obj_ptr;
+ k = pdf_create_obj(pdf, obj_type_annot, pdf->obj_ptr + 1);
}
new_annot_whatsit(pdf_annot_node);
obj_annot_ptr(pdf, k) = tail;
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.h b/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.h
index 20d8e436146..3d8a396aa94 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.h
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
-/* $Id: pdfcolorstack.h 3261 2009-12-18 11:38:21Z taco $ */
+/* $Id: pdfcolorstack.h 3676 2010-05-02 20:04:49Z hhenkel $ */
#ifndef PDFCOLORSTACK_H
# define PDFCOLORSTACK_H
@@ -26,9 +26,6 @@
# define set_pdf_colorstack_cmd(A,B) pdf_colorstack_cmd(A)=B
# define set_pdf_colorstack_data(A,B) pdf_colorstack_data(A)=B
-/* remember shipout mode: page/form */
-extern boolean page_mode;
-
# define STACK_INCREMENT 8
int newcolorstack(int s, int literal_mode, boolean pagestart);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w b/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w
index 4d31e99e76a..3ed72e0eb87 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w
@@ -21,8 +21,8 @@
#include "ptexlib.h"
static const char _svn_version[] =
- "$Id: pdfcolorstack.w 3612 2010-04-13 09:29:42Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.60.x/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w $";
+ "$Id: pdfcolorstack.w 3891 2010-09-14 23:02:24Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w $";
@* Color Stack and Matrix Transformation Support.
@@ -54,9 +54,6 @@ They have the following properties:
#define DIRECT_PAGE 1
#define DIRECT_ALWAYS 2
-/* remember shipout mode: page/form */
-boolean page_mode;
-
typedef struct {
char **page_stack;
char **form_stack;
@@ -176,7 +173,7 @@ static int colorstackset(int colstack_no, str_number s)
{
colstack_type *colstack = get_colstack(colstack_no);
- if (page_mode) {
+ if (global_shipping_mode == SHIPPING_PAGE) {
xfree(colstack->page_current);
colstack->page_current = makecstring(s);
} else {
@@ -191,7 +188,7 @@ int colorstackcurrent(int colstack_no)
{
colstack_type *colstack = get_colstack(colstack_no);
- if (page_mode) {
+ if (global_shipping_mode == SHIPPING_PAGE) {
put_cstring_on_str_pool(colstack->page_current);
} else {
put_cstring_on_str_pool(colstack->form_current);
@@ -204,7 +201,7 @@ static int colorstackpush(int colstack_no, str_number s)
{
colstack_type *colstack = get_colstack(colstack_no);
char *str;
- if (page_mode) {
+ if (global_shipping_mode == SHIPPING_PAGE) {
if (colstack->page_used == colstack->page_size) {
colstack->page_size += STACK_INCREMENT;
colstack->page_stack = xretalloc(colstack->page_stack,
@@ -243,7 +240,7 @@ int colorstackpop(int colstack_no)
{
colstack_type *colstack = get_colstack(colstack_no);
- if (page_mode) {
+ if (global_shipping_mode == SHIPPING_PAGE) {
if (colstack->page_used == 0) {
pdftex_warn("pop empty color page stack %u",
(unsigned int) colstack_no);
@@ -271,7 +268,7 @@ void colorstackpagestart(void)
int i, j;
colstack_type *colstack;
- if (page_mode) {
+ if (global_shipping_mode == SHIPPING_PAGE) {
/* see procedure |pdf_out_colorstack_startpage| */
return;
}
@@ -381,6 +378,6 @@ void pdf_out_colorstack_startpage(PDF pdf)
flush_str(s);
}
}
- incr(i);
+ i++;
}
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfdest.w b/Build/source/texk/web2c/luatexdir/pdf/pdfdest.w
index f97ea95e2ac..6081369e8b8 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfdest.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfdest.w
@@ -19,8 +19,8 @@
@ @c
static const char _svn_version[] =
- "$Id: pdfdest.w 3571 2010-04-02 13:50:45Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.60.x/source/texk/web2c/luatexdir/pdf/pdfdest.w $";
+ "$Id: pdfdest.w 3889 2010-09-14 22:21:57Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfdest.w $";
#include "ptexlib.h"
@@ -88,7 +88,7 @@ void do_dest(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
scaledpos pos = pdf->posstruct->pos;
scaled_whd alt_rule;
int k;
- if (!is_shipping_page)
+ if (global_shipping_mode == SHIPPING_FORM)
pdf_error("ext4", "destinations cannot be inside an XForm");
if (doing_leaders)
return;
@@ -321,6 +321,7 @@ int output_name_tree(PDF pdf)
int k = 0; /* index of current child of |l|; if |k < pdf_dest_names_ptr|
then this is pointer to |dest_names| array;
otherwise it is the pointer to |obj_tab| (object number) */
+ int m;
int dests = 0;
int names_head = 0, names_tail = 0;
if (pdf->dest_names_ptr == 0) {
@@ -329,10 +330,8 @@ int output_name_tree(PDF pdf)
sort_dest_names(pdf);
while (true) {
-
do {
- pdf_create_obj(pdf, obj_type_others, 0); /* create a new node */
- l = pdf->obj_ptr;
+ l = pdf_create_obj(pdf, obj_type_others, 0); /* create a new node */
if (b == 0)
b = l; /* first in this level */
if (names_head == 0) {
@@ -401,7 +400,7 @@ int output_name_tree(PDF pdf)
DONE:
if ((dests != 0) || (pdf_names_toks != null)) {
- pdf_new_dict(pdf, obj_type_others, 0, 1);
+ m = pdf_new_dict(pdf, obj_type_others, 0, 1);
if (dests != 0)
pdf_indirect_ln(pdf, "Dests", dests);
if (pdf_names_toks != null) {
@@ -410,7 +409,7 @@ int output_name_tree(PDF pdf)
pdf_names_toks = null;
}
pdf_end_dict(pdf);
- return pdf->obj_ptr;
+ return m;
} else {
return 0;
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdffont.w b/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
index 94dbc0c1e0a..0a33057f368 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
@@ -21,8 +21,8 @@
@ @c
static const char _svn_version[] =
- "$Id: pdffont.w 3638 2010-04-20 14:00:47Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.1/source/texk/web2c/luatexdir/pdf/pdffont.w $";
+ "$Id: pdffont.w 4098 2011-04-07 21:01:11Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdffont.w $";
#include "ptexlib.h"
@@ -64,7 +64,6 @@ void output_one_char(PDF pdf, internal_font_number ffi, int c)
break;
}
if (has_packet(ffi, c)) {
- assert(pdf->o_mode == OMODE_PDF);
do_vf_packet(pdf, ffi, c);
} else
backend_out[glyph_node] (pdf, ffi, c); /* |pdf_place_glyph(pdf, ffi, c);| */
@@ -91,7 +90,7 @@ indicates that the corresponding font shares the font resource with the font
static boolean font_shareable(internal_font_number f, internal_font_number k)
{
int ret = 0;
- internal_font_number b;
+ internal_font_number b; /* possible base font */
/* For some lua-loaded (for instance AFM) fonts, it is normal to have
a zero cidregistry, and such fonts do not have a fontmap entry yet
at this point, so the test should use the other branch */
@@ -101,7 +100,7 @@ static boolean font_shareable(internal_font_number f, internal_font_number k)
font_map(f) != NULL &&
(same(font_name, k, f) ||
(font_auto_expand(f) &&
- (b = pdf_font_blink(f)) != 0 && same(font_name, k, b)))) {
+ (b = pdf_font_blink(k)) != null_font && same(font_name, k, b)))) {
ret = 1;
}
#ifdef DEBUG
@@ -111,7 +110,8 @@ static boolean font_shareable(internal_font_number f, internal_font_number k)
} else {
if ((same(font_filename, k, f) && same(font_fullname, k, f))
|| (font_auto_expand(f)
- && (b = pdf_font_blink(f)) != 0 && same(font_name, k, b))) {
+ && (b = pdf_font_blink(k)) != null_font
+ && same(font_name, k, b))) {
ret = 1;
}
#ifdef DEBUG
@@ -129,12 +129,12 @@ void pdf_init_font(PDF pdf, internal_font_number f)
{
internal_font_number k, b;
fm_entry *fm;
- int i;
+ int i, l;
assert(!font_used(f));
/* if |f| is auto expanded then ensure the base font is initialized */
- if (font_auto_expand(f) && ((b = pdf_font_blink(f)) != 0)) {
+ if (font_auto_expand(f) && ((b = pdf_font_blink(f)) != null_font)) {
if (!font_used(b))
pdf_init_font(pdf, b);
set_font_map(f, font_map(b));
@@ -173,8 +173,8 @@ void pdf_init_font(PDF pdf, internal_font_number f)
i = obj_link(pdf, i);
}
/* create a new font object for |f| */
- pdf_create_obj(pdf, obj_type_font, f);
- pdf_use_font(f, pdf->obj_ptr);
+ l = pdf_create_obj(pdf, obj_type_font, f);
+ pdf_use_font(f, l);
}
@ set the actual font on PDF page
@@ -418,6 +418,7 @@ void new_letterspaced_font(small_number a)
pointer u; /* user's font identifier */
str_number t; /* name for the frozen font identifier */
internal_font_number f, k;
+ boolean nolig = false;
get_r_token();
u = cur_cs;
if (u >= hash_base)
@@ -429,7 +430,9 @@ void new_letterspaced_font(small_number a)
scan_font_ident();
k = cur_val;
scan_int();
- f = letter_space_font(u, k, fix_int(cur_val, -1000, 1000));
+ if (scan_keyword("nolig"))
+ nolig=true;
+ f = letter_space_font(k, fix_int(cur_val, -1000, 1000), nolig);
equiv(u) = f;
eqtb[font_id_base + f] = eqtb[u];
font_id_text(f) = t;
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h
index f5840e715db..0bc83c7e04d 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
-/* $Id: pdfgen.h 3573 2010-04-02 14:10:54Z hhenkel $ */
+/* $Id: pdfgen.h 3940 2010-11-01 22:46:24Z hhenkel $ */
#ifndef PDFGEN_H
# define PDFGEN_H
@@ -76,6 +76,8 @@ typedef enum {
zip_finish = 2 /* finish \.{ZIP} compression */
} zip_write_states;
+typedef enum { NOT_SHIPPING, SHIPPING_PAGE, SHIPPING_FORM } shipping_mode_e;
+
extern int pdf_output_option;
extern int pdf_output_value;
extern int pdf_draftmode_option;
@@ -99,11 +101,14 @@ extern void fix_pdf_minorversion(PDF);
/* do the same as |pdf_quick_out| and flush the PDF buffer if necessary */
# define pdf_out(pdf,A) do { pdf_room(pdf,1); pdf_quick_out(pdf,A); } while (0)
-# define pdf_out_block(pdf,A,n) do { \
+# if 0
+/* see function pdf_out_block() */
+# define pdf_out_block_macro(pdf,A,n) do { \
pdf_room(pdf,(int)(n)); \
(void)memcpy((pdf->buf+pdf->ptr),(A),(size_t)(n)); \
pdf->ptr+=(int)(n); \
} while (0)
+# endif
/*
Basic printing procedures for PDF output are very similiar to \TeX\ basic
@@ -111,10 +116,10 @@ printing ones but the output is going to PDF buffer. Subroutines with
suffix |_ln| append a new-line character to the PDF output.
*/
-# define pdf_new_line_char 10 /* new-line character for UNIX platforms */
+# define pdf_newline_char 10 /* new-line character '\n' for UNIX platforms */
/* output a new-line character to PDF buffer */
-# define pdf_print_nl(pdf) pdf_out(pdf,pdf_new_line_char)
+# define pdf_print_nl(pdf) pdf_out(pdf,pdf_newline_char)
/* print out a string to PDF buffer followed by a new-line character */
# define pdf_print_ln(pdf,A) do { \
@@ -128,7 +133,6 @@ suffix |_ln| append a new-line character to the PDF output.
pdf_print_nl(pdf); \
} while (0)
-extern void pdf_puts(PDF, const char *);
extern __attribute__ ((format(printf, 2, 3)))
void pdf_printf(PDF, const char *, ...);
@@ -151,13 +155,15 @@ extern void pdf_print_mag_bp(PDF, scaled);
extern void addto_page_resources(PDF pdf, pdf_obj_type t, int k);
extern pdf_object_list *get_page_resources_list(PDF pdf, pdf_obj_type t);
+extern void pdf_out_block(PDF pdf, const char *s, size_t n);
+
+# define pdf_puts(pdf, s) pdf_out_block((pdf), (s), strlen(s))
+
# define pdf_print_resname_prefix(pdf) do { \
if (pdf->resname_prefix != NULL) \
- pdf_puts(pdf,pdf->resname_prefix); \
+ pdf_puts(pdf, pdf->resname_prefix); \
} while (0)
-extern void pdf_print_fw_int(PDF, longinteger, int);
-extern void pdf_out_bytes(PDF, longinteger, int);
extern void pdf_int_entry(PDF, const char *, int);
extern void pdf_int_entry_ln(PDF, const char *, int);
extern void pdf_indirect(PDF, const char *, int);
@@ -173,23 +179,13 @@ extern void pdf_print_rect_spec(PDF, halfword);
extern void pdf_rectangle(PDF, halfword);
extern void pdf_begin_obj(PDF, int, int);
-extern void pdf_new_obj(PDF, int, int, int);
+extern int pdf_new_obj(PDF, int, int, int);
extern void pdf_end_obj(PDF);
extern void pdf_begin_dict(PDF, int, int);
-extern void pdf_new_dict(PDF, int, int, int);
+extern int pdf_new_dict(PDF, int, int, int);
extern void pdf_end_dict(PDF);
-extern void pdf_os_switch(PDF pdf, boolean pdf_os);
-extern void pdf_os_prepare_obj(PDF pdf, int i, int pdf_os_level);
-extern void pdf_os_write_objstream(PDF);
-
-extern void write_stream_length(PDF, int, longinteger);
-
-extern void print_creation_date(PDF);
-extern void print_mod_date(PDF);
-extern void print_ID(PDF, const char *);
-
extern void remove_pdffile(PDF);
extern int fb_offset(PDF);
@@ -198,12 +194,11 @@ extern void fb_putchar(PDF, eight_bits);
extern void fb_seek(PDF, int);
extern void fb_free(PDF);
-extern void write_zip(PDF, boolean);
extern void zip_free(PDF);
/* functions that do not output stuff */
-extern scaled round_xn_over_d(scaled x, int n, int d);
+extern scaled round_xn_over_d(scaled x, int n, unsigned int d);
extern char *convertStringToPDFString(const char *in, int len);
extern void init_start_time(PDF);
@@ -215,8 +210,9 @@ extern void check_o_mode(PDF pdf, const char *s, int o_mode, boolean errorflag);
extern void set_job_id(PDF, int, int, int, int);
extern char *get_resname_prefix(PDF);
-extern void pdf_begin_page(PDF pdf, boolean shipping_page);
-extern void pdf_end_page(PDF pdf, boolean shipping_page);
+extern void pdf_begin_page(PDF pdf);
+extern void pdf_end_page(PDF pdf);
+extern void print_pdf_table_string(PDF pdf, const char *s);
extern void fix_o_mode(PDF pdf);
extern void ensure_output_state(PDF pdf, output_state s);
@@ -227,13 +223,10 @@ extern halfword pdf_catalog_toks; /* additional keys of Catalog dictionary
extern halfword pdf_catalog_openaction;
extern halfword pdf_names_toks; /* additional keys of Names dictionary */
extern halfword pdf_trailer_toks; /* additional keys of Trailer dictionary */
-extern halfword pdf_pageattributes_toks; /* additional keys of Page dictionary */
-extern halfword pdf_pageresources_toks; /* additional keys of Resources dictionary */
-extern halfword pdf_pagesattributes_toks; /* additional keys of Pages dictionary */
extern void scan_pdfcatalog(PDF pdf);
extern void finish_pdf_file(PDF pdf, int luatex_version,
str_number luatex_revision);
-extern boolean is_shipping_page;
+extern shipping_mode_e global_shipping_mode;
#endif /* PDFGEN_H */
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w
index 98d318c9ea8..fc25df199e7 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w
@@ -19,14 +19,15 @@
@ @c
static const char _svn_version[] =
- "$Id: pdfgen.w 3638 2010-04-20 14:00:47Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.1/source/texk/web2c/luatexdir/pdf/pdfgen.w $";
+ "$Id: pdfgen.w 4126 2011-04-11 09:34:50Z taco $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfgen.w $";
#include "ptexlib.h"
@ @c
#include <kpathsea/c-dir.h>
#include <kpathsea/c-ctype.h>
+#include "lua/luatex-api.h"
#include "md5.h"
#define is_hex_char isxdigit
@@ -51,10 +52,7 @@ halfword pdf_catalog_toks; /* additional keys of Catalog dictionary */
halfword pdf_catalog_openaction;
halfword pdf_names_toks; /* additional keys of Names dictionary */
halfword pdf_trailer_toks; /* additional keys of Trailer dictionary */
-halfword pdf_pageattributes_toks; /* additional keys of Page dictionary */
-halfword pdf_pageresources_toks; /* additional keys of Resources dictionary */
-halfword pdf_pagesattributes_toks; /* additional keys of Pages dictionary */
-boolean is_shipping_page; /* set to |shipping_page| when |ship_out| starts */
+shipping_mode_e global_shipping_mode = NOT_SHIPPING; /* set to |shipping_mode| when |ship_out| starts */
@ |init_pdf_struct()| is called early, only once, from maincontrol.w
@@ -62,17 +60,17 @@ boolean is_shipping_page; /* set to |shipping_page| when |ship_out| starts
PDF init_pdf_struct(PDF pdf)
{
assert(pdf == NULL);
- pdf = xmalloc(sizeof(pdf_output_file));
+ pdf = xtalloc(1, pdf_output_file);
memset(pdf, 0, sizeof(pdf_output_file));
pdf->o_mode = OMODE_NONE; /* will be set by |fix_o_mode()| */
pdf->o_state = ST_INITIAL;
- pdf->os_obj = xmalloc(pdf_os_max_objs * sizeof(os_obj_data));
+ pdf->os_obj = xtalloc(pdf_os_max_objs, os_obj_data);
pdf->os_buf_size = inf_pdf_os_buf_size;
- pdf->os_buf = xmalloc((unsigned) pdf->os_buf_size * sizeof(unsigned char));
+ pdf->os_buf = xtalloc(pdf->os_buf_size, unsigned char);
pdf->op_buf_size = inf_pdf_op_buf_size;
- pdf->op_buf = xmalloc((unsigned) pdf->op_buf_size * sizeof(unsigned char));
+ pdf->op_buf = xtalloc(pdf->op_buf_size, unsigned char);
pdf->buf_size = pdf->op_buf_size;
pdf->buf = pdf->op_buf;
@@ -80,20 +78,18 @@ PDF init_pdf_struct(PDF pdf)
/* Sometimes it is neccesary to allocate memory for PDF output that cannot
be deallocated then, so we use |mem| for this purpose. */
pdf->mem_size = inf_pdf_mem_size; /* allocated size of |mem| array */
- pdf->mem = xmalloc((unsigned) ((unsigned) pdf->mem_size * sizeof(int)));
+ pdf->mem = xtalloc(pdf->mem_size, int);
pdf->mem_ptr = 1; /* the first word is not used so we can use zero as a value for testing
whether a pointer to |mem| is valid */
pdf->pstruct = NULL;
- pdf->posstruct = xmalloc(sizeof(posstructure));
+ pdf->posstruct = xtalloc(1, posstructure);
pdf->posstruct->pos.h = 0;
pdf->posstruct->pos.v = 0;
pdf->posstruct->dir = dir_TLT;
pdf->obj_tab_size = (unsigned) inf_obj_tab_size; /* allocated size of |obj_tab| array */
- pdf->obj_tab = xmalloc((unsigned)
- ((unsigned) (pdf->obj_tab_size + 1) *
- sizeof(obj_entry)));
+ pdf->obj_tab = xtalloc(pdf->obj_tab_size + 1, obj_entry);
memset(pdf->obj_tab, 0, sizeof(obj_entry));
pdf->minor_version = -1; /* unset */
@@ -114,27 +110,27 @@ PDF init_pdf_struct(PDF pdf)
pdf->page_resources = NULL;
init_pdf_pagecalculations(pdf);
+ pdf->pdflua_ref = new_pdflua();
return pdf;
}
@ @c
-static void pdf_shipout_begin(boolean shipping_page)
+static void pdf_shipout_begin()
{
pos_stack_used = 0; /* start with empty stack */
- page_mode = shipping_page;
- if (shipping_page) {
+ if (global_shipping_mode == SHIPPING_PAGE) {
colorstackpagestart();
}
}
-static void pdf_shipout_end(boolean shipping_page)
+static void pdf_shipout_end()
{
if (pos_stack_used > 0) {
pdftex_fail("%u unmatched \\pdfsave after %s shipout",
(unsigned int) pos_stack_used,
- ((shipping_page) ? "page" : "form"));
+ ((global_shipping_mode == SHIPPING_PAGE) ? "page" : "form"));
}
}
@@ -163,33 +159,36 @@ int pdf_get_mem(PDF pdf, int s)
return ret;
}
+@ |get_o_mode| translates from |pdf_output| to |o_mode|.
+
+@c
+static output_mode get_o_mode()
+{
+ output_mode o_mode;
+ if (pdf_output > 0) {
+ if (pdf_output == 2009)
+ o_mode = OMODE_LUA;
+ else
+ o_mode = OMODE_PDF;
+ } else
+ o_mode = OMODE_DVI;
+ return o_mode;
+}
@ |fix_o_mode| freezes |pdf->o_mode| as soon as anything goes through
the backend, be it \.{PDF}, \.{DVI}, or \.{Lua}.
@c
-#define pdf_output int_par(pdf_output_code)
-
void fix_o_mode(PDF pdf)
{
- static int fixed_pdf_output = 0;
- if (pdf->o_mode == OMODE_NONE) {
- if (pdf_output > 0) {
- if (pdf_output == 2009)
- pdf->o_mode = OMODE_LUA;
- else
- pdf->o_mode = OMODE_PDF;
- } else
- pdf->o_mode = OMODE_DVI;
- fixed_pdf_output = pdf_output;
- pdf_output_value = pdf_output;
- } else if (pdf_output != fixed_pdf_output) {
+ output_mode o_mode = get_o_mode();
+ if (pdf->o_mode == OMODE_NONE)
+ pdf->o_mode = o_mode;
+ else if (pdf->o_mode != o_mode)
pdf_error("setup",
"\\pdfoutput can only be changed before anything is written to the output");
- }
}
-
@ This ensures that |pdfminorversion| is set only before any bytes have
been written to the generated \.{PDF} file. Here also all variables for
\.{PDF} output are initialized, the \.{PDF} file is opened by |ensure_pdf_open|,
@@ -214,10 +213,10 @@ void fix_pdf_minorversion(PDF pdf)
pdf->minor_version = pdf_minor_version;
} else {
/* Check that variables for \.{PDF} output are unchanged */
- if (pdf->minor_version != int_par(pdf_minor_version_code))
+ if (pdf->minor_version != pdf_minor_version)
pdf_error("setup",
"\\pdfminorversion cannot be changed after data is written to the PDF file");
- if (pdf->draftmode != int_par(pdf_draftmode_code))
+ if (pdf->draftmode != pdf_draftmode)
pdf_error("setup",
"\\pdfdraftmode cannot be changed after data is written to the PDF file");
}
@@ -227,19 +226,91 @@ void fix_pdf_minorversion(PDF pdf)
}
}
+@ @c
+#define ZIP_BUF_SIZE 32768
+
+#define check_err(f, fn) \
+ if (f != Z_OK) \
+ pdftex_fail("zlib: %s() failed (error code %d)", fn, f)
+
+@ @c
+static void write_zip(PDF pdf)
+{
+ int flush, err = Z_OK;
+ uInt zip_len;
+ z_stream *s = pdf->c_stream;
+ boolean finish = pdf->zip_write_state == zip_finish;
+ assert(pdf->compress_level > 0);
+ /* This was just to suppress the filename report in |pdftex_fail|
+ but zlib errors are rare enough (especially now that the
+ compress level is fixed) that I don't care about the slightly
+ ugly error message that could result.
+ */
+#if 0
+ cur_file_name = NULL;
+#endif
+ if (pdf->stream_length == 0) {
+ if (s == NULL) {
+ s = pdf->c_stream = xtalloc(1, z_stream);
+ s->zalloc = (alloc_func) 0;
+ s->zfree = (free_func) 0;
+ s->opaque = (voidpf) 0;
+ check_err(deflateInit(s, pdf->compress_level), "deflateInit");
+ assert(pdf->zipbuf == NULL);
+ pdf->zipbuf = xtalloc(ZIP_BUF_SIZE, char);
+ } else
+ check_err(deflateReset(s), "deflateReset");
+ s->next_out = (Bytef *) pdf->zipbuf;
+ s->avail_out = ZIP_BUF_SIZE;
+ }
+ assert(s != NULL);
+ assert(pdf->zipbuf != NULL);
+ s->next_in = pdf->buf;
+ s->avail_in = (uInt) pdf->ptr;
+ while (true) {
+ if (s->avail_out == 0 || (finish && s->avail_out < ZIP_BUF_SIZE)) {
+ zip_len = ZIP_BUF_SIZE - s->avail_out;
+ pdf->gone += (off_t) xfwrite(pdf->zipbuf, 1, zip_len, pdf->file);
+ pdf->last_byte = pdf->zipbuf[zip_len - 1];
+ s->next_out = (Bytef *) pdf->zipbuf;
+ s->avail_out = ZIP_BUF_SIZE;
+ }
+ if (finish) {
+ if (err == Z_STREAM_END) {
+ assert(s->avail_in == 0);
+ assert(s->avail_out == ZIP_BUF_SIZE);
+ xfflush(pdf->file);
+ break;
+ }
+ flush = Z_FINISH;
+ } else {
+ if (s->avail_in == 0)
+ break;
+ flush = Z_NO_FLUSH;
+ }
+ err = deflate(s, flush);
+ if (err != Z_OK && err != Z_STREAM_END)
+ pdftex_fail("zlib: deflate() failed (error code %d)", err);
+ }
+ pdf->stream_length = (off_t) s->total_out;
+}
+
+@ @c
+void zip_free(PDF pdf)
+{
+ if (pdf->zipbuf != NULL) {
+ check_err(deflateEnd(pdf->c_stream), "deflateEnd");
+ xfree(pdf->zipbuf);
+ }
+ xfree(pdf->c_stream);
+}
+
@ The PDF buffer is flushed by calling |pdf_flush|, which checks the
variable |zip_write_state| and will compress the buffer before flushing if
neccesary. We call |pdf_begin_stream| to begin a stream and |pdf_end_stream|
to finish it. The stream contents will be compressed if compression is turn on.
@c
-static void write_pdf(PDF pdf, int a, int b)
-{
- (void) fwrite((char *) &pdf->buf[a], sizeof(pdf->buf[a]),
- (size_t) ((b) - (a) + 1), pdf->file);
-}
-
-@ @c
void pdf_flush(PDF pdf)
{ /* flush out the |pdf_buf| */
@@ -250,18 +321,19 @@ void pdf_flush(PDF pdf)
case no_zip:
if (pdf->ptr > 0) {
if (pdf->draftmode == 0)
- write_pdf(pdf, 0, pdf->ptr - 1);
+ (void) xfwrite((char *) pdf->buf, sizeof(char),
+ (size_t) pdf->ptr, pdf->file);
pdf->gone += pdf->ptr;
pdf->last_byte = pdf->buf[pdf->ptr - 1];
}
break;
case zip_writing:
if (pdf->draftmode == 0)
- write_zip(pdf, false);
+ write_zip(pdf);
break;
case zip_finish:
if (pdf->draftmode == 0)
- write_zip(pdf, true);
+ write_zip(pdf);
pdf->zip_write_state = no_zip;
break;
}
@@ -275,7 +347,7 @@ void pdf_flush(PDF pdf)
@ switch between PDF stream and object stream mode
@c
-void pdf_os_switch(PDF pdf, boolean pdf_os)
+static void pdf_os_switch(PDF pdf, boolean pdf_os)
{
if (pdf_os && pdf->os_enable) {
if (!pdf->os_mode) { /* back up PDF stream variables */
@@ -299,15 +371,14 @@ void pdf_os_switch(PDF pdf, boolean pdf_os)
@ create new \.{/ObjStm} object if required, and set up cross reference info
@c
-void pdf_os_prepare_obj(PDF pdf, int i, int pdf_os_level)
+static void pdf_os_prepare_obj(PDF pdf, int i, int pdf_os_level)
{
pdf_os_switch(pdf, ((pdf_os_level > 0)
&& (pdf->objcompresslevel >= pdf_os_level)));
if (pdf->os_mode) {
if (pdf->os_cur_objnum == 0) {
- pdf_create_obj(pdf, obj_type_objstm, pdf->sys_obj_ptr + 1);
- pdf->os_cur_objnum = pdf->sys_obj_ptr;
- pdf->obj_ptr--; /* object stream is not accessible to user */
+ pdf->os_cur_objnum =
+ pdf_create_obj(pdf, obj_type_objstm, pdf->obj_ptr + 1);
pdf->os_cntr++; /* only for statistics */
pdf->os_idx = 0;
pdf->ptr = 0; /* start fresh object stream */
@@ -385,30 +456,27 @@ void pdf_print_char(PDF pdf, int c)
pdf_print_escaped(c);
}
-void pdf_print_wide_char(PDF pdf, int c)
+@ @c
+void pdf_out_block(PDF pdf, const char *s, size_t n)
{
- char hex[5];
- snprintf(hex, 5, "%04X", c);
- pdf_room(pdf, 4);
- pdf_quick_out(pdf, (unsigned char) hex[0]);
- pdf_quick_out(pdf, (unsigned char) hex[1]);
- pdf_quick_out(pdf, (unsigned char) hex[2]);
- pdf_quick_out(pdf, (unsigned char) hex[3]);
+ size_t l;
+ do {
+ l = n;
+ if ((int) l > pdf->buf_size)
+ l = (size_t) pdf->buf_size;
+ pdf_room(pdf, (int) l);
+ (void) memcpy(pdf->buf + pdf->ptr, s, l);
+ pdf->ptr += (int) l;
+ s += l;
+ n -= l;
+ } while (n > 0);
}
-@ @c
-void pdf_puts(PDF pdf, const char *s)
+void pdf_print_wide_char(PDF pdf, int c)
{
-
- size_t l = strlen(s);
- if (l < (size_t) pdf->buf_size) {
- pdf_room(pdf, (int) l);
- while (*s != '\0')
- pdf_quick_out(pdf, *s++);
- } else {
- while (*s != '\0')
- pdf_out(pdf, *s++);
- }
+ char hex[5];
+ snprintf(hex, 5, "%04X", c);
+ pdf_out_block(pdf, (const char *) hex, 4);
}
@ @c
@@ -429,15 +497,15 @@ void pdf_printf(PDF pdf, const char *fmt, ...)
@c
void pdf_print(PDF pdf, str_number s)
{
- if (s < number_chars) {
+ const char *ss;
+ size_t l;
+ if (s >= STRING_OFFSET) {
+ ss = (const char *) str_string(s);
+ l = str_length(s);
+ pdf_out_block(pdf, ss, l);
+ } else {
assert(s < 256);
pdf_out(pdf, s);
- } else {
- unsigned char *k, *j;
- j = str_string(s) + str_length(s);
- for (k = str_string(s); k < j; k++) {
- pdf_out(pdf, *k);
- }
}
}
@@ -467,7 +535,7 @@ void pdf_print_int(PDF pdf, longinteger n)
}
do {
dig[k++] = (int) (n % 10);
- n = n / 10;
+ n /= 10;
} while (n != 0);
pdf_room(pdf, k);
while (k-- > 0) {
@@ -493,7 +561,7 @@ void pdf_print_real(PDF pdf, int m, int d)
d--;
}
while (m % 10 == 0)
- m = m / 10;
+ m /= 10;
pdf_print_int(pdf, m);
}
}
@@ -554,6 +622,18 @@ void pdf_begin_stream(PDF pdf)
}
}
+@ @c
+static void write_stream_length(PDF pdf, int length, longinteger offset)
+{
+ if (jobname_cstr == NULL)
+ jobname_cstr = makecstring(job_name);
+ if (pdf->draftmode == 0) {
+ xfseeko(pdf->file, (off_t) offset, SEEK_SET, jobname_cstr);
+ fprintf(pdf->file, "%li", (long int) length);
+ xfseeko(pdf->file, pdf_offset(pdf), SEEK_SET, jobname_cstr);
+ }
+}
+
@ end a stream
@c
void pdf_end_stream(PDF pdf)
@@ -567,8 +647,8 @@ void pdf_end_stream(PDF pdf)
write_stream_length(pdf, (int) pdf->stream_length,
pdf->stream_length_offset);
pdf->seek_write_length = false;
- if (pdf->last_byte != pdf_new_line_char)
- pdf_out(pdf, pdf_new_line_char);
+ if (pdf->last_byte != pdf_newline_char)
+ pdf_out(pdf, pdf_newline_char);
pdf_puts(pdf, "endstream\n");
pdf_end_obj(pdf);
}
@@ -579,7 +659,6 @@ void pdf_remove_last_space(PDF pdf)
pdf->ptr--;
}
-
@ To print |scaled| value to PDF output we need some subroutines to ensure
accurary.
@@ -592,14 +671,16 @@ scaled one_hundred_inch = 7227 * 65536;
/* scaled value corresponds to 1in (rounded to 4736287) */
scaled one_inch = (7227 * 65536 + 50) / 100;
- /* scaled value corresponds to 1truein (rounded!) */
+/* scaled value corresponds to 1truein (rounded!) */
scaled one_true_inch = (7227 * 65536 + 50) / 100;
/* scaled value corresponds to 100bp */
scaled one_hundred_bp = (7227 * 65536) / 72;
/* scaled value corresponds to 1bp (rounded to 65782) */
-scaled one_bp = ((7227 * 65536) / 72 + 50) / 100;
+/* changed on 20110411 to be exactly 65781, as in tex itself,
+ because this value is also used for \pdfpxdimen */
+scaled one_bp = 65781;
/* $10^0..10^9$ */
int ten_pow[10] = {
@@ -612,7 +693,7 @@ digits of precision. It is defined in C because it is a good candidate
for optimizations that are not possible in pascal.
@c
-scaled round_xn_over_d(scaled x, int n, int d)
+scaled round_xn_over_d(scaled x, int n, unsigned int d)
{
boolean positive; /* was |x>=0|? */
unsigned t, u, v; /* intermediate quantities */
@@ -630,7 +711,7 @@ scaled round_xn_over_d(scaled x, int n, int d)
else
u = 0100000 * (u / d) + (v / d);
v = v % d;
- if (2 * v >= (unsigned) d)
+ if (2 * v >= d)
u++;
if (positive)
return (scaled) u;
@@ -703,7 +784,6 @@ void addto_page_resources(PDF pdf, pdf_obj_type t, int k)
void **pp;
pdf_object_list *p, *item = NULL;
assert(pdf != NULL);
- /* assert(obj_type(pdf, k) == t); *//* TODO, not yet strictly true */
re = pdf->page_resources;
assert(re != NULL);
assert(t <= PDF_OBJ_TYPE_MAX);
@@ -726,19 +806,21 @@ void addto_page_resources(PDF pdf, pdf_obj_type t, int k)
("addto_page_resources(): avl_probe() out of memory in insertion");
}
if (pr->list == NULL) {
- item = xmalloc(sizeof(pdf_object_list));
+ item = xtalloc(1, pdf_object_list);
item->link = NULL;
item->info = k;
pr->list = item;
- set_obj_scheduled(pdf, k); /* k is an object number */
+ if (obj_type(pdf, k) == (int)t)
+ set_obj_scheduled(pdf, k); /* k is an object number */
} else {
for (p = pr->list; p->info != k && p->link != NULL; p = p->link);
if (p->info != k) {
- item = xmalloc(sizeof(pdf_object_list));
+ item = xtalloc(1, pdf_object_list);
item->link = NULL;
item->info = k;
p->link = item;
- set_obj_scheduled(pdf, k);
+ if (obj_type(pdf, k) == (int)t)
+ set_obj_scheduled(pdf, k);
}
}
}
@@ -797,38 +879,34 @@ static void destroy_page_resources_tree(PDF pdf)
@* Subroutines to print out various PDF objects.
-@ print out an integer with fixed width; used for outputting cross-reference table
+@ print out an integer |n| with fixed width |w|; used for outputting cross-reference table
@c
-void pdf_print_fw_int(PDF pdf, longinteger n, int w)
+static void pdf_print_fw_int(PDF pdf, longinteger n, size_t w)
{
int k; /* $0\le k\le23$ */
- int dig[24];
- k = 0;
+ unsigned char digits[24];
+ k = (int) w;
do {
- dig[k] = (int) (n % 10);
- n = n / 10;
- k++;
- } while (k != w);
- pdf_room(pdf, k);
- while (k-- > 0)
- pdf_quick_out(pdf, (unsigned char) ('0' + dig[k]));
+ k--;
+ digits[k] = (unsigned char) ('0' + (n % 10));
+ n /= 10;
+ } while (k != 0);
+ pdf_out_block(pdf, (const char *) digits, w);
}
-@ print out an integer as a number of bytes; used for outputting \.{/XRef} cross-reference stream
+@ print out an integer |n| as a fixed number |w| of bytes; used for outputting \.{/XRef} cross-reference stream
@c
-void pdf_out_bytes(PDF pdf, longinteger n, int w)
+static void pdf_out_bytes(PDF pdf, longinteger n, size_t w)
{
int k;
- int bytes[8]; /* digits in a number being output */
- k = 0;
+ unsigned char bytes[8]; /* digits in a number being output */
+ k = (int) w;
do {
- bytes[k] = (int) (n % 256);
- n = n / 256;
- k++;
- } while (k != w);
- pdf_room(pdf, k);
- while (k-- > 0)
- pdf_quick_out(pdf, bytes[k]);
+ k--;
+ bytes[k] = (unsigned char) (n % 256);
+ n /= 256;
+ } while (k != 0);
+ pdf_out_block(pdf, (const char *) bytes, w);
}
@ print out an entry in dictionary with integer value to PDF buffer
@@ -1062,42 +1140,6 @@ void ensure_output_state(PDF pdf, output_state s)
}
}
-@ begin a PDF dictionary object
-@c
-void pdf_begin_dict(PDF pdf, int i, int pdf_os_level)
-{
- ensure_output_state(pdf, ST_HEADER_WRITTEN);
- pdf_os_prepare_obj(pdf, i, pdf_os_level);
- if (!pdf->os_mode) {
- pdf_printf(pdf, "%d 0 obj <<\n", (int) i);
- } else {
- if (pdf->compress_level == 0)
- pdf_printf(pdf, "%% %d 0 obj\n", (int) i); /* debugging help */
- pdf_puts(pdf, "<<\n");
- }
-}
-
-@ begin a new PDF dictionary object
-@c
-void pdf_new_dict(PDF pdf, int t, int i, int pdf_os)
-{
- pdf_create_obj(pdf, t, i);
- pdf_begin_dict(pdf, pdf->obj_ptr, pdf_os);
-}
-
-@ end a PDF dictionary object
-@c
-void pdf_end_dict(PDF pdf)
-{
- if (pdf->os_mode) {
- pdf_puts(pdf, ">>\n");
- if (pdf->os_idx == pdf_os_max_objs - 1)
- pdf_os_write_objstream(pdf);
- } else {
- pdf_puts(pdf, ">> endobj\n");
- }
-}
-
@ Write out an accumulated object stream.
First the object number and byte offset pairs are generated
@@ -1108,7 +1150,7 @@ copied to the PDF output buffer, where also compression is done.
When calling this procedure, |pdf_os_mode| must be |true|.
@c
-void pdf_os_write_objstream(PDF pdf)
+static void pdf_os_write_objstream(PDF pdf)
{
halfword i, j, p, q;
if (pdf->os_cur_objnum == 0) /* no object stream started */
@@ -1120,7 +1162,7 @@ void pdf_os_write_objstream(PDF pdf)
pdf_printf(pdf, "%d %d", (int) pdf->os_obj[i].num,
(int) pdf->os_obj[i].off);
if (j == 9) { /* print out in groups of ten for better readability */
- pdf_out(pdf, pdf_new_line_char);
+ pdf_out(pdf, pdf_newline_char);
j = 0;
} else {
pdf_out(pdf, ' ');
@@ -1128,19 +1170,16 @@ void pdf_os_write_objstream(PDF pdf)
}
i++;
}
- pdf->buf[pdf->ptr - 1] = pdf_new_line_char; /* no risk of flush, as we are in |pdf_os_mode| */
+ pdf->buf[pdf->ptr - 1] = pdf_newline_char; /* no risk of flush, as we are in |pdf_os_mode| */
q = pdf->ptr;
pdf_begin_dict(pdf, pdf->os_cur_objnum, 0); /* switch to PDF stream writing */
pdf_puts(pdf, "/Type /ObjStm\n");
pdf_printf(pdf, "/N %d\n", (int) (pdf->os_idx + 1));
pdf_printf(pdf, "/First %d\n", (int) (q - p));
pdf_begin_stream(pdf);
- pdf_room(pdf, q - p); /* should always fit into the PDF output buffer */
- i = p;
- while (i < q) { /* write object number and byte offset pairs */
- pdf_quick_out(pdf, pdf->os_buf[i]);
- i++;
- }
+ /* write object number and byte offset pairs;
+ |q - p| should always fit into the PDF output buffer */
+ pdf_out_block(pdf, (const char *) (pdf->os_buf + p), (size_t) (q - p));
i = 0;
while (i < p) {
q = i + pdf->buf_size;
@@ -1156,6 +1195,43 @@ void pdf_os_write_objstream(PDF pdf)
pdf->os_cur_objnum = 0; /* to force object stream generation next time */
}
+@ begin a PDF dictionary object
+@c
+void pdf_begin_dict(PDF pdf, int i, int pdf_os_level)
+{
+ ensure_output_state(pdf, ST_HEADER_WRITTEN);
+ pdf_os_prepare_obj(pdf, i, pdf_os_level);
+ if (!pdf->os_mode) {
+ pdf_printf(pdf, "%d 0 obj\n<<\n", (int) i);
+ } else {
+ if (pdf->compress_level == 0)
+ pdf_printf(pdf, "%% %d 0 obj\n", (int) i); /* debugging help */
+ pdf_puts(pdf, "<<\n");
+ }
+}
+
+@ begin a new PDF dictionary object
+@c
+int pdf_new_dict(PDF pdf, int t, int i, int pdf_os_level)
+{
+ int k = pdf_create_obj(pdf, t, i);
+ pdf_begin_dict(pdf, k, pdf_os_level);
+ return k;
+}
+
+@ end a PDF dictionary object
+@c
+void pdf_end_dict(PDF pdf)
+{
+ if (pdf->os_mode) {
+ pdf_puts(pdf, ">>\n");
+ if (pdf->os_idx == pdf_os_max_objs - 1)
+ pdf_os_write_objstream(pdf);
+ } else {
+ pdf_puts(pdf, ">>\nendobj\n");
+ }
+}
+
@ begin a PDF object
@c
void pdf_begin_obj(PDF pdf, int i, int pdf_os_level)
@@ -1171,10 +1247,11 @@ void pdf_begin_obj(PDF pdf, int i, int pdf_os_level)
@ begin a new PDF object
@c
-void pdf_new_obj(PDF pdf, int t, int i, int pdf_os)
+int pdf_new_obj(PDF pdf, int t, int i, int pdf_os_level)
{
- pdf_create_obj(pdf, t, i);
- pdf_begin_obj(pdf, pdf->obj_ptr, pdf_os);
+ int k = pdf_create_obj(pdf, t, i);
+ pdf_begin_obj(pdf, k, pdf_os_level);
+ return k;
}
@ end a PDF object
@@ -1189,18 +1266,6 @@ void pdf_end_obj(PDF pdf)
}
}
-@ @c
-void write_stream_length(PDF pdf, int length, longinteger offset)
-{
- if (jobname_cstr == NULL)
- jobname_cstr = makecstring(job_name);
- if (pdf->draftmode == 0) {
- xfseeko(pdf->file, (off_t) offset, SEEK_SET, jobname_cstr);
- fprintf(pdf->file, "%li", (long int) length);
- xfseeko(pdf->file, pdf_offset(pdf), SEEK_SET, jobname_cstr);
- }
-}
-
@ Converts any string given in in in an allowed PDF string which can be
handled by printf et.al.: \.{\\} is escaped to \.{\\\\}, parenthesis are escaped and
control characters are octal encoded.
@@ -1297,7 +1362,7 @@ static void convertStringToHexString(const char *in, char *out, int lin)
implementation using just the first two items.
@c
-void print_ID(PDF pdf, const char *file_name)
+static void print_ID(PDF pdf, const char *file_name)
{
time_t t;
size_t size;
@@ -1440,14 +1505,14 @@ void init_start_time(PDF pdf)
}
@ @c
-void print_creation_date(PDF pdf)
+static void print_creation_date(PDF pdf)
{
init_start_time(pdf);
pdf_printf(pdf, "/CreationDate (%s)\n", pdf->start_time_str);
}
@ @c
-void print_mod_date(PDF pdf)
+static void print_mod_date(PDF pdf)
{
init_start_time(pdf);
pdf_printf(pdf, "/ModDate (%s)\n", pdf->start_time_str);
@@ -1534,82 +1599,6 @@ void fb_free(PDF pdf)
}
@ @c
-#define ZIP_BUF_SIZE 32768
-
-#define check_err(f, fn) \
- if (f != Z_OK) \
- pdftex_fail("zlib: %s() failed (error code %d)", fn, f)
-
-@ @c
-void write_zip(PDF pdf, boolean finish)
-{
- int err;
- int level = pdf->compress_level;
- assert(level > 0);
- /* This was just to suppress the filename report in |pdftex_fail|
- but zlib errors are rare enough (especially now that the
- compress level is fixed) that I don't care about the slightly
- ugly error message that could result.
- */
-#if 0
- cur_file_name = NULL;
-#endif
- if (pdf->stream_length == 0) {
- if (pdf->zipbuf == NULL) {
- pdf->zipbuf = xtalloc(ZIP_BUF_SIZE, char);
- pdf->c_stream.zalloc = (alloc_func) 0;
- pdf->c_stream.zfree = (free_func) 0;
- pdf->c_stream.opaque = (voidpf) 0;
- check_err(deflateInit(&pdf->c_stream, level), "deflateInit");
- } else {
- check_err(deflateReset(&pdf->c_stream), "deflateReset");
- }
- pdf->c_stream.next_out = (Bytef *) pdf->zipbuf;
- pdf->c_stream.avail_out = ZIP_BUF_SIZE;
- }
- assert(pdf->zipbuf != NULL);
- pdf->c_stream.next_in = pdf->buf;
- pdf->c_stream.avail_in = (uInt) pdf->ptr;
- for (;;) {
- if (pdf->c_stream.avail_out == 0) {
- pdf->gone =
- pdf->gone + (off_t) xfwrite(pdf->zipbuf, 1, ZIP_BUF_SIZE,
- pdf->file);
- pdf->last_byte = pdf->zipbuf[ZIP_BUF_SIZE - 1]; /* not needed */
- pdf->c_stream.next_out = (Bytef *) pdf->zipbuf;
- pdf->c_stream.avail_out = ZIP_BUF_SIZE;
- }
- err = deflate(&pdf->c_stream, finish ? Z_FINISH : Z_NO_FLUSH);
- if (finish && err == Z_STREAM_END)
- break;
- check_err(err, "deflate");
- if (!finish && pdf->c_stream.avail_in == 0)
- break;
- }
- if (finish) {
- if (pdf->c_stream.avail_out < ZIP_BUF_SIZE) { /* at least one byte has been output */
- pdf->gone = pdf->gone +
- (off_t) xfwrite(pdf->zipbuf, 1,
- (size_t) (ZIP_BUF_SIZE -
- pdf->c_stream.avail_out), pdf->file);
- pdf->last_byte =
- pdf->zipbuf[ZIP_BUF_SIZE - pdf->c_stream.avail_out - 1];
- }
- xfflush(pdf->file);
- }
- pdf->stream_length = (off_t) pdf->c_stream.total_out;
-}
-
-@ @c
-void zip_free(PDF pdf)
-{
- if (pdf->zipbuf != NULL) {
- check_err(deflateEnd(&pdf->c_stream), "deflateEnd");
- free(pdf->zipbuf);
- }
-}
-
-@ @c
void pdf_error(const char *t, const char *p)
{
normalize_selector();
@@ -1661,15 +1650,9 @@ void check_o_mode(PDF pdf, const char *s, int o_mode_bitpattern, boolean strict)
in possibly wrong state until real output, ok.
*/
- if (pdf->o_mode == OMODE_NONE) {
- if (pdf_output > 0) {
- if (pdf_output == 2009)
- o_mode = OMODE_LUA;
- else
- o_mode = OMODE_PDF;
- } else
- o_mode = OMODE_DVI;
- } else
+ if (pdf->o_mode == OMODE_NONE)
+ o_mode = get_o_mode();
+ else
o_mode = pdf->o_mode;
if (!((1 << o_mode) & o_mode_bitpattern)) { /* warning or error */
switch (o_mode) {
@@ -1750,26 +1733,27 @@ char *get_resname_prefix(PDF pdf)
#define pdf_xform_attr equiv(pdf_xform_attr_loc)
#define pdf_xform_resources equiv(pdf_xform_resources_loc)
-void pdf_begin_page(PDF pdf, boolean shipping_page)
+void pdf_begin_page(PDF pdf)
{
- scaled form_margin = one_bp;
+ scaled form_margin = 0; /* was one_bp until SVN4066 */
ensure_output_state(pdf, ST_HEADER_WRITTEN);
init_pdf_pagecalculations(pdf);
if (pdf->page_resources == NULL) {
- pdf->page_resources = xmalloc(sizeof(pdf_resource_struct));
+ pdf->page_resources = xtalloc(1, pdf_resource_struct);
pdf->page_resources->resources_tree = NULL;
}
pdf->page_resources->last_resources = pdf_new_objnum(pdf);
reset_page_resources(pdf);
- if (shipping_page) {
+ if (global_shipping_mode == SHIPPING_PAGE) {
pdf->last_page = get_obj(pdf, obj_type_page, total_pages + 1, 0);
set_obj_aux(pdf, pdf->last_page, 1); /* mark that this page has been created */
- pdf_new_dict(pdf, obj_type_pagestream, 0, 0);
- pdf->last_stream = pdf->obj_ptr;
+ pdf->last_stream = pdf_new_dict(pdf, obj_type_pagestream, 0, 0);
pdf->last_thread = null;
+ pdflua_begin_page(pdf);
} else {
+ assert(global_shipping_mode == SHIPPING_FORM);
pdf_begin_dict(pdf, pdf_cur_form, 0);
pdf->last_stream = pdf_cur_form;
@@ -1798,7 +1782,7 @@ void pdf_begin_page(PDF pdf, boolean shipping_page)
}
/* Start stream of page/form contents */
pdf_begin_stream(pdf);
- if (shipping_page) {
+ if (global_shipping_mode == SHIPPING_PAGE) {
/* Adjust transformation matrix for the magnification ratio */
if (mag != 1000) {
pdf_print_real(pdf, mag, 3);
@@ -1807,35 +1791,52 @@ void pdf_begin_page(PDF pdf, boolean shipping_page)
pdf_puts(pdf, " 0 0 cm\n");
}
}
- pdf_shipout_begin(shipping_page);
+ pdf_shipout_begin();
- if (shipping_page)
+ if (global_shipping_mode == SHIPPING_PAGE)
pdf_out_colorstack_startpage(pdf);
}
@ @c
+void print_pdf_table_string(PDF pdf, const char *s)
+{
+ size_t len;
+ const char *ls;
+ lua_getglobal(Luas, "pdf"); /* t ... */
+ lua_pushstring(Luas, s); /* s t ... */
+ lua_gettable(Luas, -2); /* s? t ... */
+ if (lua_isstring(Luas, -1)) { /* s t ... */
+ ls = lua_tolstring(Luas, -1, &len);
+ pdf_out_block(pdf, ls, len);
+ pdf_out(pdf, '\n');
+ }
+ lua_pop(Luas, 2); /* ... */
+}
+
+@ @c
#define pdf_page_attr equiv(pdf_page_attr_loc)
#define pdf_page_resources equiv(pdf_page_resources_loc)
-void pdf_end_page(PDF pdf, boolean shipping_page)
+void pdf_end_page(PDF pdf)
{
- int j;
+ int j, annots = 0, beads = 0;
pdf_resource_struct *res_p = pdf->page_resources;
pdf_resource_struct local_page_resources;
- pdf_object_list *ol, *ol1;
+ pdf_object_list *annot_list, *bead_list, *link_list, *ol, *ol1;
scaledpos save_cur_page_size; /* to save |cur_page_size| during flushing pending forms */
+ shipping_mode_e save_shipping_mode;
int procset = PROCSET_PDF;
/* Finish stream of page/form contents */
pdf_goto_pagemode(pdf);
- pdf_shipout_end(shipping_page);
+ pdf_shipout_end();
pdf_end_stream(pdf);
- if (shipping_page) {
- /* Write out page object */
+ if (global_shipping_mode == SHIPPING_PAGE) {
+ pdf->last_pages = pdf_do_page_divert(pdf, pdf->last_page, 0);
+ /* Write out /Page object */
pdf_begin_dict(pdf, pdf->last_page, 1);
- pdf->last_pages = pdf_do_page_divert(pdf, pdf->last_page, 0);
pdf_puts(pdf, "/Type /Page\n");
pdf_indirect_ln(pdf, "Contents", pdf->last_stream);
pdf_indirect_ln(pdf, "Resources", res_p->last_resources);
@@ -1846,33 +1847,57 @@ void pdf_end_page(PDF pdf, boolean shipping_page)
pdf_puts(pdf, "]\n");
if (pdf_page_attr != null)
pdf_print_toks_ln(pdf, pdf_page_attr);
- if (pdf_pageattributes_toks != null) /* from Lua */
- pdf_print_toks_ln(pdf, pdf_pageattributes_toks);
+ print_pdf_table_string(pdf, "pageattributes");
pdf_indirect_ln(pdf, "Parent", pdf->last_pages);
- if (pdf->img_page_group_val > 0) {
+ if (pdf->img_page_group_val != 0) {
+ assert(pdf->img_page_group_val > 0);
pdf_printf(pdf, "/Group %d 0 R\n", pdf->img_page_group_val);
- pdf->img_page_group_val = 0;
}
+ annot_list = get_page_resources_list(pdf, obj_type_annot);
+ link_list = get_page_resources_list(pdf, obj_type_link);
+ if (annot_list != NULL || link_list != NULL) {
+ annots = pdf_create_obj(pdf, obj_type_annots, 0);
+ pdf_indirect_ln(pdf, "Annots", annots);
+ }
+ bead_list = get_page_resources_list(pdf, obj_type_bead);
+ if (bead_list != NULL) {
+ beads = pdf_create_obj(pdf, obj_type_beads, 0);
+ pdf_indirect_ln(pdf, "B", beads);
+ }
+ pdf_end_dict(pdf);
+ pdflua_end_page(pdf, annots, beads);
+
+ pdf->img_page_group_val = 0;
+
/* Generate array of annotations or beads in page */
- ol = get_page_resources_list(pdf, obj_type_annot);
- ol1 = get_page_resources_list(pdf, obj_type_link);
- if (ol != NULL || ol1 != NULL) {
- pdf_puts(pdf, "/Annots [ ");
- while (ol != NULL) {
- assert(ol->info > 0);
- pdf_print_int(pdf, ol->info);
+ if (annot_list != NULL || link_list != NULL) {
+ pdf_begin_obj(pdf, annots, 1);
+ pdf_puts(pdf, "[");
+ while (annot_list != NULL) {
+ assert(annot_list->info > 0);
+ pdf_print_int(pdf, annot_list->info);
pdf_puts(pdf, " 0 R ");
- ol = ol->link;
+ annot_list = annot_list->link;
}
- while (ol1 != NULL) {
- pdf_print_int(pdf, ol1->info);
+ while (link_list != NULL) {
+ pdf_print_int(pdf, link_list->info);
pdf_puts(pdf, " 0 R ");
- ol1 = ol1->link;
+ link_list = link_list->link;
}
pdf_puts(pdf, "]\n");
+ pdf_end_obj(pdf);
+ }
+ if (bead_list != NULL) {
+ pdf_begin_dict(pdf, beads, 1);
+ pdf_puts(pdf, "[");
+ while (bead_list != NULL) {
+ pdf_print_int(pdf, bead_list->info);
+ pdf_printf(pdf, " 0 R ");
+ bead_list = bead_list->link;
+ }
+ pdf_printf(pdf, "]\n");
+ pdf_end_dict(pdf);
}
- print_beads_list(pdf);
- pdf_end_dict(pdf);
}
/* Write out resource lists */
@@ -1894,11 +1919,13 @@ void pdf_end_page(PDF pdf, boolean shipping_page)
if (!is_obj_written(pdf, ol->info)) {
pdf_cur_form = ol->info;
save_cur_page_size = cur_page_size;
+ save_shipping_mode = global_shipping_mode;
pdf->page_resources = &local_page_resources;
local_page_resources.resources_tree = NULL;
- ship_out(pdf, obj_xform_box(pdf, pdf_cur_form), false);
+ ship_out(pdf, obj_xform_box(pdf, pdf_cur_form), SHIPPING_FORM);
/* Restore page size and page resources */
cur_page_size = save_cur_page_size;
+ global_shipping_mode = save_shipping_mode;
destroy_page_resources_tree(pdf);
pdf->page_resources = res_p;
}
@@ -1913,12 +1940,12 @@ void pdf_end_page(PDF pdf, boolean shipping_page)
ol = ol->link;
}
- if (shipping_page) {
+ if (global_shipping_mode == SHIPPING_PAGE) {
/* Write out pending PDF marks */
/* Write out PDF annotations */
ol = get_page_resources_list(pdf, obj_type_annot);
while (ol != NULL) {
- if (ol->info > 0) {
+ if (ol->info > 0 && obj_type(pdf, ol->info) == obj_type_annot) {
j = obj_annot_ptr(pdf, ol->info); /* |j| points to |pdf_annot_node| */
pdf_begin_dict(pdf, ol->info, 1);
pdf_puts(pdf, "/Type /Annot\n");
@@ -1967,11 +1994,10 @@ void pdf_end_page(PDF pdf, boolean shipping_page)
/* Write out resources dictionary */
pdf_begin_dict(pdf, res_p->last_resources, 1);
/* Print additional resources */
- if (shipping_page) {
+ if (global_shipping_mode == SHIPPING_PAGE) {
if (pdf_page_resources != null)
pdf_print_toks_ln(pdf, pdf_page_resources);
- if (pdf_pageresources_toks != null) /* from Lua */
- pdf_print_toks_ln(pdf, pdf_pageresources_toks);
+ print_pdf_table_string(pdf, "pageresources");
} else {
if (pdf_xform_resources != null)
pdf_print_toks_ln(pdf, pdf_xform_resources);
@@ -2045,9 +2071,6 @@ void pdf_end_page(PDF pdf, boolean shipping_page)
@* Finishing the PDF output file.
-@ @c
-#define pdf_gen_tounicode int_par(pdf_gen_tounicode_code)
-
@ Destinations that have been referenced but don't exists have
|obj_dest_ptr=null|. Leaving them undefined might cause troubles for
PDF browsers, so we need to fix them; they point to the last page.
@@ -2111,13 +2134,14 @@ static boolean substr_of_str(const char *s, const char *t)
return true;
}
-static void pdf_print_info(PDF pdf, int luatex_version, str_number luatex_revision)
+static int pdf_print_info(PDF pdf, int luatex_version,
+ str_number luatex_revision)
{ /* print info object */
boolean creator_given, producer_given, creationdate_given, moddate_given,
trapped_given;
char *s = NULL;
- int len = 0;
- pdf_new_dict(pdf, obj_type_others, 0, 3); /* keep Info readable unless explicitely forced */
+ int k, len = 0;
+ k = pdf_new_dict(pdf, obj_type_info, 0, 3); /* keep Info readable unless explicitely forced */
creator_given = false;
producer_given = false;
creationdate_given = false;
@@ -2140,7 +2164,6 @@ static void pdf_print_info(PDF pdf, int luatex_version, str_number luatex_revisi
pdf_out(pdf, '.');
pdf_print(pdf, luatex_revision);
pdf_puts(pdf, ")\n");
-
}
if (pdf_info_toks != null) {
if (len > 0) {
@@ -2164,6 +2187,7 @@ static void pdf_print_info(PDF pdf, int luatex_version, str_number luatex_revisi
}
pdf_str_entry_ln(pdf, "PTEX.Fullbanner", pdftex_banner);
pdf_end_dict(pdf);
+ return k;
}
static void build_free_object_list(PDF pdf)
@@ -2171,7 +2195,7 @@ static void build_free_object_list(PDF pdf)
int k, l;
l = 0;
set_obj_fresh(pdf, l); /* null object at begin of list of free objects */
- for (k = 1; k <= pdf->sys_obj_ptr; k++) {
+ for (k = 1; k <= pdf->obj_ptr; k++) {
if (!is_obj_written(pdf, k)) {
set_obj_link(pdf, l, k);
l = k;
@@ -2188,9 +2212,10 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
{
boolean res;
int i, j, k;
- int root, outlines, threads, names_tree;
- int xref_offset_width;
+ int root, info, xref_stm = 0, outlines, threads, names_tree;
+ size_t xref_offset_width;
int callback_id = callback_defined(stop_run_callback);
+ int callback_id1 = callback_defined(finish_pdffile_callback);
if (total_pages == 0) {
if (callback_id == 0) {
@@ -2204,6 +2229,8 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
if (pdf->draftmode == 0) {
pdf_flush(pdf); /* to make sure that the output file name has been already created */
flush_jbig2_page0_objects(pdf); /* flush page 0 objects from JBIG2 images, if any */
+ if (callback_id1 > 0)
+ res = run_callback(callback_id1, "->");
check_nonexisting_pages(pdf);
check_nonexisting_destinations(pdf);
@@ -2250,6 +2277,7 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
write_fontstuff(pdf);
pdf->last_pages = output_pages_tree(pdf);
+ pdflua_output_pages_tree(pdf);
/* Output outlines */
outlines = print_outlines(pdf);
@@ -2265,8 +2293,7 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
/* Output article threads */
if (pdf->head_tab[obj_type_thread] != 0) {
- pdf_new_obj(pdf, obj_type_others, 0, 1);
- threads = pdf->obj_ptr;
+ threads = pdf_new_obj(pdf, obj_type_others, 0, 1);
pdf_out(pdf, '[');
k = pdf->head_tab[obj_type_thread];
while (k != 0) {
@@ -2286,9 +2313,8 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
threads = 0;
}
- /* Output the catalog object */
- pdf_new_dict(pdf, obj_type_others, 0, 1);
- root = pdf->obj_ptr;
+ /* Output the /Catalog object */
+ root = pdf_new_dict(pdf, obj_type_catalog, 0, 1);
pdf_puts(pdf, "/Type /Catalog\n");
pdf_indirect_ln(pdf, "Pages", pdf->last_pages);
if (threads != 0)
@@ -2306,7 +2332,8 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
pdf_indirect_ln(pdf, "OpenAction", pdf_catalog_openaction);
pdf_end_dict(pdf);
- pdf_print_info(pdf, luatex_version, luatex_revision); /* last candidate for object stream */
+ /* last candidate for object stream */
+ info = pdf_print_info(pdf, luatex_version, luatex_revision); /* final object for pdf->os_enable == false */
if (pdf->os_enable) {
pdf_os_switch(pdf, true);
@@ -2314,12 +2341,12 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
pdf_flush(pdf);
pdf_os_switch(pdf, false);
/* Output the cross-reference stream dictionary */
- pdf_new_dict(pdf, obj_type_others, 0, 0);
- if ((obj_offset(pdf, pdf->sys_obj_ptr) / 256) > 16777215)
+ xref_stm = pdf_new_dict(pdf, obj_type_others, 0, 0); /* final object for pdf->os_enable == true */
+ if ((obj_offset(pdf, pdf->obj_ptr) / 256) > 16777215)
xref_offset_width = 5;
- else if (obj_offset(pdf, pdf->sys_obj_ptr) > 16777215)
+ else if (obj_offset(pdf, pdf->obj_ptr) > 16777215)
xref_offset_width = 4;
- else if (obj_offset(pdf, pdf->sys_obj_ptr) > 65535)
+ else if (obj_offset(pdf, pdf->obj_ptr) > 65535)
xref_offset_width = 3;
else
xref_offset_width = 2;
@@ -2331,10 +2358,10 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
pdf_puts(pdf, "]\n");
pdf_int_entry_ln(pdf, "Size", pdf->obj_ptr + 1);
pdf_puts(pdf, "/W [1 ");
- pdf_print_int(pdf, xref_offset_width);
+ pdf_print_int(pdf, (int) xref_offset_width);
pdf_puts(pdf, " 1]\n");
pdf_indirect_ln(pdf, "Root", root);
- pdf_indirect_ln(pdf, "Info", pdf->obj_ptr - 1);
+ pdf_indirect_ln(pdf, "Info", info);
if (pdf_trailer_toks != null) {
pdf_print_toks_ln(pdf, pdf_trailer_toks);
delete_token_ref(pdf_trailer_toks);
@@ -2343,7 +2370,7 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
print_ID(pdf, pdf->file_name);
pdf_print_nl(pdf);
pdf_begin_stream(pdf);
- for (k = 0; k <= pdf->sys_obj_ptr; k++) {
+ for (k = 0; k <= pdf->obj_ptr; k++) {
if (!is_obj_written(pdf, k)) { /* a free object */
pdf_out(pdf, 0);
pdf_out_bytes(pdf, obj_link(pdf, k), xref_offset_width);
@@ -2391,9 +2418,9 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
if (!pdf->os_enable) {
pdf_puts(pdf, "trailer\n");
pdf_puts(pdf, "<< ");
- pdf_int_entry_ln(pdf, "Size", pdf->sys_obj_ptr + 1);
+ pdf_int_entry_ln(pdf, "Size", pdf->obj_ptr + 1);
pdf_indirect_ln(pdf, "Root", root);
- pdf_indirect_ln(pdf, "Info", pdf->sys_obj_ptr);
+ pdf_indirect_ln(pdf, "Info", info);
if (pdf_trailer_toks != null) {
pdf_print_toks_ln(pdf, pdf_trailer_toks);
delete_token_ref(pdf_trailer_toks);
@@ -2404,7 +2431,7 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
}
pdf_puts(pdf, "startxref\n");
if (pdf->os_enable)
- pdf_print_int_ln(pdf, obj_offset(pdf, pdf->sys_obj_ptr));
+ pdf_print_int_ln(pdf, obj_offset(pdf, xref_stm));
else
pdf_print_int_ln(pdf, pdf_saved_offset(pdf));
pdf_puts(pdf, "%%EOF\n");
@@ -2470,8 +2497,7 @@ void scan_pdfcatalog(PDF pdf)
} else {
check_o_mode(pdf, "\\pdfcatalog", 1 << OMODE_PDF, true);
p = scan_action(pdf);
- pdf_new_obj(pdf, obj_type_others, 0, 1);
- pdf_catalog_openaction = pdf->obj_ptr;
+ pdf_catalog_openaction = pdf_new_obj(pdf, obj_type_others, 0, 1);
write_action(pdf, p);
pdf_end_obj(pdf);
delete_action_ref(p);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w b/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w
index 6eb6d9fc5b2..6e6c4b26dca 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w
@@ -19,8 +19,8 @@
@ @c
static const char _svn_version[] =
- "$Id: pdfglyph.w 3703 2010-05-27 07:58:34Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.2/source/texk/web2c/luatexdir/pdf/pdfglyph.w $";
+ "$Id: pdfglyph.w 4131 2011-04-11 13:41:26Z taco $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfglyph.w $";
#include "ptexlib.h"
@@ -107,16 +107,17 @@ static void print_tm(PDF pdf, pdffloat * tm)
}
@ @c
-static void set_textmatrix(PDF pdf, scaledpos pos, boolean force)
+static void set_textmatrix(PDF pdf, scaledpos pos)
{
boolean move;
pdfstructure *p = pdf->pstruct;
assert(is_textmode(p));
move = calc_pdfpos(p, pos);
- if (force || move) {
+ if (p->need_tm == 1 || move) {
print_tm(pdf, p->tm);
p->pdf.h.m = p->pdf_bt_pos.h.m + p->tm[4].m; /* Tm replaces */
p->pdf.v.m = p->pdf_bt_pos.v.m + p->tm[5].m;
+ p->need_tm = 0;
}
}
@@ -183,9 +184,9 @@ void pdf_place_glyph(PDF pdf, internal_font_number f, int c)
setup_fontparameters(pdf, f);
if (p->f_pdf != p->f_pdf_cur || p->fs.m != p->fs_cur.m) {
set_font(pdf);
- set_textmatrix(pdf, pos, true); /* force Tm setting */
- } else
- set_textmatrix(pdf, pos, false);
+ p->need_tm = 1; /* force Tm setting */
+ }
+ set_textmatrix(pdf, pos);
begin_chararray(pdf);
}
assert(is_charmode(p) || is_chararraymode(p));
@@ -197,7 +198,7 @@ void pdf_place_glyph(PDF pdf, internal_font_number f, int c)
&& (p->pdf_bt_pos.h.m + p->tm[4].m) != p->pdf.h.m)
|| abs(p->tj_delta.m) >= 1000000) {
pdf_goto_textmode(pdf);
- set_textmatrix(pdf, pos, false);
+ set_textmatrix(pdf, pos);
begin_chararray(pdf);
move = calc_pdfpos(p, pos);
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfimage.w b/Build/source/texk/web2c/luatexdir/pdf/pdfimage.w
index 5fbdc037912..cc1e20c1870 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfimage.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfimage.w
@@ -20,7 +20,7 @@
@ @c
static const char _svn_version[] =
"$Id: pdfimage.w 3571 2010-04-02 13:50:45Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.60.x/source/texk/web2c/luatexdir/pdf/pdfimage.w $";
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfimage.w $";
#include "ptexlib.h"
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdflink.w b/Build/source/texk/web2c/luatexdir/pdf/pdflink.w
index 517f0079a01..4cdfa711ed6 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdflink.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdflink.w
@@ -19,8 +19,8 @@
@ @c
static const char _svn_version[] =
- "$Id: pdflink.w 3571 2010-04-02 13:50:45Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.60.x/source/texk/web2c/luatexdir/pdf/pdflink.w $";
+ "$Id: pdflink.w 3891 2010-09-14 23:02:24Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdflink.w $";
#include "ptexlib.h"
@@ -37,7 +37,7 @@ void push_link_level(PDF pdf, halfword p)
if (pdf->link_stack_ptr >= pdf_max_link_level)
overflow("pdf link stack size", pdf_max_link_level);
assert(((type(p) == whatsit_node) && (subtype(p) == pdf_start_link_node)));
- incr(pdf->link_stack_ptr);
+ pdf->link_stack_ptr++;
pdf->link_stack[pdf->link_stack_ptr].nesting_level = cur_s;
pdf->link_stack[pdf->link_stack_ptr].link_node = copy_node_list(p);
pdf->link_stack[pdf->link_stack_ptr].ref_link_node = p;
@@ -48,7 +48,7 @@ void pop_link_level(PDF pdf)
{
assert(pdf->link_stack_ptr > 0);
flush_node_list(pdf->link_stack[pdf->link_stack_ptr].link_node);
- decr(pdf->link_stack_ptr);
+ pdf->link_stack_ptr--;
}
@ @c
@@ -57,7 +57,7 @@ void do_link(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
scaled_whd alt_rule;
if (type(p) == vlist_node)
pdf_error("ext4", "\\pdfstartlink ended up in vlist");
- if (!is_shipping_page)
+ if (global_shipping_mode == SHIPPING_FORM)
pdf_error("ext4", "link annotations cannot be inside an XForm");
assert(type(parent_box) == hlist_node);
if (is_obj_scheduled(pdf, pdf_link_objnum(p)))
@@ -90,7 +90,7 @@ void end_link(PDF pdf, halfword p)
if (is_running(width(pdf->link_stack[pdf->link_stack_ptr].link_node))) {
q = pdf->link_stack[pdf->link_stack_ptr].ref_link_node;
- if (is_shipping_page && matrixused()) {
+ if (global_shipping_mode == SHIPPING_PAGE && matrixused()) {
matrixrecalculate(pos.h + pdf_link_margin);
pdf_ann_left(q) = getllx() - pdf_link_margin;
pdf_ann_top(q) = cur_page_size.v - getury() - pdf_link_margin;
@@ -128,6 +128,7 @@ node, in order to use |flush_node_list| to do the job.
void append_link(PDF pdf, halfword parent_box, scaledpos cur, small_number i)
{
halfword p;
+ int k;
scaled_whd alt_rule;
assert(type(parent_box) == hlist_node);
p = copy_node(pdf->link_stack[(int) i].link_node);
@@ -137,9 +138,9 @@ void append_link(PDF pdf, halfword parent_box, scaledpos cur, small_number i)
alt_rule.ht = height(p);
alt_rule.dp = depth(p);
set_rect_dimens(pdf, p, parent_box, cur, alt_rule, pdf_link_margin);
- pdf_create_obj(pdf, obj_type_others, 0);
- obj_annot_ptr(pdf, pdf->obj_ptr) = p;
- addto_page_resources(pdf, obj_type_link, pdf->obj_ptr);
+ k = pdf_create_obj(pdf, obj_type_others, 0);
+ obj_annot_ptr(pdf, k) = p;
+ addto_page_resources(pdf, obj_type_link, k);
}
@ @c
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w b/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w
index 67be319082e..397c09902c7 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w
@@ -21,8 +21,8 @@
@ @c
static const char _svn_version[] =
- "$Id: pdflistout.w 3571 2010-04-02 13:50:45Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.60.x/source/texk/web2c/luatexdir/pdf/pdflistout.w $";
+ "$Id: pdflistout.w 3891 2010-09-14 23:02:24Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdflistout.w $";
#include "ptexlib.h"
@@ -221,9 +221,9 @@ static halfword calculate_width_to_enddir(halfword p, real cur_glue,
case whatsit_node:
if (subtype(q) == dir_node) {
if (dir_dir(q) >= 0)
- incr(dir_nest);
+ dir_nest++;
else
- decr(dir_nest);
+ dir_nest--;
if (dir_nest == 0) {
enddir_ptr = q;
dir_cur_h(enddir_ptr) = w;
@@ -347,7 +347,7 @@ void hlist_out(PDF pdf, halfword this_box)
localpos.pos = refpos->pos;
localpos.dir = box_dir(this_box);
- incr(cur_s);
+ cur_s++;
if (cur_s > max_push)
max_push = cur_s;
@@ -782,7 +782,7 @@ void hlist_out(PDF pdf, halfword this_box)
dvi = save_dvi; /* DVI! */
}
}
- decr(cur_s);
+ cur_s--;
pdf->posstruct = refpos;
}
@@ -825,7 +825,7 @@ void vlist_out(PDF pdf, halfword this_box)
localpos.dir = box_dir(this_box);
synch_pos_with_cur(pdf->posstruct, refpos, cur);
- incr(cur_s);
+ cur_s++;
if (cur_s > max_push)
max_push = cur_s;
@@ -1134,6 +1134,6 @@ void vlist_out(PDF pdf, halfword this_box)
dvi = save_dvi; /* DVI! */
}
}
- decr(cur_s);
+ cur_s--;
pdf->posstruct = refpos;
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w b/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w
index 36b90dfca1f..798036f80bd 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w
@@ -1,5 +1,5 @@
% pdfliteral.w
-%
+%
% Copyright 2009-2010 Taco Hoekwater <taco@@luatex.org>
% This file is part of LuaTeX.
@@ -15,14 +15,14 @@
% License for more details.
% You should have received a copy of the GNU General Public License along
-% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
+% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
#include "ptexlib.h"
static const char _svn_version[] =
- "$Id: pdfliteral.w 3571 2010-04-02 13:50:45Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.60.x/source/texk/web2c/luatexdir/pdf/pdfliteral.w $";
+ "$Id: pdfliteral.w 3733 2010-07-06 22:14:07Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfliteral.w $";
@ @c
void pdf_special(PDF pdf, halfword p)
@@ -49,6 +49,7 @@ void pdf_out_literal(PDF pdf, halfword p)
{
int old_setting; /* holds print |selector| */
str_number s;
+ pdfstructure *ps = pdf->pstruct;
if (pdf_literal_type(p) == normal) {
old_setting = selector;
selector = new_string;
@@ -69,6 +70,7 @@ void pdf_out_literal(PDF pdf, halfword p)
break;
case direct_always:
pdf_end_string_nl(pdf);
+ ps->need_tm = 1;
break;
default:
confusion("literal1");
@@ -78,7 +80,7 @@ void pdf_out_literal(PDF pdf, halfword p)
}
}
-@ test equality of start of strings
+@ test equality of start of strings
@c
static boolean str_in_cstr(str_number s, const char *r, unsigned i)
{
@@ -97,7 +99,10 @@ static boolean str_in_cstr(str_number s, const char *r, unsigned i)
@ @c
void pdf_literal(PDF pdf, str_number s, int literal_mode, boolean warn)
{
+ unsigned char *ss;
+ size_t l;
pool_pointer j = 0; /* current character code position, initialized to make the compiler happy */
+ pdfstructure *p = pdf->pstruct;
if (s >= STRING_OFFSET) { /* needed for |out_save| */
j = 0;
if (literal_mode == scan_special) {
@@ -131,21 +136,16 @@ void pdf_literal(PDF pdf, str_number s, int literal_mode, boolean warn)
break;
case direct_always:
pdf_end_string_nl(pdf);
+ p->need_tm = 1;
break;
default:
confusion("literal1");
break;
}
if (s >= STRING_OFFSET) {
- unsigned char *ss = str_string(s);
- size_t l = str_length(s) - (size_t) j;
- if (l < max_single_pdf_print) {
- pdf_out_block(pdf, (ss + j), l);
- } else {
-
- while (l--)
- pdf_out(pdf, *(ss + j++));
- }
+ ss = str_string(s);
+ l = str_length(s) - (size_t) j;
+ pdf_out_block(pdf, (const char *) (ss + j), l);
} else {
assert(s < 256);
pdf_out(pdf, s);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.h b/Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.h
new file mode 100644
index 00000000000..69ddf3406ca
--- /dev/null
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.h
@@ -0,0 +1,30 @@
+/* pdfluaapi.h
+
+ Copyright 2009 Taco Hoekwater <taco@luatex.org>
+
+ This file is part of LuaTeX.
+
+ LuaTeX is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ LuaTeX is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
+
+/* $Id: pdfluaapi.h 3949 2010-11-07 00:09:19Z hhenkel $ */
+
+#ifndef PDFLUAAPI_H
+# define PDFLUAAPI_H
+
+extern int new_pdflua(void);
+extern void pdflua_begin_page(PDF pdf);
+extern void pdflua_end_page(PDF pdf, int annots, int beads);
+extern void pdflua_output_pages_tree(PDF pdf);
+
+#endif /* PDFLUAAPI_H */
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.w b/Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.w
new file mode 100644
index 00000000000..c434241f3de
--- /dev/null
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.w
@@ -0,0 +1,115 @@
+% pdfluaapi.w
+%
+% Copyright 2010 Taco Hoekwater <taco@@luatex.org>
+
+% This file is part of LuaTeX.
+
+% LuaTeX is free software; you can redistribute it and/or modify it under
+% the terms of the GNU General Public License as published by the Free
+% Software Foundation; either version 2 of the License, or (at your
+% option) any later version.
+
+% LuaTeX is distributed in the hope that it will be useful, but WITHOUT
+% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+% License for more details.
+
+% You should have received a copy of the GNU General Public License along
+% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
+
+@ @c
+static const char _svn_version[] =
+ "$Id: pdfluaapi.w 4066 2011-01-18 20:19:50Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfluaapi.w $";
+
+#include "ptexlib.h"
+
+@ @c
+int new_pdflua(void)
+{
+ int i, err;
+ Byte *uncompr;
+ zlib_struct *zp = (zlib_struct *) pdflua_zlib_struct_ptr;
+ uLong uncomprLen = zp->uncomprLen;
+ if ((uncompr = xtalloc(zp->uncomprLen, Byte)) == NULL)
+ pdftex_fail("new_pdflua(): xtalloc()");
+ err = uncompress(uncompr, &uncomprLen, zp->compr, zp->comprLen);
+ if (err != Z_OK)
+ pdftex_fail("new_pdflua(): uncompress()");
+ assert(uncomprLen == zp->uncomprLen);
+ if (luaL_loadbuffer(Luas, (const char *) uncompr, uncomprLen, "pdflua")
+ || lua_pcall(Luas, 0, 1, 0))
+ pdftex_fail("new_pdflua(): lua_pcall()");
+ luaL_checktype(Luas, -1, LUA_TTABLE); /* t */
+ i = luaL_ref(Luas, LUA_GLOBALSINDEX); /* - */
+ xfree(uncompr);
+ return i;
+}
+
+@ @c
+void pdflua_begin_page(PDF pdf)
+{
+ int err; /* ... */
+ lua_rawgeti(Luas, LUA_GLOBALSINDEX, pdf->pdflua_ref); /* t ... */
+ lua_pushstring(Luas, "beginpage"); /* s t ... */
+ lua_gettable(Luas, -2); /* f t ... */
+ lua_newtable(Luas); /* t f t ... */
+ lua_pushnumber(Luas, total_pages + 1); /* i t f t ... */
+ lua_setfield(Luas, -2, "pagenum"); /* t f t ... */
+ lua_pushnumber(Luas, pdf->last_page); /* i t f t ... */
+ lua_setfield(Luas, -2, "page_objnum"); /* t f t ... */
+ lua_pushnumber(Luas, pdf->last_stream); /* i t f t ... */
+ lua_setfield(Luas, -2, "stream_objnum"); /* t f t ... */
+ lua_pushnumber(Luas, pdf->page_resources->last_resources); /* i t f t ... */
+ lua_setfield(Luas, -2, "resources_objnum"); /* t f t ... */
+ err = lua_pcall(Luas, 1, 0, 0); /* (e) t ... */
+ if (err != 0)
+ pdftex_fail("pdflua.lua: beginpage()");
+ /* t ... */
+ lua_pop(Luas, 1); /* ... */
+}
+
+@ @c
+void pdflua_end_page(PDF pdf, int annots, int beads)
+{
+ int err; /* ... */
+ lua_rawgeti(Luas, LUA_GLOBALSINDEX, pdf->pdflua_ref); /* t ... */
+ lua_pushstring(Luas, "endpage"); /* s t ... */
+ lua_gettable(Luas, -2); /* f t ... */
+ lua_newtable(Luas); /* t f t ... */
+ lua_pushnumber(Luas, total_pages); /* i t f t ... */
+ lua_setfield(Luas, -2, "pagenum"); /* t f t ... */
+ lua_pushnumber(Luas, cur_page_size.h); /* i t f t ... */
+ lua_setfield(Luas, -2, "hsize"); /* t f t ... */
+ lua_pushnumber(Luas, cur_page_size.v); /* i t f t ... */
+ lua_setfield(Luas, -2, "vsize"); /* t f t ... */
+ if (annots != 0) {
+ lua_pushnumber(Luas, annots); /* i t f t ... */
+ lua_setfield(Luas, -2, "annots"); /* t f t ... */
+ }
+ if (beads != 0) {
+ lua_pushnumber(Luas, beads); /* i t f t ... */
+ lua_setfield(Luas, -2, "beads"); /* t f t ... */
+ }
+ if (pdf->img_page_group_val != 0) {
+ lua_pushnumber(Luas, pdf->img_page_group_val); /* i t f t ... */
+ lua_setfield(Luas, -2, "imggroup"); /* t f t ... */
+ }
+ err = lua_pcall(Luas, 1, 0, 0); /* (e) t ... */
+ if (err != 0)
+ pdftex_fail("pdflua.lua: endpage()");
+ /* t ... */
+ lua_pop(Luas, 1); /* ... */
+}
+
+@ @c
+void pdflua_output_pages_tree(PDF pdf)
+{
+ int err;
+ lua_rawgeti(Luas, LUA_GLOBALSINDEX, pdf->pdflua_ref); /* t */
+ lua_pushstring(Luas, "outputpagestree"); /* s t */
+ lua_gettable(Luas, -2); /* f */
+ err = lua_pcall(Luas, 0, 0, 0); /* - */
+ if (err != 0)
+ pdftex_fail("pdflua.lua: outputpagestree()");
+}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h
index 35325a1e8bb..6b6f628b8ec 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
-/* $Id: pdfobj.h 3261 2009-12-18 11:38:21Z taco $ */
+/* $Id: pdfobj.h 3874 2010-09-11 22:22:05Z hhenkel $ */
#ifndef PDFOBJ_H
# define PDFOBJ_H
@@ -61,6 +61,8 @@ extern void init_obj_obj(PDF pdf, int k);
extern void pdf_write_obj(PDF pdf, int n);
extern void scan_obj(PDF pdf);
extern void scan_refobj(PDF pdf);
+extern void scan_refobj_lua(PDF pdf, int k);
extern void pdf_ref_obj(PDF pdf, halfword p);
+extern void pdf_ref_obj_lua(PDF pdf, int k);
#endif
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w
index 8ad6319274f..2d370ddc54f 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w
@@ -19,8 +19,8 @@
@ @c
static const char _svn_version[] =
- "$Id: pdfobj.w 3571 2010-04-02 13:50:45Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.60.x/source/texk/web2c/luatexdir/pdf/pdfobj.w $";
+ "$Id: pdfobj.w 4093 2011-03-16 16:17:06Z taco $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfobj.w $";
#include "ptexlib.h"
@@ -36,7 +36,7 @@ void pdf_write_obj(PDF pdf, int k)
{
lstring data;
const_lstring st;
- size_t i, li; /* index into |data.s| */
+ size_t li; /* index into |data.s| */
int saved_compress_level = pdf->compress_level;
int os_level = 1; /* gives compressed objects for \.{\\pdfobjcompresslevel} $>$ 0 */
int l = 0; /* possibly a lua registry reference */
@@ -54,8 +54,7 @@ void pdf_write_obj(PDF pdf, int k)
assert(lua_isstring(Luas, -1));
st.s = lua_tolstring(Luas, -1, &li);
st.l = li;
- for (i = 0; i < st.l; i++)
- pdf_out(pdf, st.s[i]);
+ pdf_out_block(pdf, st.s, st.l);
if (st.s[st.l - 1] != '\n')
pdf_out(pdf, '\n');
luaL_unref(Luas, LUA_REGISTRYINDEX, l);
@@ -69,6 +68,7 @@ void pdf_write_obj(PDF pdf, int k)
assert(lua_isstring(Luas, -1));
st.s = lua_tolstring(Luas, -1, &li);
st.l = li;
+ lua_pop(Luas,1);
if (obj_obj_is_file(pdf, k)) {
boolean res = false; /* callback status value */
const char *fnam = NULL; /* callback found filename */
@@ -100,15 +100,13 @@ void pdf_write_obj(PDF pdf, int k)
pdf_error("ext5", "error reading file for embedding");
tprint("<<");
tprint(st.s);
- for (i = 0; i < data.l; i++)
- pdf_out(pdf, data.s[i]);
+ pdf_out_block(pdf, (const char *) data.s, data.l);
if (!obj_obj_is_stream(pdf, k) && data.s[data.l - 1] != '\n')
pdf_out(pdf, '\n');
xfree(data.s);
tprint(">>");
} else {
- for (i = 0; i < st.l; i++)
- pdf_out(pdf, st.s[i]);
+ pdf_out_block(pdf, st.s, st.l);
if (!obj_obj_is_stream(pdf, k) && st.s[st.l - 1] != '\n')
pdf_out(pdf, '\n');
}
@@ -149,20 +147,18 @@ void scan_obj(PDF pdf)
get_x_token();
if (cur_cmd != spacer_cmd)
back_input();
- incr(pdf->obj_count);
- pdf_create_obj(pdf, obj_type_obj, pdf->sys_obj_ptr + 1);
- k = pdf->sys_obj_ptr;
+ pdf->obj_count++;
+ k = pdf_create_obj(pdf, obj_type_obj, pdf->obj_ptr + 1);
} else {
if (scan_keyword("useobjnum")) {
scan_int();
k = cur_val;
- check_obj_exists(pdf, obj_type_obj, k);
+ check_obj_type(pdf, obj_type_obj, k);
if (is_obj_scheduled(pdf, k) || obj_data_ptr(pdf, k) != 0)
luaL_error(Luas, "object in use");
} else {
- incr(pdf->obj_count);
- pdf_create_obj(pdf, obj_type_obj, pdf->sys_obj_ptr + 1);
- k = pdf->sys_obj_ptr;
+ pdf->obj_count++;
+ k = pdf_create_obj(pdf, obj_type_obj, pdf->obj_ptr + 1);
}
obj_data_ptr(pdf, k) = pdf_get_mem(pdf, pdfmem_obj_size);
init_obj_obj(pdf, k);
@@ -201,14 +197,28 @@ void scan_obj(PDF pdf)
void scan_refobj(PDF pdf)
{
scan_int();
- check_obj_exists(pdf, obj_type_obj, cur_val);
+ check_obj_type(pdf, obj_type_obj, cur_val);
new_whatsit(pdf_refobj_node);
pdf_obj_objnum(tail) = cur_val;
}
+void scan_refobj_lua(PDF pdf, int k)
+{
+ check_obj_type(pdf, obj_type_obj, k);
+ new_whatsit(pdf_refobj_node);
+ pdf_obj_objnum(tail) = k;
+}
+
@ @c
void pdf_ref_obj(PDF pdf, halfword p)
{
if (!is_obj_scheduled(pdf, pdf_obj_objnum(p)))
addto_page_resources(pdf, obj_type_obj, pdf_obj_objnum(p));
}
+
+@ @c
+void pdf_ref_obj_lua(PDF pdf, int k)
+{
+ if (!is_obj_scheduled(pdf, k))
+ addto_page_resources(pdf, obj_type_obj, k);
+}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w b/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w
index 7efaa479bf6..dc97c290f30 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w
@@ -21,8 +21,8 @@
#include "ptexlib.h"
static const char _svn_version[] =
- "$Id: pdfoutline.w 3571 2010-04-02 13:50:45Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.60.x/source/texk/web2c/luatexdir/pdf/pdfoutline.w $";
+ "$Id: pdfoutline.w 3891 2010-09-14 23:02:24Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfoutline.w $";
@ Data structure of outlines; it's not able to write out outline entries
before all outline entries are defined, so memory allocated for outline
@@ -64,7 +64,7 @@ static int open_subentries(PDF pdf, halfword p)
if (obj_outline_first(pdf, p) != 0) {
l = obj_outline_first(pdf, p);
do {
- incr(k);
+ k++;
c = open_subentries(pdf, l);
if (obj_outline_count(pdf, l) > 0)
k = k + c;
@@ -89,7 +89,7 @@ static int outline_list_count(PDF pdf, pointer p)
{
int k = 1;
while (obj_outline_prev(pdf, p) != 0) {
- incr(k);
+ k++;
p = obj_outline_prev(pdf, p);
}
return k;
@@ -99,7 +99,7 @@ static int outline_list_count(PDF pdf, pointer p)
void scan_pdfoutline(PDF pdf)
{
halfword p, q, r;
- int i, j, k;
+ int i, j, k, l;
if (scan_keyword("attr")) {
scan_pdf_ext_toks();
r = def_ref;
@@ -115,17 +115,15 @@ void scan_pdfoutline(PDF pdf)
}
scan_pdf_ext_toks();
q = def_ref;
- pdf_new_obj(pdf, obj_type_others, 0, 1);
- j = pdf->obj_ptr;
+ j = pdf_new_obj(pdf, obj_type_others, 0, 1);
write_action(pdf, p);
pdf_end_obj(pdf);
delete_action_ref(p);
- pdf_create_obj(pdf, obj_type_outline, 0);
- k = pdf->obj_ptr;
+ k = pdf_create_obj(pdf, obj_type_outline, 0);
set_obj_outline_ptr(pdf, k, pdf_get_mem(pdf, pdfmem_outline_size));
set_obj_outline_action_objnum(pdf, k, j);
set_obj_outline_count(pdf, k, i);
- pdf_new_obj(pdf, obj_type_others, 0, 1);
+ l = pdf_new_obj(pdf, obj_type_others, 0, 1);
{
char *s = tokenlist_to_cstring(q, true, NULL);
pdf_print_str_ln(pdf, s);
@@ -133,7 +131,7 @@ void scan_pdfoutline(PDF pdf)
}
delete_token_ref(q);
pdf_end_obj(pdf);
- set_obj_outline_title(pdf, k, pdf->obj_ptr);
+ set_obj_outline_title(pdf, k, l);
set_obj_outline_prev(pdf, k, 0);
set_obj_outline_next(pdf, k, 0);
set_obj_outline_first(pdf, k, 0);
@@ -182,12 +180,11 @@ int print_outlines(PDF pdf)
int k, l, a;
int outlines;
if (pdf->first_outline != 0) {
- pdf_new_dict(pdf, obj_type_others, 0, 1);
- outlines = pdf->obj_ptr;
+ outlines = pdf_new_dict(pdf, obj_type_others, 0, 1);
l = pdf->first_outline;
k = 0;
do {
- incr(k);
+ k++;
a = open_subentries(pdf, l);
if (obj_outline_count(pdf, l) > 0)
k = k + a;
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w b/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w
index 1cd00ac0537..15d90288ea9 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w
@@ -19,16 +19,16 @@
@ @c
static const char _svn_version[] =
- "$Id: pdfpage.w 3703 2010-05-27 07:58:34Z taco $ "
- "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.2/source/texk/web2c/luatexdir/pdf/pdfpage.w $";
+ "$Id: pdfpage.w 4131 2011-04-11 13:41:26Z taco $ "
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfpage.w $";
+
+#include "ptexlib.h"
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <math.h>
-#include "ptexlib.h"
-
#define lround(a) (long) floor((a) + 0.5)
@ eternal constants
@@ -68,6 +68,7 @@ void init_pdf_pagecalculations(PDF pdf)
p->wmode = WMODE_H;
p->mode = PMODE_PAGE;
p->ishex = 0;
+ p->need_tm = 0;
p->k1 = ten_pow[p->pdf.h.e] / one_bp;
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w b/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w
index 80385154163..4b70e9cfa31 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w
@@ -20,7 +20,7 @@
@ @c
static const char _svn_version[] =
"$Id: pdfrule.w 3584 2010-04-02 17:45:55Z hhenkel $"
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.60.x/source/texk/web2c/luatexdir/pdf/pdfrule.w $";
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfrule.w $";
#include "ptexlib.h"
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w b/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w
index 3f44429c059..5a5f4fea22d 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w
@@ -19,8 +19,8 @@
@ @c
static const char _svn_version[] =
- "$Id: pdfsaverestore.w 3571 2010-04-02 13:50:45Z taco $ "
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.60.x/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w $";
+ "$Id: pdfsaverestore.w 3676 2010-05-02 20:04:49Z hhenkel $ "
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w $";
#include "ptexlib.h"
@@ -44,7 +44,7 @@ static void checkpdfsave(scaledpos pos)
}
pos_stack[pos_stack_used].pos.h = pos.h;
pos_stack[pos_stack_used].pos.v = pos.v;
- if (page_mode) {
+ if (global_shipping_mode == SHIPPING_PAGE) {
pos_stack[pos_stack_used].matrix_stack = matrix_stack_used;
}
pos_stack_used++;
@@ -65,7 +65,7 @@ static void checkpdfrestore(scaledpos pos)
pdftex_warn("Misplaced \\pdfrestore by (%dsp, %dsp)", (int) diff.h,
(int) diff.v);
}
- if (page_mode) {
+ if (global_shipping_mode == SHIPPING_PAGE) {
matrix_stack_used = pos_stack[pos_stack_used].matrix_stack;
}
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w b/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w
index c597c51ee5d..0dbb8be7cc6 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w
@@ -19,8 +19,8 @@
@ @c
static const char _svn_version[] =
- "$Id: pdfsetmatrix.w 3612 2010-04-13 09:29:42Z taco $ "
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.60.x/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w $";
+ "$Id: pdfsetmatrix.w 3676 2010-05-02 20:04:49Z hhenkel $ "
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w $";
#include "ptexlib.h"
@@ -91,7 +91,7 @@ static void pdfsetmatrix(const char *in, scaledpos pos)
matrix_entry x, *y, *z;
- if (page_mode) {
+ if (global_shipping_mode == SHIPPING_PAGE) {
if (sscanf((const char *) in, " %lf %lf %lf %lf ",
&x.a, &x.b, &x.c, &x.d) != 4) {
pdftex_warn("Unrecognized format of \\pdfsetmatrix{%s}", in);
@@ -184,7 +184,7 @@ void matrixtransformrect(scaled llx, scaled lly, scaled urx, scaled ury)
{
scaled x1, x2, x3, x4, y1, y2, y3, y4;
- if (page_mode && matrix_stack_used > 0) {
+ if (global_shipping_mode == SHIPPING_PAGE && matrix_stack_used > 0) {
last_llx = llx;
last_lly = lly;
last_urx = urx;
@@ -207,7 +207,7 @@ void matrixtransformrect(scaled llx, scaled lly, scaled urx, scaled ury)
void matrixtransformpoint(scaled x, scaled y)
{
- if (page_mode && matrix_stack_used > 0) {
+ if (global_shipping_mode == SHIPPING_PAGE && matrix_stack_used > 0) {
do_matrixtransform(x, y, &ret_llx, &ret_lly);
} else {
ret_llx = x;
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.h b/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.h
index 1070996a5ba..37e49a3b0d4 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.h
@@ -17,14 +17,14 @@
You should have received a copy of the GNU General Public License along
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
-/* $Id: pdfshipout.h 2977 2009-08-08 12:49:35Z hhenkel $ */
+/* $Id: pdfshipout.h 3853 2010-09-03 18:05:14Z oneiros $ */
#ifndef PDFSHIPOUT_H
# define PDFSHIPOUT_H
-extern boolean is_shipping_page; /* set to |shipping_page| when |ship_out| starts */
+extern shipping_mode_e global_shipping_mode; /* set to |shipping_mode| when |ship_out| starts */
extern scaledpos shipbox_refpos; /* for \gleaders */
-extern void ship_out(PDF pdf, halfword p, boolean shipping_page);
+extern void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode);
#endif
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w b/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w
index cb0a36ae256..f00ac0b2722 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w
@@ -19,8 +19,8 @@
@ @c
static const char _svn_version[] =
- "$Id: pdfshipout.w 3571 2010-04-02 13:50:45Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.60.x/source/texk/web2c/luatexdir/pdf/pdfshipout.w $";
+ "$Id: pdfshipout.w 3891 2010-09-14 23:02:24Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfshipout.w $";
#include "ptexlib.h"
@@ -44,11 +44,11 @@ static const char _svn_version[] =
scaledpos shipbox_refpos;
@ |ship_out| is used to shipout a box to PDF or DVI mode.
-If |shipping_page| is not set then the output will be a Form object
-(only PDF), otherwise it will be a Page object.
+If |shipping_mode| is set to |SHIPPING_FORM| then the output will be a Form object
+(only PDF), and if it is set to |SHIPPING_PAGE| it will be a Page object.
@c
-void ship_out(PDF pdf, halfword p, boolean shipping_page)
+void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
{
/* output the box |p| */
int j, k; /* indices to first ten count registers */
@@ -77,8 +77,8 @@ void ship_out(PDF pdf, halfword p, boolean shipping_page)
print_ln();
tprint("Completed box being shipped out");
}
- is_shipping_page = shipping_page;
- if (shipping_page) {
+ global_shipping_mode = shipping_mode;
+ if (shipping_mode == SHIPPING_PAGE) {
if (pre_callback_id > 0)
(void) run_callback(pre_callback_id, "->");
else if (pre_callback_id == 0) {
@@ -89,7 +89,7 @@ void ship_out(PDF pdf, halfword p, boolean shipping_page)
print_char('[');
j = 9;
while ((count(j) == 0) && (j > 0))
- decr(j);
+ j--;
for (k = 0; k <= j; k++) {
print_int(count(k));
if (k < j)
@@ -97,7 +97,7 @@ void ship_out(PDF pdf, halfword p, boolean shipping_page)
}
}
}
- if ((tracing_output > 0) && shipping_page) {
+ if ((tracing_output > 0) && shipping_mode == SHIPPING_PAGE) {
print_char(']');
update_terminal();
begin_diagnostic();
@@ -106,7 +106,7 @@ void ship_out(PDF pdf, halfword p, boolean shipping_page)
}
/* Ship box |p| out */
- if (shipping_page && box_dir(p) != page_direction)
+ if (shipping_mode == SHIPPING_PAGE && box_dir(p) != page_direction)
pdf_warning("\\shipout",
"\\pagedir != \\bodydir; "
"\\box\\outputbox may be placed wrongly on the page.", true,
@@ -139,7 +139,7 @@ void ship_out(PDF pdf, halfword p, boolean shipping_page)
max_h = width(p) + h_offset;
/* Calculate page dimensions and margins */
- if (is_shipping_page) {
+ if (global_shipping_mode == SHIPPING_PAGE) {
if (page_width > 0)
cur_page_size.h = page_width;
else {
@@ -256,14 +256,14 @@ void ship_out(PDF pdf, halfword p, boolean shipping_page)
switch (pdf->o_mode) {
case OMODE_DVI:
- assert(shipping_page);
+ assert(shipping_mode == SHIPPING_PAGE);
dvi_begin_page(pdf);
break;
case OMODE_PDF:
- pdf_begin_page(pdf, shipping_page);
+ pdf_begin_page(pdf);
break;
case OMODE_LUA:
- assert(shipping_page);
+ assert(shipping_mode == SHIPPING_PAGE);
lua_begin_page(pdf);
break;
default:
@@ -281,8 +281,8 @@ void ship_out(PDF pdf, halfword p, boolean shipping_page)
assert(0);
}
- if (shipping_page)
- incr(total_pages);
+ if (shipping_mode == SHIPPING_PAGE)
+ total_pages++;
cur_s = -1;
/* Finish shipping */
@@ -292,7 +292,7 @@ void ship_out(PDF pdf, halfword p, boolean shipping_page)
dvi_end_page(pdf);
break;
case OMODE_PDF:
- pdf_end_page(pdf, shipping_page);
+ pdf_end_page(pdf);
break;
case OMODE_LUA:
lua_end_page(pdf);
@@ -302,7 +302,8 @@ void ship_out(PDF pdf, halfword p, boolean shipping_page)
}
DONE:
- if ((tracing_output <= 0) && (post_callback_id == 0) && shipping_page) {
+ if ((tracing_output <= 0) && (post_callback_id == 0)
+ && shipping_mode == SHIPPING_PAGE) {
print_char(']');
update_terminal();
}
@@ -323,10 +324,12 @@ void ship_out(PDF pdf, halfword p, boolean shipping_page)
print_int(dyn_used);
print_ln();
}
- if (shipping_page && (post_callback_id > 0))
+ if (shipping_mode == SHIPPING_PAGE && (post_callback_id > 0))
(void) run_callback(post_callback_id, "->");
/* Finish sheet {\sl Sync\TeX} information record */
if (int_par(synctex_code))
synctexteehs();
+
+ global_shipping_mode = NOT_SHIPPING;
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftables.h b/Build/source/texk/web2c/luatexdir/pdf/pdftables.h
index f44c6b2a7c6..b5ee6b55266 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdftables.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdftables.h
@@ -17,11 +17,13 @@
You should have received a copy of the GNU General Public License along
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
-/* $Id: pdftables.h 3261 2009-12-18 11:38:21Z taco $ */
+/* $Id: pdftables.h 4062 2011-01-11 20:47:28Z hhenkel $ */
#ifndef PDFTABLES_H
# define PDFTABLES_H
+const char *pdf_obj_typenames[PDF_OBJ_TYPE_MAX + 1];
+
typedef enum {
union_type_int,
union_type_cstring,
@@ -68,7 +70,7 @@ well.
# define obj_info(pdf,A) pdf->obj_tab[(A)].u.int0 /* information representing identifier of this object */
# define obj_start(pdf,A) pdf->obj_tab[(A)].u.str0
# define obj_link(pdf,A) pdf->obj_tab[(A)].int1 /* link to the next entry in linked list */
-# define obj_offset(pdf,A) pdf->obj_tab[(A)].int2 /* negative (flags), or byte offset for this object in PDF
+# define obj_offset(pdf,A) pdf->obj_tab[(A)].int2 /* negative (flags), or byte offset for this object in PDF
output file, or object stream number for this object */
# define obj_os_idx(pdf,A) pdf->obj_tab[(A)].int3 /* index of this object in object stream */
# define obj_aux(pdf,A) pdf->obj_tab[(A)].v.int4 /* auxiliary pointer */
@@ -90,7 +92,7 @@ well.
# define is_obj_scheduled(pdf,A) (intcast(obj_offset(pdf,A))>-2)
# define is_obj_written(pdf,A) (intcast(obj_offset(pdf,A))>-1)
-/* NOTE: The data structure definitions for the nodes on the typesetting side are
+/* NOTE: The data structure definitions for the nodes on the typesetting side are
inside |nodes.h| */
/* Some constants */
@@ -98,9 +100,10 @@ well.
# define sup_pk_dpi 8000 /* max PK pixel density value from \.{texmf.cnf} */
extern int find_obj(PDF pdf, int t, int i, boolean byname);
-extern void check_obj_exists(PDF pdf, int t, int n);
+extern void check_obj_exists(PDF pdf, int objnum);
+extern void check_obj_type(PDF pdf, int t, int objnum);
extern int get_obj(PDF pdf, int t, int i, boolean byname);
-extern void pdf_create_obj(PDF pdf, int t, int i);
+extern int pdf_create_obj(PDF pdf, int t, int i);
extern int pdf_new_objnum(PDF pdf);
extern void set_rect_dimens(PDF pdf, halfword p, halfword parent_box,
@@ -116,21 +119,23 @@ extern void undump_pdftex_data(PDF pdf);
# define set_depth(A, B) depth(A) = (B)
/* interface definitions for eqtb locations */
-# define pdf_minor_version int_par(pdf_minor_version_code)
+# define pdf_compress_level int_par(pdf_compress_level_code)
# define pdf_decimal_digits int_par(pdf_decimal_digits_code)
+# define pdf_draftmode int_par(pdf_draftmode_code)
# define pdf_gamma int_par(pdf_gamma_code)
+# define pdf_gen_tounicode int_par(pdf_gen_tounicode_code)
+# define pdf_image_apply_gamma int_par(pdf_image_apply_gamma_code)
# define pdf_image_gamma int_par(pdf_image_gamma_code)
# define pdf_image_hicolor int_par(pdf_image_hicolor_code)
-# define pdf_image_apply_gamma int_par(pdf_image_apply_gamma_code)
-# define pdf_objcompresslevel int_par(pdf_objcompresslevel_code)
-# define pdf_draftmode int_par(pdf_draftmode_code)
# define pdf_inclusion_copy_font int_par(pdf_inclusion_copy_font_code)
# define pdf_inclusion_errorlevel int_par(pdf_inclusion_errorlevel_code)
-# define pdf_replace_font int_par(pdf_replace_font_code)
-# define pdf_pk_resolution int_par(pdf_pk_resolution_code)
+# define pdf_minor_version int_par(pdf_minor_version_code)
+# define pdf_move_chars int_par(pdf_move_chars_code)
+# define pdf_objcompresslevel int_par(pdf_objcompresslevel_code)
+# define pdf_output int_par(pdf_output_code)
# define pdf_pk_mode equiv(pdf_pk_mode_loc)
+# define pdf_pk_resolution int_par(pdf_pk_resolution_code)
+# define pdf_replace_font int_par(pdf_replace_font_code)
# define pdf_unique_resname int_par(pdf_unique_resname_code)
-# define pdf_compress_level int_par(pdf_compress_level_code)
-# define pdf_move_chars int_par(pdf_move_chars_code)
-#endif
+#endif /* PDFTABLES_H */
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftables.w b/Build/source/texk/web2c/luatexdir/pdf/pdftables.w
index 5db049c758e..b7f7869d3b4 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdftables.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdftables.w
@@ -19,33 +19,16 @@
@ @c
static const char _svn_version[] =
- "$Id: pdftables.w 3571 2010-04-02 13:50:45Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.60.x/source/texk/web2c/luatexdir/pdf/pdftables.w $";
+ "$Id: pdftables.w 3908 2010-10-13 19:22:02Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdftables.w $";
#include "ptexlib.h"
-@ One AVL tree each for a few |obj_type| out of |0...PDF_OBJ_TYPE_MAX|
-
-@c
-/* mark which objects should be searchable through AVL tree */
-
-static int obj_in_tree[PDF_OBJ_TYPE_MAX + 1] = {
- 0, /* |obj_type_font = 0|, */
- 0, /* |obj_type_outline = 1|, */
- 1, /* |obj_type_dest = 2|, */
- 0, /* |obj_type_obj = 3|, */
- 0, /* |obj_type_xform = 4|, */
- 0, /* |obj_type_ximage = 5|, */
- 1, /* |obj_type_thread = 6|, */
- /* the ones below don't go into a linked list */
- 0, /* |obj_type_pagestream = 7|, */
- 1, /* |obj_type_page = 8|, */
- 0, /* |obj_type_pages = 9|, */
- 0, /* |obj_type_link = 10|, */
- 0, /* |obj_type_bead = 11|, */
- 0, /* |obj_type_annot = 12|, */
- 0, /* |obj_type_objstm = 13|, */
- 0 /* |obj_type_others = 14| */
+@ @c
+const char *pdf_obj_typenames[PDF_OBJ_TYPE_MAX + 1] =
+ { "font", "outline", "dest", "obj", "xform", "ximage", "thread",
+ "pagestream", "page", "pages", "catalog", "info", "link", "annot", "annots",
+ "bead", "beads", "objstm", "others"
};
@ AVL sort oentry into |avl_table[]|
@@ -71,7 +54,7 @@ static int compare_info(const void *pa, const void *pb, void *param)
static void avl_put_obj(PDF pdf, int t, oentry * oe)
{
void **pp;
- assert(t >= 0 || t <= PDF_OBJ_TYPE_MAX || obj_in_tree[t] == 1);
+ assert(t >= 0 && t <= PDF_OBJ_TYPE_MAX);
if (pdf->obj_tree[t] == NULL) {
pdf->obj_tree[t] = avl_create(compare_info, NULL, &avl_xallocator);
if (pdf->obj_tree[t] == NULL)
@@ -106,7 +89,7 @@ static int avl_find_int_obj(PDF pdf, int t, int i)
{
oentry *p;
oentry tmp;
- assert(t >= 0 || t <= PDF_OBJ_TYPE_MAX || obj_in_tree[t] == 1);
+ assert(t >= 0 && t <= PDF_OBJ_TYPE_MAX);
tmp.u.int0 = i;
tmp.u_type = union_type_int;
if (pdf->obj_tree[t] == NULL)
@@ -121,7 +104,7 @@ static int avl_find_str_obj(PDF pdf, int t, char *s)
{
oentry *p;
oentry tmp;
- assert(t >= 0 || t <= PDF_OBJ_TYPE_MAX || obj_in_tree[t] == 1);
+ assert(t >= 0 && t <= PDF_OBJ_TYPE_MAX);
tmp.u.str0 = s;
tmp.u_type = union_type_cstring;
if (pdf->obj_tree[t] == NULL)
@@ -135,13 +118,13 @@ static int avl_find_str_obj(PDF pdf, int t, char *s)
@ Create an object with type |t| and identifier |i|
@c
-void pdf_create_obj(PDF pdf, int t, int i)
+int pdf_create_obj(PDF pdf, int t, int i)
{
int a;
char *ss = NULL;
- if (pdf->sys_obj_ptr == sup_obj_tab_size)
+ if (pdf->obj_ptr == sup_obj_tab_size)
overflow("indirect objects table size", (unsigned) pdf->obj_tab_size);
- if (pdf->sys_obj_ptr == pdf->obj_tab_size) {
+ if (pdf->obj_ptr == pdf->obj_tab_size) {
a = pdf->obj_tab_size / 5;
if (pdf->obj_tab_size < sup_obj_tab_size - a)
pdf->obj_tab_size = pdf->obj_tab_size + a;
@@ -151,8 +134,7 @@ void pdf_create_obj(PDF pdf, int t, int i)
xreallocarray(pdf->obj_tab, obj_entry,
(unsigned) pdf->obj_tab_size);
}
- incr(pdf->sys_obj_ptr);
- pdf->obj_ptr = pdf->sys_obj_ptr;
+ pdf->obj_ptr++;
obj_info(pdf, pdf->obj_ptr) = i;
obj_type(pdf, pdf->obj_ptr) = t;
set_obj_fresh(pdf, pdf->obj_ptr);
@@ -169,7 +151,9 @@ void pdf_create_obj(PDF pdf, int t, int i)
append_dest_name(pdf, makecstring(-obj_info(pdf, pdf->obj_ptr)),
pdf->obj_ptr);
}
+ return pdf->obj_ptr;
}
+
@ @c
int find_obj(PDF pdf, int t, int i, boolean byname)
{
@@ -209,12 +193,11 @@ int get_obj(PDF pdf, int t, int i, boolean byname)
}
if (r == 0) {
if (byname > 0) {
- pdf_create_obj(pdf, t, -s);
+ r = pdf_create_obj(pdf, t, -s);
s = 0;
} else {
- pdf_create_obj(pdf, t, i);
+ r = pdf_create_obj(pdf, t, i);
}
- r = pdf->obj_ptr;
if (t == obj_type_dest)
set_obj_dest_ptr(pdf, r, null);
}
@@ -228,16 +211,30 @@ int get_obj(PDF pdf, int t, int i, boolean byname)
@c
int pdf_new_objnum(PDF pdf)
{
- pdf_create_obj(pdf, obj_type_others, 0);
- return pdf->obj_ptr;
+ int k = pdf_create_obj(pdf, obj_type_others, 0);
+ return k;
}
-void check_obj_exists(PDF pdf, int t, int objnum)
+void check_obj_exists(PDF pdf, int objnum)
{
if (objnum < 0 || objnum > pdf->obj_ptr)
pdf_error("ext1", "cannot find referenced object");
- if (t != obj_type(pdf, objnum))
- pdf_error("ext1", "referenced object has wrong type");
+}
+
+void check_obj_type(PDF pdf, int t, int objnum)
+{
+ int u;
+ char *s;
+ check_obj_exists(pdf, objnum);
+ u = obj_type(pdf, objnum);
+ if (t != u) {
+ assert(t >= 0 && t <= PDF_OBJ_TYPE_MAX);
+ assert(u >= 0 && u <= PDF_OBJ_TYPE_MAX);
+ s = (char *) xtalloc(128, char);
+ snprintf(s, 127, "referenced object has wrong type %s; should be %s",
+ pdf_obj_typenames[u], pdf_obj_typenames[t]);
+ pdf_error("ext1", s);
+ }
}
@ @c
@@ -277,7 +274,7 @@ void set_rect_dimens(PDF pdf, halfword p, halfword parent_box, scaledpos cur,
pos_ll.v = pos_ur.v;
pos_ur.v = tmp.v;
}
- if (is_shipping_page && matrixused()) {
+ if (global_shipping_mode == SHIPPING_PAGE && matrixused()) {
matrixtransformrect(pos_ll.h, pos_ll.v, pos_ur.h, pos_ur.v);
pos_ll.h = getllx();
pos_ll.v = getlly();
@@ -333,9 +330,7 @@ void dump_pdftex_data(PDF pdf)
dump_int(x);
x = pdf->obj_ptr;
dump_int(x);
- x = pdf->sys_obj_ptr;
- dump_int(x);
- for (k = 1; k <= pdf->sys_obj_ptr; k++) {
+ for (k = 1; k <= pdf->obj_ptr; k++) {
x = obj_info(pdf, k);
dump_int(x);
x = obj_link(pdf, k);
@@ -348,7 +343,7 @@ void dump_pdftex_data(PDF pdf)
dump_int(x);
}
print_ln();
- print_int(pdf->sys_obj_ptr);
+ print_int(pdf->obj_ptr);
tprint(" indirect objects");
dump_int(pdf->obj_count);
dump_int(pdf->xform_count);
@@ -405,9 +400,7 @@ void undump_pdftex_data(PDF pdf)
pdf->obj_tab_size = x;
undump_int(x);
pdf->obj_ptr = x;
- undump_int(x);
- pdf->sys_obj_ptr = x;
- for (k = 1; k <= pdf->sys_obj_ptr; k++) {
+ for (k = 1; k <= pdf->obj_ptr; k++) {
undump_int(x);
obj_info(pdf, k) = x;
undump_int(x);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfthread.h b/Build/source/texk/web2c/luatexdir/pdf/pdfthread.h
index 45d50a4551f..c1671f4f0aa 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfthread.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfthread.h
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
-/* $Id: pdfthread.h 3261 2009-12-18 11:38:21Z taco $ */
+/* $Id: pdfthread.h 3905 2010-10-02 20:29:20Z hhenkel $ */
#ifndef PDFTHREAD_H
# define PDFTHREADH
@@ -64,7 +64,6 @@ extern void pdf_fix_thread(PDF pdf, int t);
extern void out_thread(PDF pdf, int t);
extern void check_running_thread(PDF pdf, halfword this_box, scaledpos cur);
-extern void print_beads_list(PDF pdf);
extern void print_bead_rectangles(PDF pdf);
extern void flush_beads_list(void);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w b/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w
index f5baf228d25..72ba892fa50 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w
@@ -19,8 +19,8 @@
@ @c
static const char _svn_version[] =
- "$Id: pdfthread.w 3571 2010-04-02 13:50:45Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.60.x/source/texk/web2c/luatexdir/pdf/pdfthread.w $";
+ "$Id: pdfthread.w 3905 2010-10-02 20:29:20Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfthread.w $";
#include "ptexlib.h"
@@ -34,7 +34,7 @@ static const char _svn_version[] =
void append_bead(PDF pdf, halfword p)
{
int a, b, c, t;
- if (!is_shipping_page)
+ if (global_shipping_mode == SHIPPING_FORM)
pdf_error("ext4", "threads cannot be inside an XForm");
t = get_obj(pdf, obj_type_thread, pdf_thread_id(p), pdf_thread_named_id(p));
b = pdf_new_objnum(pdf);
@@ -166,8 +166,7 @@ void pdf_fix_thread(PDF pdf, int t)
tprint(" has been referenced but does not exist, replaced by a fixed one");
print_ln();
print_ln();
- pdf_new_dict(pdf, obj_type_others, 0, 0);
- a = pdf->obj_ptr;
+ a = pdf_new_dict(pdf, obj_type_others, 0, 0);
pdf_indirect_ln(pdf, "T", t);
pdf_indirect_ln(pdf, "V", a);
pdf_indirect_ln(pdf, "N", a);
@@ -254,35 +253,21 @@ void check_running_thread(PDF pdf, halfword this_box, scaledpos cur)
}
@ @c
-void print_beads_list(PDF pdf)
-{
- pdf_object_list *k;
- if ((k = get_page_resources_list(pdf, obj_type_bead)) != NULL) {
- pdf_printf(pdf, "/B [ ");
- while (k != NULL) {
- pdf_print_int(pdf, k->info);
- pdf_printf(pdf, " 0 R ");
- k = k->link;
- }
- pdf_printf(pdf, "]\n");
- }
-}
-
-@ @c
void print_bead_rectangles(PDF pdf)
{
halfword i;
pdf_object_list *k;
+ int l;
if ((k = get_page_resources_list(pdf, obj_type_bead)) != NULL) {
while (k != NULL) {
- pdf_new_obj(pdf, obj_type_others, 0, 1);
+ l = pdf_new_obj(pdf, obj_type_others, 0, 1);
pdf_out(pdf, '[');
i = obj_bead_data(pdf, k->info); /* pointer to a whatsit or whatsit-like node */
pdf_print_rect_spec(pdf, i);
if (subtype(i) == pdf_thread_data_node) /* thanh says it mis be destroyed here */
flush_node(i);
pdf_printf(pdf, "]\n");
- set_obj_bead_rect(pdf, k->info, pdf->obj_ptr); /* rewrite |obj_bead_data| */
+ set_obj_bead_rect(pdf, k->info, l); /* rewrite |obj_bead_data| */
pdf_end_obj(pdf);
k = k->link;
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h b/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h
index 83b3c89a97e..255a156ef61 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h
@@ -17,12 +17,13 @@
You should have received a copy of the GNU General Public License along
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
-/* $Id: pdftypes.h 3341 2010-01-08 19:52:54Z hhenkel $ */
+/* $Id: pdftypes.h 3949 2010-11-07 00:09:19Z hhenkel $ */
#ifndef PDFTYPES_H
# define PDFTYPES_H
# include <zlib.h>
+# include "lua/luatex-api.h"
/* This stucture holds everything that is needed for the actual pdf generation.
@@ -109,6 +110,7 @@ typedef struct {
writing_mode wmode; /* PDF writing mode WMode (horizontal/vertical) */
pos_mode mode; /* current positioning mode */
int ishex; /* Whether the current char string is <> or () */
+ int need_tm; /* flag whether Tm needs to be set */
} pdfstructure;
typedef struct obj_entry_ {
@@ -131,7 +133,7 @@ typedef struct dest_name_entry_ {
int objnum; /* destination object number */
} dest_name_entry;
-# define pdf_max_link_level 10 /* maximum depth of link nesting */
+# define pdf_max_link_level 10/* maximum depth of link nesting */
typedef struct pdf_link_stack_record {
int nesting_level;
@@ -153,17 +155,21 @@ typedef enum {
/* |obj_type_thread| is the highest entry in |head_tab|, but there are a few
more linked lists that are handy: */
obj_type_pagestream = 7, /* Page stream objects */
- obj_type_page = 8, /* Page objects */
- obj_type_pages = 9, /* Pages objects */
- obj_type_link = 10, /* link objects */
- obj_type_bead = 11, /* thread bead objects */
- obj_type_annot = 12, /* annotation objects */
- obj_type_objstm = 13, /* /ObjStm objects */
- obj_type_others = 14 /* any other objects (also not linked in any list) */
+ obj_type_page = 8, /* /Page objects */
+ obj_type_pages = 9, /* /Pages objects */
+ obj_type_catalog = 10, /* /Catalog object */
+ obj_type_info = 11, /* /Info object */
+ obj_type_link = 12, /* link objects */
+ obj_type_annot = 13, /* annotation objects */
+ obj_type_annots = 14, /* /Annots objects */
+ obj_type_bead = 15, /* thread bead objects */
+ obj_type_beads = 16, /* /B objects (array of bead objects) */
+ obj_type_objstm = 17, /* /ObjStm objects */
+ obj_type_others = 18 /* any other objects (also not linked in any list) */
} pdf_obj_type;
# define HEAD_TAB_MAX 6 /* obj_type_thread */
-# define PDF_OBJ_TYPE_MAX 14 /* obj_type_others */
+# define PDF_OBJ_TYPE_MAX 18 /* obj_type_others */
typedef struct pdf_resource_struct_ {
struct avl_table *resources_tree;
@@ -223,7 +229,7 @@ typedef struct pdf_output_file_ {
size_t fb_limit;
char *zipbuf;
- z_stream c_stream; /* compression stream */
+ z_stream *c_stream; /* compression stream pointer */
int zip_write_state; /* which state of compression we are in */
int pk_scale_factor; /* this is just a preprocessed value that depends on
@@ -245,8 +251,7 @@ typedef struct pdf_output_file_ {
struct avl_table *obj_tree[PDF_OBJ_TYPE_MAX + 1]; /* this is useful for finding the objects back */
int pages_tail;
- int obj_ptr; /* user objects counter */
- int sys_obj_ptr; /* system objects counter, including object streams */
+ int obj_ptr; /* objects counter */
int last_pages; /* pointer to most recently generated pages object */
int last_page; /* pointer to most recently generated page object */
int last_stream; /* pointer to most recently generated stream */
@@ -284,6 +289,7 @@ typedef struct pdf_output_file_ {
int thread_level; /* depth of nesting of box containing the last thread */
int f_cur; /* TeX font number */
+ int pdflua_ref;
} pdf_output_file;
typedef pdf_output_file *PDF;
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w
index ab62fc465a1..724755f4ebc 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w
@@ -19,8 +19,8 @@
@ @c
static const char _svn_version[] =
- "$Id: pdfxform.w 3571 2010-04-02 13:50:45Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.60.x/source/texk/web2c/luatexdir/pdf/pdfxform.w $";
+ "$Id: pdfxform.w 3908 2010-10-13 19:22:02Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfxform.w $";
#include "ptexlib.h"
@@ -72,9 +72,8 @@ void scan_pdfxform(PDF pdf)
{
int k;
halfword p;
- incr(pdf->xform_count);
- pdf_create_obj(pdf, obj_type_xform, pdf->xform_count);
- k = pdf->obj_ptr;
+ pdf->xform_count++;
+ k = pdf_create_obj(pdf, obj_type_xform, pdf->xform_count);
set_obj_data_ptr(pdf, k, pdf_get_mem(pdf, pdfmem_xform_size));
if (scan_keyword("attr")) {
scan_pdf_ext_toks();
@@ -109,7 +108,7 @@ void scan_pdfrefxform(PDF pdf)
scaled_whd alt_rule, dim, nat;
alt_rule = scan_alt_rule(); /* scans |<rule spec>| to |alt_rule| */
scan_int();
- check_obj_exists(pdf, obj_type_xform, cur_val);
+ check_obj_type(pdf, obj_type_xform, cur_val);
new_whatsit(pdf_refxform_node);
nat.wd = obj_xform_width(pdf, cur_val);
nat.ht = obj_xform_height(pdf, cur_val);