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/pdfaction.w82
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfannot.w22
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w31
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfdest.w123
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdffont.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdffont.w22
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfgen.h110
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfgen.w1499
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfglyph.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w132
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfimage.w22
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdflink.w31
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdflistout.w44
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w22
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.w26
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfobj.h8
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfobj.w48
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w69
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfpage.h3
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfpage.w63
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.h (renamed from Build/source/texk/web2c/luatexdir/pdf/pagetree.h)8
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.w (renamed from Build/source/texk/web2c/luatexdir/pdf/pagetree.w)55
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfrule.w42
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w16
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w16
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w58
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdftables.h58
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdftables.w32
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfthread.w102
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdftypes.h124
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfxform.w22
31 files changed, 1555 insertions, 1339 deletions
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfaction.w b/Build/source/texk/web2c/luatexdir/pdf/pdfaction.w
index 4bef7c1d087..bc477fbed65 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfaction.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfaction.w
@@ -1,29 +1,28 @@
% pdfaction.w
-%
-% Copyright 2009-2010 Taco Hoekwater <taco@@luatex.org>
-
+%
+% Copyright 2009-2011 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
-#include "ptexlib.h"
-
static const char _svn_version[] =
- "$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 $";
+ "$Id: pdfaction.w 4442 2012-05-25 22:40:34Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfaction.w $";
+#include "ptexlib.h"
@ @c
static halfword new_action_node(void)
@@ -47,7 +46,7 @@ void delete_action_node(halfword a)
free_node(a, pdf_action_size);
}
-@ read an action specification
+@ read an action specification
@c
halfword scan_action(PDF pdf)
{
@@ -130,78 +129,83 @@ void write_action(PDF pdf, halfword p)
char *s;
int d = 0;
if (pdf_action_type(p) == pdf_action_user) {
- pdf_print_toks_ln(pdf, pdf_action_tokens(p));
+ pdf_out(pdf, '\n');
+ pdf_print_toks(pdf, pdf_action_tokens(p));
+ pdf_out(pdf, '\n');
return;
}
- pdf_printf(pdf, "<< ");
+ pdf_begin_dict(pdf);
if (pdf_action_file(p) != null) {
- pdf_printf(pdf, "/F ");
+ pdf_add_name(pdf, "F");
+ pdf_out(pdf, ' ');
s = tokenlist_to_cstring(pdf_action_file(p), true, NULL);
pdf_print_str(pdf, s);
xfree(s);
- pdf_printf(pdf, " ");
+ pdf_out(pdf, ' ');
if (pdf_action_new_window(p) > pdf_window_notset) {
- pdf_printf(pdf, "/NewWindow ");
if (pdf_action_new_window(p) == pdf_window_new)
- pdf_printf(pdf, "true ");
+ pdf_dict_add_bool(pdf, "NewWindow", 1);
else
- pdf_printf(pdf, "false ");
+ pdf_dict_add_bool(pdf, "NewWindow", 0);
}
}
switch (pdf_action_type(p)) {
case pdf_action_page:
+ pdf_dict_add_name(pdf, "S", "GoTo");
if (pdf_action_file(p) == null) {
- pdf_printf(pdf, "/S /GoTo /D [");
- pdf_print_int(pdf,
- get_obj(pdf, obj_type_page, pdf_action_id(p), false));
- pdf_printf(pdf, " 0 R");
+ pdf_add_name(pdf, "D");
+ pdf_begin_array(pdf);
+ pdf_add_ref(pdf,
+ pdf_get_obj(pdf, obj_type_page, pdf_action_id(p),
+ false));
} else {
- pdf_printf(pdf, "/S /GoToR /D [");
+ pdf_add_name(pdf, "D");
+ pdf_begin_array(pdf);
pdf_print_int(pdf, pdf_action_id(p) - 1);
}
{
char *tokstr =
tokenlist_to_cstring(pdf_action_tokens(p), true, NULL);
- pdf_printf(pdf, " %s]", tokstr);
+ pdf_printf(pdf, " %s", tokstr);
+ pdf_end_array(pdf);
xfree(tokstr);
}
break;
case pdf_action_goto:
if (pdf_action_file(p) == null) {
- pdf_printf(pdf, "/S /GoTo ");
- d = get_obj(pdf, obj_type_dest, pdf_action_id(p),
- pdf_action_named_id(p));
- } else {
- pdf_printf(pdf, "/S /GoToR ");
- }
+ pdf_dict_add_name(pdf, "S", "GoTo");
+ d = pdf_get_obj(pdf, obj_type_dest, pdf_action_id(p),
+ pdf_action_named_id(p));
+ } else
+ pdf_dict_add_name(pdf, "S", "GoToR");
if (pdf_action_named_id(p) > 0) {
char *tokstr = tokenlist_to_cstring(pdf_action_id(p), true, NULL);
- pdf_str_entry(pdf, "D", tokstr);
+ pdf_dict_add_string(pdf, "D", tokstr);
xfree(tokstr);
} else if (pdf_action_file(p) == null) {
- pdf_indirect(pdf, "D", d);
+ pdf_dict_add_ref(pdf, "D", d);
} else {
pdf_error("ext4",
"`goto' option cannot be used with both `file' and `num'");
}
break;
case pdf_action_thread:
- pdf_printf(pdf, "/S /Thread ");
+ pdf_dict_add_name(pdf, "S", "Thread");
if (pdf_action_file(p) == null) {
- d = get_obj(pdf, obj_type_thread, pdf_action_id(p),
- pdf_action_named_id(p));
+ d = pdf_get_obj(pdf, obj_type_thread, pdf_action_id(p),
+ pdf_action_named_id(p));
if (pdf_action_named_id(p) > 0) {
char *tokstr =
tokenlist_to_cstring(pdf_action_id(p), true, NULL);
- pdf_str_entry(pdf, "D", tokstr);
+ pdf_dict_add_string(pdf, "D", tokstr);
xfree(tokstr);
} else if (pdf_action_file(p) == null) {
- pdf_indirect(pdf, "D", d);
+ pdf_dict_add_ref(pdf, "D", d);
} else {
- pdf_int_entry(pdf, "D", pdf_action_id(p));
+ pdf_dict_add_int(pdf, "D", pdf_action_id(p));
}
}
break;
}
- pdf_printf(pdf, " >>\n");
+ pdf_end_dict(pdf);
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w b/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w
index b112c1a5447..4fede1f4099 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w
@@ -1,26 +1,26 @@
% pdfannot.w
-
-% Copyright 2009-2010 Taco Hoekwater <taco@@luatex.org>
-
+%
+% Copyright 2009-2011 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: 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 $";
+ "$Id: pdfannot.w 4442 2012-05-25 22:40:34Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfannot.w $";
#include "ptexlib.h"
@@ -36,7 +36,7 @@ void do_annot(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
if (doing_leaders)
return;
if (is_obj_scheduled(pdf, pdf_annot_objnum(p))) {
- k = pdf_create_obj(pdf, obj_type_annot, pdf->obj_ptr + 1);
+ k = pdf_create_obj(pdf, obj_type_annot, 0);
obj_annot_ptr(pdf, pdf_annot_objnum(p)) = p;
pdf_annot_objnum(p) = k;
}
@@ -73,7 +73,7 @@ void scan_annot(PDF pdf)
{
int k;
if (scan_keyword("reserveobjnum")) {
- k = pdf_create_obj(pdf, obj_type_annot, pdf->obj_ptr + 1);
+ k = pdf_create_obj(pdf, obj_type_annot, 0);
/* Scan an optional space */
get_x_token();
if (cur_cmd != spacer_cmd)
@@ -86,7 +86,7 @@ void scan_annot(PDF pdf)
if (obj_annot_ptr(pdf, k) != 0)
pdf_error("ext1", "annot object in use");
} else {
- k = pdf_create_obj(pdf, obj_type_annot, pdf->obj_ptr + 1);
+ k = pdf_create_obj(pdf, obj_type_annot, 0);
}
new_annot_whatsit(pdf_annot_node);
obj_annot_ptr(pdf, k) = tail;
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w b/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w
index 3ed72e0eb87..15bb5fee168 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w
@@ -1,29 +1,28 @@
% pdfcolorstack.w
-%
-% Copyright 2009-2010 Taco Hoekwater <taco@@luatex.org>
-
+%
+% Copyright 2009-2011 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/>.
+% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
-#include "ptexlib.h"
-
static const char _svn_version[] =
- "$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 $";
+ "$Id: pdfcolorstack.w 4442 2012-05-25 22:40:34Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w $";
+#include "ptexlib.h"
@* Color Stack and Matrix Transformation Support.
@@ -204,9 +203,8 @@ static int colorstackpush(int colstack_no, str_number s)
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,
- (unsigned) colstack->page_size,
- char *);
+ xretalloc(colstack->page_stack, (unsigned) colstack->page_size,
+ char *);
}
colstack->page_stack[colstack->page_used++] = colstack->page_current;
str = makecstring(s);
@@ -219,9 +217,8 @@ static int colorstackpush(int colstack_no, str_number s)
} else {
if (colstack->form_used == colstack->form_size) {
colstack->form_size += STACK_INCREMENT;
- colstack->form_stack = xretalloc(colstack->form_stack,
- (unsigned) colstack->form_size,
- char *);
+ xretalloc(colstack->form_stack, (unsigned) colstack->form_size,
+ char *);
}
colstack->form_stack[colstack->form_used++] = colstack->form_current;
str = makecstring(s);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfdest.w b/Build/source/texk/web2c/luatexdir/pdf/pdfdest.w
index 6081369e8b8..94cfa7f82fd 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfdest.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfdest.w
@@ -1,26 +1,26 @@
% pdfdest.w
-
-% Copyright 2009-2010 Taco Hoekwater <taco@@luatex.org>
-
+%
+% Copyright 2009-2011 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/>.
+% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
static const char _svn_version[] =
- "$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 $";
+ "$Id: pdfdest.w 4448 2012-06-21 15:07:03Z taco $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfdest.w $";
#include "ptexlib.h"
@@ -92,7 +92,7 @@ void do_dest(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
pdf_error("ext4", "destinations cannot be inside an XForm");
if (doing_leaders)
return;
- k = get_obj(pdf, obj_type_dest, pdf_dest_id(p), pdf_dest_named_id(p));
+ k = pdf_get_obj(pdf, obj_type_dest, pdf_dest_id(p), pdf_dest_named_id(p));
if (obj_dest_ptr(pdf, k) != null) {
warn_dest_dup(pdf_dest_id(p), (small_number) pdf_dest_named_id(p),
"ext4", "has been already used, duplicate ignored");
@@ -103,6 +103,7 @@ void do_dest(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
alt_rule.wd = width(p);
alt_rule.ht = height(p);
alt_rule.dp = depth(p);
+ /* the different branches for matrixused is somewhat strange and should always be used */
switch (pdf_dest_type(p)) {
case pdf_dest_xyz:
if (matrixused())
@@ -146,65 +147,63 @@ void write_out_pdf_mark_destinations(PDF pdf)
} else {
int i;
i = obj_dest_ptr(pdf, k->info);
+ pdf_begin_obj(pdf, k->info, OBJSTM_ALWAYS);
if (pdf_dest_named_id(i) > 0) {
- pdf_begin_dict(pdf, k->info, 1);
- pdf_printf(pdf, "/D ");
- } else {
- pdf_begin_obj(pdf, k->info, 1);
+ pdf_begin_dict(pdf);
+ pdf_add_name(pdf, "D");
}
- pdf_out(pdf, '[');
- pdf_print_int(pdf, pdf->last_page);
- pdf_printf(pdf, " 0 R ");
+ pdf_begin_array(pdf);
+ pdf_add_ref(pdf, pdf->last_page);
switch (pdf_dest_type(i)) {
case pdf_dest_xyz:
- pdf_printf(pdf, "/XYZ ");
- pdf_print_mag_bp(pdf, pdf_ann_left(i));
- pdf_out(pdf, ' ');
- pdf_print_mag_bp(pdf, pdf_ann_top(i));
- pdf_out(pdf, ' ');
+ pdf_add_name(pdf, "XYZ");
+ pdf_add_mag_bp(pdf, pdf_ann_left(i));
+ pdf_add_mag_bp(pdf, pdf_ann_top(i));
if (pdf_dest_xyz_zoom(i) == null) {
- pdf_printf(pdf, "null");
+ pdf_add_null(pdf);
} else {
+ if (pdf->cave == 1)
+ pdf_out(pdf, ' ');
pdf_print_int(pdf, pdf_dest_xyz_zoom(i) / 1000);
pdf_out(pdf, '.');
pdf_print_int(pdf, (pdf_dest_xyz_zoom(i) % 1000));
+ pdf->cave = 1;
}
break;
case pdf_dest_fit:
- pdf_printf(pdf, "/Fit");
+ pdf_add_name(pdf, "Fit");
break;
case pdf_dest_fith:
- pdf_printf(pdf, "/FitH ");
- pdf_print_mag_bp(pdf, pdf_ann_top(i));
+ pdf_add_name(pdf, "FitH");
+ pdf_add_mag_bp(pdf, pdf_ann_top(i));
break;
case pdf_dest_fitv:
- pdf_printf(pdf, "/FitV ");
- pdf_print_mag_bp(pdf, pdf_ann_left(i));
+ pdf_add_name(pdf, "FitV");
+ pdf_add_mag_bp(pdf, pdf_ann_left(i));
break;
case pdf_dest_fitb:
- pdf_printf(pdf, "/FitB");
+ pdf_add_name(pdf, "FitB");
break;
case pdf_dest_fitbh:
- pdf_printf(pdf, "/FitBH ");
- pdf_print_mag_bp(pdf, pdf_ann_top(i));
+ pdf_add_name(pdf, "FitBH");
+ pdf_add_mag_bp(pdf, pdf_ann_top(i));
break;
case pdf_dest_fitbv:
- pdf_printf(pdf, "/FitBV ");
- pdf_print_mag_bp(pdf, pdf_ann_left(i));
+ pdf_add_name(pdf, "FitBV");
+ pdf_add_mag_bp(pdf, pdf_ann_left(i));
break;
case pdf_dest_fitr:
- pdf_printf(pdf, "/FitR ");
- pdf_print_rect_spec(pdf, i);
+ pdf_add_name(pdf, "FitR");
+ pdf_add_rect_spec(pdf, i);
break;
default:
pdf_error("ext5", "unknown dest type");
break;
}
- pdf_printf(pdf, "]\n");
+ pdf_end_array(pdf);
if (pdf_dest_named_id(i) > 0)
pdf_end_dict(pdf);
- else
- pdf_end_obj(pdf);
+ pdf_end_obj(pdf);
}
k = k->link;
}
@@ -307,7 +306,6 @@ void sort_dest_names(PDF pdf)
sizeof(dest_name_entry), dest_cmp);
}
-
@ Output the name tree. The tree nature of the destination list forces the
storing of intermediate data in |obj_info| and |obj_aux| fields, which
is further uglified by the fact that |obj_tab| entries do not accept char
@@ -343,21 +341,20 @@ int output_name_tree(PDF pdf)
}
set_obj_link(pdf, names_tail, 0);
/* Output the current node in this level */
- pdf_begin_dict(pdf, l, 1);
+ pdf_begin_obj(pdf, l, OBJSTM_ALWAYS);
+ pdf_begin_dict(pdf);
j = 0;
if (is_names) {
set_obj_start(pdf, l, pdf->dest_names[k].objname);
- pdf_printf(pdf, "/Names [");
+ pdf_add_name(pdf, "Names");
+ pdf_begin_array(pdf);
do {
- pdf_print_str(pdf, pdf->dest_names[k].objname);
- pdf_out(pdf, ' ');
- pdf_print_int(pdf, pdf->dest_names[k].objnum);
- pdf_printf(pdf, " 0 R ");
+ pdf_add_string(pdf, pdf->dest_names[k].objname);
+ pdf_add_ref(pdf, pdf->dest_names[k].objnum);
j++;
k++;
} while (j != name_tree_kids_max && k != pdf->dest_names_ptr);
- pdf_remove_last_space(pdf);
- pdf_printf(pdf, "]\n");
+ pdf_end_array(pdf);
set_obj_stop(pdf, l, pdf->dest_names[k - 1].objname); /* for later */
if (k == pdf->dest_names_ptr) {
is_names = false;
@@ -367,48 +364,48 @@ int output_name_tree(PDF pdf)
} else {
set_obj_start(pdf, l, obj_start(pdf, k));
- pdf_printf(pdf, "/Kids [");
+ pdf_add_name(pdf, "Kids");
+ pdf_begin_array(pdf);
do {
- pdf_print_int(pdf, k);
- pdf_printf(pdf, " 0 R ");
+ pdf_add_ref(pdf, k);
set_obj_stop(pdf, l, obj_stop(pdf, k));
k = obj_link(pdf, k);
j++;
} while (j != name_tree_kids_max && k != b
&& obj_link(pdf, k) != 0);
- pdf_remove_last_space(pdf);
- pdf_printf(pdf, "]\n");
+ pdf_end_array(pdf);
if (k == b)
b = 0;
}
- pdf_printf(pdf, "/Limits [");
- pdf_print_str(pdf, obj_start(pdf, l));
- pdf_out(pdf, ' ');
- pdf_print_str(pdf, obj_stop(pdf, l));
- pdf_printf(pdf, "]\n");
+ pdf_add_name(pdf, "Limits");
+ pdf_begin_array(pdf);
+ pdf_add_string(pdf, obj_start(pdf, l));
+ pdf_add_string(pdf, obj_stop(pdf, l));
+ pdf_end_array(pdf);
pdf_end_dict(pdf);
-
-
+ pdf_end_obj(pdf);
} while (b != 0);
if (k == l) {
dests = l;
goto DONE;
}
-
}
DONE:
if ((dests != 0) || (pdf_names_toks != null)) {
- m = pdf_new_dict(pdf, obj_type_others, 0, 1);
+ m = pdf_create_obj(pdf, obj_type_others, 0);
+ pdf_begin_obj(pdf, m, OBJSTM_ALWAYS);
+ pdf_begin_dict(pdf);
if (dests != 0)
- pdf_indirect_ln(pdf, "Dests", dests);
+ pdf_dict_add_ref(pdf, "Dests", dests);
if (pdf_names_toks != null) {
- pdf_print_toks_ln(pdf, pdf_names_toks);
+ pdf_print_toks(pdf, pdf_names_toks);
delete_token_ref(pdf_names_toks);
pdf_names_toks = null;
}
pdf_end_dict(pdf);
+ pdf_end_obj(pdf);
return m;
} else {
return 0;
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdffont.h b/Build/source/texk/web2c/luatexdir/pdf/pdffont.h
index aabe66a4792..b20caf91ccc 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdffont.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdffont.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: pdffont.h 3430 2010-02-11 21:42:02Z hhenkel $ */
+/* $Id: pdffont.h 4576 2013-02-08 20:42:57Z hhenkel $ */
#ifndef PDFFONT_H
# define PDFFONT_H
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdffont.w b/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
index 0a33057f368..af645e4e5e3 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
@@ -1,28 +1,28 @@
% pdffont.w
-
-% Copyright 2009-2010 Taco Hoekwater <taco@@luatex.org>
-
+%
+% Copyright 2009-2012 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/>.
+% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
\def\pdfTeX{pdf\TeX}
@ @c
static const char _svn_version[] =
- "$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 $";
+ "$Id: pdffont.w 4576 2013-02-08 20:42:57Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdffont.w $";
#include "ptexlib.h"
@@ -37,7 +37,7 @@ fonts too. Information about virtual fonts can be found in the source of some
\.{DVI}-related programs.
Whenever we want to write out a character in a font to PDF output, we
-should check whether the used character is a virtual or read character.
+should check whether the used character is a virtual or real character.
The |has_packet()| C macro checks for this condition.
@@ -62,6 +62,8 @@ void output_one_char(PDF pdf, internal_font_number ffi, int c)
pos_down(ci.ht);
pos_left(ci.wd / 2);
break;
+ default:
+ assert(0);
}
if (has_packet(ffi, c)) {
do_vf_packet(pdf, ffi, c);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h
index 0bc83c7e04d..daf6c81cba0 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h
@@ -1,6 +1,6 @@
/* pdfgen.h
- Copyright 2009-2010 Taco Hoekwater <taco@luatex.org>
+ Copyright 2009-2013 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
@@ -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 3940 2010-11-01 22:46:24Z hhenkel $ */
+/* $Id: pdfgen.h 4558 2013-01-19 14:21:59Z oneiros $ */
#ifndef PDFGEN_H
# define PDFGEN_H
@@ -28,7 +28,7 @@
# define PROCSET_IMAGE_C (1 << 3)
# define PROCSET_IMAGE_I (1 << 4)
-# define inf_pdf_mem_size 10000 /* min size of the |mem| array */
+# define inf_pdf_mem_size 10000/* min size of the |mem| array */
# define sup_pdf_mem_size 10000000 /* max size of the |mem| array */
extern PDF static_pdf;
@@ -43,25 +43,22 @@ output file in initialization to ensure that it will be the first
written bytes.
*/
-# define inf_pdf_op_buf_size 16384 /* size of the PDF output buffer */
-# define sup_pdf_op_buf_size 16384 /* size of the PDF output buffer */
-# define inf_pdf_os_buf_size 1 /* initial value of |pdf_os_buf_size| */
-# define sup_pdf_os_buf_size 5000000 /* arbitrary upper hard limit of |pdf_os_buf_size| */
-# define max_single_pdf_print 8192 /* Max size that can be get from pdf_room() at once.
- the value is on the conservative side, but should be
- large enough to cover most uses */
-# define pdf_os_max_objs 100 /* maximum number of objects in object stream */
+# define inf_pdfout_buf_size 16384 /* initial value of |pdf->buf| size */
+# define sup_pdfout_buf_size 16384 /* arbitrary upper hard limit of |pdf->buf| size */
+# define inf_objstm_buf_size 1 /* initial value of |os->buf[OBJSTM_BUF]| size */
+# define sup_objstm_buf_size 5000000 /* arbitrary upper hard limit of |os->buf[OBJSTM_BUF]| size */
+
+# define PDF_OS_MAX_OBJS 100 /* maximum number of objects in object stream */
# define inf_obj_tab_size 1000 /* min size of the cross-reference table for PDF output */
# define sup_obj_tab_size 8388607 /* max size of the cross-reference table for PDF output */
/* The following macros are similar as for \.{DVI} buffer handling */
-# define pdf_offset(pdf) (pdf->gone + pdf->ptr)
+# define pdf_offset(pdf) (pdf->gone + (off_t)(pdf->buf->p - pdf->buf->data))
/* the file offset of last byte in PDF
buffer that |pdf_ptr| points to */
-# define pdf_save_offset(pdf) pdf->save_offset=(pdf->gone + pdf->ptr)
-# define pdf_saved_offset(pdf) pdf->save_offset
+# define pdf_save_offset(pdf) pdf->save_offset = (pdf->gone + (off_t)(pdf->buf->p - pdf->buf->data))
# define set_ff(A) do { \
if (pdf_font_num(A) < 0) \
@@ -70,12 +67,6 @@ written bytes.
ff = A; \
} while (0)
-typedef enum {
- no_zip = 0, /* no \.{ZIP} compression */
- zip_writing = 1, /* \.{ZIP} compression being used */
- 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;
@@ -96,19 +87,10 @@ extern void pdf_room(PDF, int);
extern void fix_pdf_minorversion(PDF);
/* output a byte to PDF buffer without checking of overflow */
-# define pdf_quick_out(pdf,A) pdf->buf[pdf->ptr++]=(unsigned char)A
+# define pdf_quick_out(pdf,A) * (pdf->buf->p++) = (unsigned char) (A)
/* 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)
-
-# 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
+# define pdf_out(pdf,A) do { pdf_room(pdf, 1); pdf_quick_out(pdf, A); } while (0)
/*
Basic printing procedures for PDF output are very similiar to \TeX\ basic
@@ -116,39 +98,53 @@ 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_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_newline_char)
-
/* print out a string to PDF buffer followed by a new-line character */
# define pdf_print_ln(pdf,A) do { \
pdf_print(pdf,A); \
- pdf_print_nl(pdf); \
+ pdf_out(pdf, '\n'); \
} while (0)
/* print out an integer to PDF buffer followed by a new-line character */
-# define pdf_print_int_ln(pdf,A) do { \
- pdf_print_int(pdf,A); \
- pdf_print_nl(pdf); \
+# define pdf_print_int_ln(pdf,A) do { \
+ pdf_print_int(pdf,A); \
+ pdf_out(pdf, '\n'); \
} while (0)
extern __attribute__ ((format(printf, 2, 3)))
void pdf_printf(PDF, const char *, ...);
-extern void pdf_print_char(PDF, int);
-extern void pdf_print_wide_char(PDF, int);
extern void pdf_print(PDF, str_number);
extern void pdf_print_int(PDF, longinteger);
-extern void pdf_print_real(PDF, int, int);
+extern void print_pdffloat(PDF pdf, pdffloat f);
extern void pdf_print_str(PDF, const char *);
+extern void pdf_add_null(PDF);
+extern void pdf_add_bool(PDF, int i);
+extern void pdf_add_int(PDF, int i);
+extern void pdf_add_longint(PDF, longinteger n);
+extern void pdf_add_ref(PDF, int num);
+extern void pdf_add_string(PDF, const char *s);
+extern void pdf_add_name(PDF, const char *name);
+
+extern void pdf_dict_add_bool(PDF, const char *key, int i);
+extern void pdf_dict_add_int(PDF, const char *key, int i);
+extern void pdf_dict_add_ref(PDF, const char *key, int num);
+extern void pdf_dict_add_name(PDF, const char *key, const char *val);
+extern void pdf_dict_add_string(PDF pdf, const char *key, const char *val);
+extern void pdf_dict_add_streaminfo(PDF);
+
extern void pdf_begin_stream(PDF);
extern void pdf_end_stream(PDF);
-extern void pdf_remove_last_space(PDF);
-extern void pdf_print_bp(PDF, scaled);
-extern void pdf_print_mag_bp(PDF, scaled);
+extern void pdf_add_bp(PDF, scaled);
+extern void pdf_add_mag_bp(PDF, scaled);
+
+extern strbuf_s *new_strbuf(size_t size, size_t limit);
+extern void strbuf_seek(strbuf_s * b, off_t offset);
+extern size_t strbuf_offset(strbuf_s * b);
+extern void strbuf_putchar(strbuf_s * b, unsigned char c);
+extern void strbuf_flush(PDF pdf, strbuf_s * b);
+extern void strbuf_free(strbuf_s * b);
/* This is for the resource lists */
@@ -164,36 +160,23 @@ extern void pdf_out_block(PDF pdf, const char *s, size_t n);
pdf_puts(pdf, pdf->resname_prefix); \
} while (0)
-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);
-extern void pdf_indirect_ln(PDF, const char *, int);
extern void pdf_print_str_ln(PDF, const char *);
-extern void pdf_str_entry(PDF, const char *, const char *);
-extern void pdf_str_entry_ln(PDF, const char *, const char *);
extern void pdf_print_toks(PDF, halfword);
-extern void pdf_print_toks_ln(PDF, halfword);
-extern void pdf_print_rect_spec(PDF, halfword);
+extern void pdf_add_rect_spec(PDF, halfword);
extern void pdf_rectangle(PDF, halfword);
extern void pdf_begin_obj(PDF, 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 int pdf_new_dict(PDF, int, int, int);
+extern void pdf_begin_dict(PDF);
extern void pdf_end_dict(PDF);
+extern void pdf_begin_array(PDF);
+extern void pdf_end_array(PDF);
extern void remove_pdffile(PDF);
-extern int fb_offset(PDF);
-extern void fb_flush(PDF);
-extern void fb_putchar(PDF, eight_bits);
-extern void fb_seek(PDF, int);
-extern void fb_free(PDF);
-
extern void zip_free(PDF);
/* functions that do not output stuff */
@@ -213,6 +196,7 @@ extern char *get_resname_prefix(PDF);
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 int get_pdf_table_bool(PDF, const char *, int);
extern void fix_o_mode(PDF pdf);
extern void ensure_output_state(PDF pdf, output_state s);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w
index 3543ec3b5ef..8e2ab31177f 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w
@@ -1,26 +1,26 @@
% pdfgen.w
-
-% Copyright 2009-2010 Taco Hoekwater <taco@@luatex.org>
-
+%
+% Copyright 2009-2013 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: pdfgen.w 4253 2011-05-09 11:13:00Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/branches/0.70.x/source/texk/web2c/luatexdir/pdf/pdfgen.w $";
+ "$Id: pdfgen.w 4568 2013-01-27 13:10:11Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfgen.w $";
#include "ptexlib.h"
@@ -38,8 +38,6 @@ static const char _svn_version[] =
PDF static_pdf = NULL;
-static char *jobname_cstr = NULL;
-
@ commandline interface
@c
int pdf_output_option;
@@ -54,26 +52,114 @@ halfword pdf_names_toks; /* additional keys of Names dictionary */
halfword pdf_trailer_toks; /* additional keys of Trailer dictionary */
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
+@ Create a new buffer |strbuf_s| of size |size| and maximum allowed size |limit|.
+Initialize it and set |p| to begin of data.
+@c
+strbuf_s *new_strbuf(size_t size, size_t limit)
+{
+ strbuf_s *b;
+ assert(limit >= size);
+ b = xtalloc(1, strbuf_s);
+ b->size = size;
+ b->limit = limit;
+ if (size > 0)
+ b->p = b->data = xtalloc(b->size, unsigned char);
+ else
+ b->p = b->data = NULL; /* for other alloc */
+ return b;
+}
+
+@ Check that |n| bytes more fit into buffer; increase it if required.
+@c
+static void strbuf_room(strbuf_s * b, size_t n)
+{
+ unsigned int a;
+ size_t l = (size_t) (b->p - b->data);
+ if (n > b->limit - l)
+ overflow("PDF buffer", (unsigned) b->size);
+ if (n + l > b->size) {
+ a = (unsigned int) (b->size >> 2);
+ if (n + l > b->size + a)
+ b->size = n + l;
+ else if (b->size < b->limit - a)
+ b->size = b->size + a;
+ else
+ b->size = b->limit;
+ b->data = xreallocarray(b->data, unsigned char, (unsigned) b->size);
+ b->p = b->data + l;
+ }
+}
+
+@ Seek to position |offset| within buffer. Position must be valid.
+@c
+void strbuf_seek(strbuf_s * b, off_t offset)
+{
+ assert(offset >= 0 && offset < (off_t) b->size);
+ b->p = b->data + offset;
+}
+
+@ Get the current buffer fill level, the number of characters.
+@c
+size_t strbuf_offset(strbuf_s * b)
+{
+ return (size_t) (b->p - b->data);
+}
+
+@ Put one character into buffer. Make room before if needed.
+@c
+void strbuf_putchar(strbuf_s * b, unsigned char c)
+{
+ if ((size_t) (b->p - b->data + 1) > b->size)
+ strbuf_room(b, 1);
+ *b->p++ = c;
+}
+@ Dump filled buffer part to PDF.
+@c
+void strbuf_flush(PDF pdf, strbuf_s * b)
+{
+ pdf_out_block(pdf, (const char *) b->data, strbuf_offset(b));
+ strbuf_seek(b, 0);
+}
+
+@ Free all dynamically allocated buffer structures.
+@c
+void strbuf_free(strbuf_s * b)
+{
+ xfree(b->data);
+ xfree(b);
+}
+
+@ |init_pdf_struct()| is called early, only once, from maincontrol.w
@c
PDF init_pdf_struct(PDF pdf)
{
+ os_struct *os;
assert(pdf == NULL);
pdf = xtalloc(1, pdf_output_file);
memset(pdf, 0, sizeof(pdf_output_file));
+ pdf->job_name = makecstring(job_name);
pdf->o_mode = OMODE_NONE; /* will be set by |fix_o_mode()| */
pdf->o_state = ST_INITIAL;
- pdf->os_obj = xtalloc(pdf_os_max_objs, os_obj_data);
- pdf->os_buf_size = inf_pdf_os_buf_size;
- pdf->os_buf = xtalloc(pdf->os_buf_size, unsigned char);
- pdf->op_buf_size = inf_pdf_op_buf_size;
- pdf->op_buf = xtalloc(pdf->op_buf_size, unsigned char);
+ /* init PDF and object stream writing */
+ pdf->os = os = xtalloc(1, os_struct);
+ memset(pdf->os, 0, sizeof(os_struct));
+ os->buf[PDFOUT_BUF] = new_strbuf(inf_pdfout_buf_size, sup_pdfout_buf_size);
+ os->buf[OBJSTM_BUF] = new_strbuf(inf_objstm_buf_size, sup_objstm_buf_size);
+ os->buf[LUASTM_BUF] = new_strbuf(0, 0);
+ os->obj = xtalloc(PDF_OS_MAX_OBJS, os_obj_data);
+ os->cur_objstm = 0;
+ os->trigger_luastm = false;
+
+ os->curbuf = PDFOUT_BUF;
+ pdf->buf = os->buf[os->curbuf];
- pdf->buf_size = pdf->op_buf_size;
- pdf->buf = pdf->op_buf;
+ pdf->fb = new_strbuf(1, 100000000);
+
+ pdf->stream_deflate = false;
+ pdf->stream_writing = false;
/* Sometimes it is neccesary to allocate memory for PDF output that cannot
be deallocated then, so we use |mem| for this purpose. */
@@ -112,26 +198,9 @@ PDF init_pdf_struct(PDF pdf)
init_pdf_pagecalculations(pdf);
pdf->pdflua_ref = new_pdflua();
- return pdf;
-}
-
-@ @c
-static void pdf_shipout_begin(void)
-{
- pos_stack_used = 0; /* start with empty stack */
-
- if (global_shipping_mode == SHIPPING_PAGE) {
- colorstackpagestart();
- }
-}
+ pdf->vfstruct = new_vfstruct();
-static void pdf_shipout_end(void)
-{
- if (pos_stack_used > 0) {
- pdftex_fail("%u unmatched \\pdfsave after %s shipout",
- (unsigned int) pos_stack_used,
- ((global_shipping_mode == SHIPPING_PAGE) ? "page" : "form"));
- }
+ return pdf;
}
@ We use |pdf_get_mem| to allocate memory in |mem|.
@@ -144,7 +213,7 @@ int pdf_get_mem(PDF pdf, int s)
if (s > sup_pdf_mem_size - pdf->mem_ptr)
overflow("PDF memory size (pdf_mem_size)", (unsigned) pdf->mem_size);
if (pdf->mem_ptr + s > pdf->mem_size) {
- a = pdf->mem_size / 5;
+ a = pdf->mem_size >> 2;
if (pdf->mem_ptr + s > pdf->mem_size + a) {
pdf->mem_size = pdf->mem_ptr + s;
} else if (pdf->mem_size < sup_pdf_mem_size - a) {
@@ -238,8 +307,9 @@ static void write_zip(PDF pdf)
{
int flush, err = Z_OK;
uInt zip_len;
+ strbuf_s *buf = pdf->buf;
z_stream *s = pdf->c_stream;
- boolean finish = pdf->zip_write_state == zip_finish;
+ 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
@@ -265,8 +335,8 @@ static void write_zip(PDF pdf)
}
assert(s != NULL);
assert(pdf->zipbuf != NULL);
- s->next_in = pdf->buf;
- s->avail_in = (uInt) pdf->ptr;
+ s->next_in = buf->data;
+ s->avail_in = (uInt) (buf->p - buf->data);
while (true) {
if (s->avail_out == 0 || (finish && s->avail_out < ZIP_BUF_SIZE)) {
zip_len = ZIP_BUF_SIZE - s->avail_out;
@@ -280,6 +350,7 @@ static void write_zip(PDF pdf)
assert(s->avail_in == 0);
assert(s->avail_out == ZIP_BUF_SIZE);
xfflush(pdf->file);
+ pdf->zip_write_state = NO_ZIP;
break;
}
flush = Z_FINISH;
@@ -305,6 +376,19 @@ void zip_free(PDF pdf)
xfree(pdf->c_stream);
}
+@ @c
+static void write_nozip(PDF pdf)
+{
+ strbuf_s *buf = pdf->buf;
+ size_t l = strbuf_offset(buf);
+ if (l == 0)
+ return;
+ pdf->stream_length = pdf_offset(pdf) - pdf->save_offset;
+ pdf->gone +=
+ (off_t) xfwrite((char *) buf->data, sizeof(char), l, pdf->file);
+ pdf->last_byte = *(buf->p - 1);
+}
+
@ 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|
@@ -312,173 +396,146 @@ to finish it. The stream contents will be compressed if compression is turn on.
@c
void pdf_flush(PDF pdf)
-{ /* flush out the |pdf_buf| */
-
- off_t saved_pdf_gone;
- if (!pdf->os_mode) {
- saved_pdf_gone = pdf->gone;
- switch (pdf->zip_write_state) {
- case no_zip:
- if (pdf->ptr > 0) {
- if (pdf->draftmode == 0)
- (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);
- break;
- case zip_finish:
- if (pdf->draftmode == 0)
+{ /* flush out the |pdf->buf| */
+ os_struct *os = pdf->os;
+ off_t saved_pdf_gone = pdf->gone;
+ assert(pdf->buf == os->buf[os->curbuf]);
+ switch (os->curbuf) {
+ case PDFOUT_BUF:
+ if (pdf->draftmode == 0) {
+ switch (pdf->zip_write_state) {
+ case NO_ZIP:
+ write_nozip(pdf);
+ break;
+ case ZIP_WRITING:
+ case ZIP_FINISH:
write_zip(pdf);
- pdf->zip_write_state = no_zip;
- break;
- }
- pdf->ptr = 0;
+ break;
+ default:
+ assert(0);
+ }
+ } else
+ pdf->zip_write_state = NO_ZIP;
+ strbuf_seek(pdf->buf, 0);
if (saved_pdf_gone > pdf->gone)
pdf_error("file size",
"File size exceeds architectural limits (pdf_gone wraps around)");
+ break;
+ case LUASTM_BUF:
+ luaL_addsize(&(os->b), strbuf_offset(pdf->buf));
+ pdf->buf->p = pdf->buf->data = (unsigned char *) luaL_prepbuffer(&(os->b)); /* for next stream piece */
+ break;
+ case OBJSTM_BUF:
+ break;
+ default:
+ assert(0);
}
}
-@ switch between PDF stream and object stream mode
-
-@c
-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 */
- pdf->op_ptr = pdf->ptr;
- pdf->ptr = pdf->os_ptr;
- pdf->buf = pdf->os_buf;
- pdf->buf_size = pdf->os_buf_size;
- pdf->os_mode = true; /* switch to object stream */
- }
- } else {
- if (pdf->os_mode) { /* back up object stream variables */
- pdf->os_ptr = pdf->ptr;
- pdf->ptr = pdf->op_ptr;
- pdf->buf = pdf->op_buf;
- pdf->buf_size = pdf->op_buf_size;
- pdf->os_mode = false; /* switch to PDF stream */
- }
- }
+@ @c
+static void pdf_buffer_select(PDF pdf, buffer_e buf)
+{
+ os_struct *os = pdf->os;
+ if (pdf->os_enable && buf == OBJSTM_BUF)
+ os->curbuf = OBJSTM_BUF; /* switch to object stream */
+ else
+ os->curbuf = PDFOUT_BUF; /* switch to PDF stream */
+ pdf->buf = os->buf[pdf->os->curbuf];
}
-@ create new \.{/ObjStm} object if required, and set up cross reference info
+@ create new \.{/ObjStm} object if required, and set up cross reference info
@c
-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->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 */
- } else {
- pdf->os_idx++;
+static void pdf_prepare_obj(PDF pdf, int k, int pdf_os_threshold)
+{
+ os_struct *os = pdf->os;
+ strbuf_s *obuf = os->buf[OBJSTM_BUF];
+ assert(os->curbuf != LUASTM_BUF);
+ assert(pdf_os_threshold >= OBJSTM_ALWAYS);
+ if (pdf->objcompresslevel >= pdf_os_threshold)
+ pdf_buffer_select(pdf, OBJSTM_BUF);
+ else
+ pdf_buffer_select(pdf, PDFOUT_BUF);
+ assert(pdf->buf == os->buf[os->curbuf]);
+ switch (os->curbuf) {
+ case PDFOUT_BUF:
+ obj_offset(pdf, k) = pdf_offset(pdf);
+ obj_os_idx(pdf, k) = PDF_OS_MAX_OBJS; /* mark it as not included in any ObjStm */
+ break;
+ case LUASTM_BUF:
+ assert(0);
+ break;
+ case OBJSTM_BUF:
+ if (os->cur_objstm == 0) {
+ os->cur_objstm =
+ (unsigned int) pdf_create_obj(pdf, obj_type_objstm, 0);
+ os->idx = 0;
+ obuf->p = obuf->data; /* start fresh object stream */
+ os->ostm_ctr++; /* only for statistics */
}
- obj_os_idx(pdf, i) = pdf->os_idx;
- obj_offset(pdf, i) = pdf->os_cur_objnum;
- pdf->os_obj[pdf->os_idx].num = i;
- pdf->os_obj[pdf->os_idx].off = pdf->ptr;
- } else {
- obj_offset(pdf, i) = pdf_offset(pdf);
- obj_os_idx(pdf, i) = -1; /* mark it as not included in object stream */
+ assert(os->idx < PDF_OS_MAX_OBJS); /* for marking below */
+ obj_os_idx(pdf, k) = (int) os->idx;
+ obj_os_objnum(pdf, k) = (int) os->cur_objstm;
+ os->obj[os->idx].num = k;
+ os->obj[os->idx].off = obuf->p - obuf->data;
+ break;
+ default:
+ assert(0);
}
}
-@* low-level buffer checkers.
+@* Low-level buffer checkers.
-@ check that |s| bytes more fit into |pdf_os_buf|; increase it if required
-@c
-static void pdf_os_get_os_buf(PDF pdf, int s)
-{
- int a;
- if (s > sup_pdf_os_buf_size - pdf->ptr)
- overflow("PDF object stream buffer", (unsigned) pdf->os_buf_size);
- if (pdf->ptr + s > pdf->os_buf_size) {
- a = pdf->os_buf_size / 5;
- if (pdf->ptr + s > pdf->os_buf_size + a)
- pdf->os_buf_size = pdf->ptr + s;
- else if (pdf->os_buf_size < sup_pdf_os_buf_size - a)
- pdf->os_buf_size = pdf->os_buf_size + a;
- else
- pdf->os_buf_size = sup_pdf_os_buf_size;
- pdf->os_buf =
- xreallocarray(pdf->os_buf, unsigned char,
- (unsigned) pdf->os_buf_size);
- pdf->buf = pdf->os_buf;
- pdf->buf_size = pdf->os_buf_size;
- }
-}
-
-@ make sure that there are at least |n| bytes free in PDF buffer
+@ Set the active buffer pointer.
+Make sure that there are at least |n| bytes free in that buffer,
+flush if needed.
@c
void pdf_room(PDF pdf, int n)
{
- if (pdf->os_mode && (n + pdf->ptr > pdf->buf_size))
- pdf_os_get_os_buf(pdf, n);
- else if ((!pdf->os_mode) && (n > pdf->buf_size))
- overflow("PDF output buffer", (unsigned) pdf->op_buf_size);
- else if ((!pdf->os_mode) && (n + pdf->ptr > pdf->buf_size))
- pdf_flush(pdf);
-}
-
-
-@ print out a character to PDF buffer; the character will be printed in octal
- form in the following cases: chars <= 32, backslash (92), left parenthesis
- (40) and right parenthesis (41)
-
-@c
-#define pdf_print_escaped(c) \
- if ((c)<=32||(c)=='\\'||(c)=='('||(c)==')'||(c)>127) { \
- pdf_room(pdf,4); \
- pdf_quick_out(pdf,'\\'); \
- pdf_quick_out(pdf,(unsigned char)('0' + (((c)>>6) & 0x3))); \
- pdf_quick_out(pdf,(unsigned char)('0' + (((c)>>3) & 0x7))); \
- pdf_quick_out(pdf,(unsigned char)('0' + ( (c) & 0x7))); \
- } else { \
- pdf_out(pdf,(c)); \
- }
-
-void pdf_print_char(PDF pdf, int c)
-{
- if (c > 255)
+ os_struct *os = pdf->os;
+ strbuf_s *buf = pdf->buf;
+ if ((size_t) (n + buf->p - buf->data) <= buf->size)
return;
- pdf_print_escaped(c);
+ assert(buf == os->buf[os->curbuf]);
+ switch (os->curbuf) {
+ case PDFOUT_BUF:
+ if ((size_t) n > buf->size)
+ overflow("PDF output buffer", (unsigned) buf->size);
+ if ((size_t) (n + buf->p - buf->data) < buf->limit)
+ strbuf_room(buf, (size_t) n); /* grow it if possible */
+ else
+ pdf_flush(pdf);
+ break;
+ case LUASTM_BUF:
+ if ((size_t) n > buf->size)
+ overflow("PDF output buffer", (unsigned) buf->size);
+ pdf_flush(pdf);
+ break;
+ case OBJSTM_BUF:
+ strbuf_room(buf, (size_t) n); /* just grow it */
+ break;
+ default:
+ assert(0);
+ }
}
@ @c
void pdf_out_block(PDF pdf, const char *s, size_t n)
{
size_t l;
+ strbuf_s *buf = pdf->buf;
do {
l = n;
- if ((int) l > pdf->buf_size)
- l = (size_t) pdf->buf_size;
+ if (l > buf->size)
+ l = buf->size;
pdf_room(pdf, (int) l);
- (void) memcpy(pdf->buf + pdf->ptr, s, l);
- pdf->ptr += (int) l;
+ (void) memcpy(buf->p, s, l);
+ buf->p += l;
s += l;
n -= l;
} while (n > 0);
}
-void pdf_print_wide_char(PDF pdf, int c)
-{
- char hex[5];
- snprintf(hex, 5, "%04X", c);
- pdf_out_block(pdf, (const char *) hex, 4);
-}
-
@ @c
__attribute__ ((format(printf, 2, 3)))
void pdf_printf(PDF pdf, const char *fmt, ...)
@@ -513,60 +570,40 @@ void pdf_print(PDF pdf, str_number s)
@c
void pdf_print_int(PDF pdf, longinteger n)
{
- register int k = 0; /* current digit; we assume that $|n|<10^{23}$ */
- int dig[24];
- if (n < 0) {
- pdf_out(pdf, '-');
- if (n < -0x7FFFFFFF) { /* need to negate |n| more carefully */
- register longinteger m;
- k++;
- m = -1 - n;
- n = m / 10;
- m = (m % 10) + 1;
- if (m < 10) {
- dig[0] = (int) m;
- } else {
- dig[0] = 0;
- n++;
- }
- } else {
- n = -n;
- }
- }
- do {
- dig[k++] = (int) (n % 10);
- n /= 10;
- } while (n != 0);
- pdf_room(pdf, k);
- while (k-- > 0) {
- pdf_quick_out(pdf, (unsigned char) ('0' + dig[k]));
- }
+ char s[24];
+ int w;
+ w = snprintf(s, 23, "%" LONGINTEGER_PRI "d", n);
+ check_nprintf(w, 23);
+ pdf_out_block(pdf, (const char *) s, (size_t) w);
}
-@ print $m/10^d$ as real
-@c
-void pdf_print_real(PDF pdf, int m, int d)
+@ @c
+void print_pdffloat(PDF pdf, pdffloat f)
{
+ char a[24];
+ int e = f.e, i, j;
+ long l, m = f.m;
if (m < 0) {
pdf_out(pdf, '-');
- m = -m;
- };
- pdf_print_int(pdf, m / ten_pow[d]);
- m = m % ten_pow[d];
- if (m > 0) {
+ m *= -1;
+ }
+ l = m / ten_pow[e];
+ pdf_print_int(pdf, l);
+ l = m % ten_pow[e];
+ if (l != 0) {
pdf_out(pdf, '.');
- d--;
- while (m < ten_pow[d]) {
- pdf_out(pdf, '0');
- d--;
+ j = snprintf(a, 23, "%ld", l + ten_pow[e]);
+ assert(j < 23);
+ for (i = e; i > 0; i--) {
+ if (a[i] != '0')
+ break;
+ a[i] = '\0';
}
- while (m % 10 == 0)
- m /= 10;
- pdf_print_int(pdf, m);
+ pdf_puts(pdf, (a + 1));
}
}
-@ print out |s| as string in PDF output
+@ print out |s| as string in PDF output
@c
void pdf_print_str(PDF pdf, const char *s)
{
@@ -599,64 +636,93 @@ void pdf_print_str(PDF pdf, const char *s)
pdf_puts(pdf, orig); /* it was a hex string after all */
}
-@ begin a stream
+@ begin a stream (needs to have a stream dictionary also)
@c
void pdf_begin_stream(PDF pdf)
{
- assert(pdf->os_mode == false);
- pdf_puts(pdf, "/Length \n");
- pdf->seek_write_length = true; /* fill in length at |pdf_end_stream| call */
- pdf->stream_length_offset = pdf_offset(pdf) - 11;
+ os_struct *os = pdf->os;
+ strbuf_s *lbuf = os->buf[LUASTM_BUF];
+ assert(os->curbuf == PDFOUT_BUF);
+ assert(pdf->buf == os->buf[os->curbuf]);
+ assert(pdf->zip_write_state == NO_ZIP);
+ pdf_puts(pdf, "\nstream\n");
+ pdf_save_offset(pdf);
+ pdf_flush(pdf);
+ if (os->trigger_luastm) {
+ os->trigger_luastm = false; /* this was just a trigger */
+ luaL_buffinit(Luas, &(os->b));
+ lbuf->p = lbuf->data = (unsigned char *) luaL_prepbuffer(&(os->b));
+ lbuf->size = lbuf->limit = LUAL_BUFFERSIZE;
+ os->curbuf = LUASTM_BUF;
+ pdf->buf = os->buf[os->curbuf];
+ }
+ if (pdf->stream_deflate) {
+ assert(pdf->compress_level > 0);
+ pdf->zip_write_state = ZIP_WRITING;
+ }
+ pdf->stream_writing = true;
pdf->stream_length = 0;
pdf->last_byte = 0;
- if (pdf->compress_level > 0) {
- pdf_puts(pdf, "/Filter /FlateDecode\n");
- pdf_puts(pdf, ">>\n");
- pdf_puts(pdf, "stream\n");
- pdf_flush(pdf);
- pdf->zip_write_state = zip_writing;
- } else {
- pdf_puts(pdf, ">>\n");
- pdf_puts(pdf, "stream\n");
- pdf_save_offset(pdf);
- }
}
-@ @c
-static void write_stream_length(PDF pdf, longinteger 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, "%" LONGINTEGER_PRI "i", (LONGINTEGER_TYPE) length);
- xfseeko(pdf->file, (off_t) pdf_offset(pdf), SEEK_SET, jobname_cstr);
- }
-}
-
-@ end a stream
+@ end a stream
@c
void pdf_end_stream(PDF pdf)
{
- if (pdf->zip_write_state == zip_writing)
- pdf->zip_write_state = zip_finish;
- else
- pdf->stream_length = pdf_offset(pdf) - pdf_saved_offset(pdf);
- pdf_flush(pdf);
- if (pdf->seek_write_length)
- write_stream_length(pdf, pdf->stream_length,
- pdf->stream_length_offset);
+ os_struct *os = pdf->os;
+ strbuf_s *lbuf = os->buf[LUASTM_BUF];
+ const_lstring ls;
+ assert(pdf->buf == os->buf[os->curbuf]);
+ switch (os->curbuf) {
+ case PDFOUT_BUF:
+ if (pdf->zip_write_state == ZIP_WRITING)
+ pdf->zip_write_state = ZIP_FINISH;
+ pdf_flush(pdf); /* sets pdf->last_byte */
+ break;
+ case LUASTM_BUF:
+ luaL_addsize(&(os->b), strbuf_offset(os->buf[LUASTM_BUF]));
+ luaL_pushresult(&(os->b));
+
+ /* now the complete page stream is on the Lua stack */
+ /* TODO: pagestream filter callback here */
+
+ ls.s = lua_tolstring(Luas, -1, &ls.l);
+ lbuf->data = (unsigned char *) ls.s;
+ lbuf->p = lbuf->data + ls.l;
+ os->curbuf = LUASTM_BUF;
+ pdf->buf = os->buf[os->curbuf];
+ if (pdf->zip_write_state == ZIP_WRITING) {
+ pdf->zip_write_state = ZIP_FINISH;
+ write_zip(pdf);
+ } else
+ write_nozip(pdf);
+ lua_pop(Luas, 1);
+ os->curbuf = PDFOUT_BUF;
+ pdf->buf = os->buf[os->curbuf];
+ assert(pdf->buf->data == pdf->buf->p);
+ break;
+ case OBJSTM_BUF:
+ assert(0);
+ break;
+ default:
+ assert(0);
+ }
+ assert(pdf->zip_write_state == NO_ZIP);
+ assert(os->curbuf == PDFOUT_BUF);
+ assert(pdf->buf == os->buf[os->curbuf]);
+ pdf->stream_deflate = false;
+ pdf->stream_writing = false;
+ if (pdf->last_byte != '\n')
+ pdf_out(pdf, '\n'); /* doesn't really belong to the stream */
+ pdf_puts(pdf, "endstream");
+ /* write stream /Length */
+ if (pdf->seek_write_length && pdf->draftmode == 0) {
+ xfseeko(pdf->file, (off_t)pdf->stream_length_offset, SEEK_SET,
+ pdf->job_name);
+ fprintf(pdf->file, "%" LONGINTEGER_PRI "i", pdf->stream_length);
+ xfseeko(pdf->file, 0, SEEK_END, pdf->job_name);
+ }
pdf->seek_write_length = false;
- if (pdf->last_byte != pdf_newline_char)
- pdf_out(pdf, pdf_newline_char);
- pdf_puts(pdf, "endstream\n");
- pdf_end_obj(pdf);
-}
-
-void pdf_remove_last_space(PDF pdf)
-{
- if ((pdf->ptr > 0) && (pdf->buf[pdf->ptr - 1] == ' '))
- pdf->ptr--;
}
@ To print |scaled| value to PDF output we need some subroutines to ensure
@@ -720,19 +786,20 @@ scaled round_xn_over_d(scaled x, int n, unsigned int d)
}
@ @c
-#define lround(a) (long) floor((a) + 0.5)
-
-void pdf_print_bp(PDF pdf, scaled s)
+void pdf_add_bp(PDF pdf, scaled s)
{ /* print scaled as |bp| */
pdffloat a;
pdfstructure *p = pdf->pstruct;
assert(p != NULL);
a.m = lround(s * p->k1);
a.e = pdf->decimal_digits;
+ if (pdf->cave > 0)
+ pdf_out(pdf, ' ');
print_pdffloat(pdf, a);
+ pdf->cave = 1;
}
-void pdf_print_mag_bp(PDF pdf, scaled s)
+void pdf_add_mag_bp(PDF pdf, scaled s)
{ /* take |mag| into account */
pdffloat a;
pdfstructure *p = pdf->pstruct;
@@ -742,18 +809,12 @@ void pdf_print_mag_bp(PDF pdf, scaled s)
else
a.m = lround(s * p->k1);
a.e = pdf->decimal_digits;
+ if (pdf->cave > 0)
+ pdf_out(pdf, ' ');
print_pdffloat(pdf, a);
+ pdf->cave = 1;
}
-#define set_p_or_return(a) do { \
- p = a; \
- if (p==NULL) { \
- a = item; \
- return; \
- } \
- } while (0)
-
-
@* handling page resources.
@c
@@ -879,7 +940,7 @@ static void destroy_page_resources_tree(PDF pdf)
@* Subroutines to print out various PDF objects.
-@ print out an integer |n| with fixed width |w|; used for outputting cross-reference table
+@ print out an integer |n| with fixed width |w|; used for outputting cross-reference table
@c
static void pdf_print_fw_int(PDF pdf, longinteger n, size_t w)
{
@@ -894,7 +955,7 @@ static void pdf_print_fw_int(PDF pdf, longinteger n, size_t w)
pdf_out_block(pdf, (const char *) digits, w);
}
-@ print out an integer |n| as a fixed number |w| 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
static void pdf_out_bytes(PDF pdf, longinteger n, size_t w)
{
@@ -909,59 +970,12 @@ static void pdf_out_bytes(PDF pdf, longinteger n, size_t w)
pdf_out_block(pdf, (const char *) bytes, w);
}
-@ print out an entry in dictionary with integer value to PDF buffer
-@c
-void pdf_int_entry(PDF pdf, const char *s, int v)
-{
- pdf_printf(pdf, "/%s ", s);
- pdf_print_int(pdf, v);
-}
-
-void pdf_int_entry_ln(PDF pdf, const char *s, int v)
-{
-
- pdf_int_entry(pdf, s, v);
- pdf_print_nl(pdf);
-}
-
-@ print out an indirect entry in dictionary
-@c
-void pdf_indirect(PDF pdf, const char *s, int o)
-{
- pdf_printf(pdf, "/%s %d 0 R", s, (int) o);
-}
-
-void pdf_indirect_ln(PDF pdf, const char *s, int o)
-{
-
- pdf_indirect(pdf, s, o);
- pdf_print_nl(pdf);
-}
-
-@ print out |s| as string in PDF output
+@ print out |s| as string in PDF output
@c
void pdf_print_str_ln(PDF pdf, const char *s)
{
pdf_print_str(pdf, s);
- pdf_print_nl(pdf);
-}
-
-@ print out an entry in dictionary with string value to PDF buffer
-@c
-void pdf_str_entry(PDF pdf, const char *s, const char *v)
-{
- if (v == 0)
- return;
- pdf_printf(pdf, "/%s ", s);
- pdf_print_str(pdf, v);
-}
-
-void pdf_str_entry_ln(PDF pdf, const char *s, const char *v)
-{
- if (v == 0)
- return;
- pdf_str_entry(pdf, s, v);
- pdf_print_nl(pdf);
+ pdf_out(pdf, '\n');
}
@ @c
@@ -969,43 +983,34 @@ void pdf_print_toks(PDF pdf, halfword p)
{
int len = 0;
char *s = tokenlist_to_cstring(p, true, &len);
- if (len > 0)
- pdf_puts(pdf, s);
- xfree(s);
-}
-
-void pdf_print_toks_ln(PDF pdf, halfword p)
-{
- int len = 0;
- char *s = tokenlist_to_cstring(p, true, &len);
if (len > 0) {
+ if (pdf->cave > 0)
+ pdf_out(pdf, ' ');
pdf_puts(pdf, s);
- pdf_print_nl(pdf);
+ pdf->cave = 1;
}
xfree(s);
}
-@ prints a rect spec
+@ prints a rect spec
@c
-void pdf_print_rect_spec(PDF pdf, halfword r)
+void pdf_add_rect_spec(PDF pdf, halfword r)
{
- pdf_print_mag_bp(pdf, pdf_ann_left(r));
- pdf_out(pdf, ' ');
- pdf_print_mag_bp(pdf, pdf_ann_bottom(r));
- pdf_out(pdf, ' ');
- pdf_print_mag_bp(pdf, pdf_ann_right(r));
- pdf_out(pdf, ' ');
- pdf_print_mag_bp(pdf, pdf_ann_top(r));
+ pdf_add_mag_bp(pdf, pdf_ann_left(r));
+ pdf_add_mag_bp(pdf, pdf_ann_bottom(r));
+ pdf_add_mag_bp(pdf, pdf_ann_right(r));
+ pdf_add_mag_bp(pdf, pdf_ann_top(r));
}
-@ output a rectangle specification to PDF file
+@ output a rectangle specification to PDF file
@c
void pdf_rectangle(PDF pdf, halfword r)
{
prepare_mag();
- pdf_puts(pdf, "/Rect [");
- pdf_print_rect_spec(pdf, r);
- pdf_puts(pdf, "]\n");
+ pdf_add_name(pdf, "Rect");
+ pdf_begin_array(pdf);
+ pdf_add_rect_spec(pdf, r);
+ pdf_end_array(pdf);
}
@ @c
@@ -1019,7 +1024,7 @@ static void init_pdf_outputparameters(PDF pdf)
pdf->image_gamma = fix_int(pdf_image_gamma, 0, 1000000);
pdf->image_hicolor = fix_int(pdf_image_hicolor, 0, 1);
pdf->image_apply_gamma = fix_int(pdf_image_apply_gamma, 0, 1);
- pdf->objcompresslevel = fix_int(pdf_objcompresslevel, 0, 3);
+ pdf->objcompresslevel = fix_int(pdf_objcompresslevel, 0, MAX_OBJ_COMPRESS_LEVEL);
pdf->inclusion_copy_font = fix_int(pdf_inclusion_copy_font, 0, 1);
pdf->replace_font = fix_int(pdf_replace_font, 0, 1);
pdf->pk_resolution = fix_int(pdf_pk_resolution, 72, 8000);
@@ -1041,13 +1046,13 @@ static void init_pdf_outputparameters(PDF pdf)
if (!callback_defined(read_pk_file_callback)) {
if (pdf_pk_mode != null) {
char *s = tokenlist_to_cstring(pdf_pk_mode, true, NULL);
- kpseinitprog("PDFTEX", (unsigned) pdf->pk_resolution, s, nil);
+ kpse_init_prog("PDFTEX", (unsigned) pdf->pk_resolution, s, nil);
xfree(s);
} else {
- kpseinitprog("PDFTEX", (unsigned) pdf->pk_resolution, nil, nil);
+ kpse_init_prog("PDFTEX", (unsigned) pdf->pk_resolution, nil, nil);
}
- if (!kpsevarvalue("MKTEXPK"))
- kpsesetprogramenabled(kpsepkformat, 1, kpsesrccmdline);
+ if (!kpse_var_value("MKTEXPK"))
+ kpse_set_program_enabled(kpse_pk_format, 1, kpse_src_cmdline);
}
set_job_id(pdf, int_par(year_code),
int_par(month_code), int_par(day_code), int_par(time_code));
@@ -1055,7 +1060,7 @@ static void init_pdf_outputparameters(PDF pdf)
pdf->resname_prefix = get_resname_prefix(pdf);
}
-@ Checks that we have a name for the generated PDF file and that it's open.
+@ Checks that we have a name for the generated PDF file and that it's open.
@c
static void ensure_output_file_open(PDF pdf, const char *ext)
@@ -1088,7 +1093,7 @@ static void ensure_pdf_header_written(PDF pdf)
pdf_out(pdf, 'T' + 128);
pdf_out(pdf, 'E' + 128);
pdf_out(pdf, 'X' + 128);
- pdf_print_nl(pdf);
+ pdf_out(pdf, '\n');
}
@ @c
@@ -1152,117 +1157,248 @@ When calling this procedure, |pdf_os_mode| must be |true|.
@c
static void pdf_os_write_objstream(PDF pdf)
{
- halfword i, j, p, q;
- if (pdf->os_cur_objnum == 0) /* no object stream started */
+ os_struct *os = pdf->os;
+ unsigned int i, j, n1, n2; /* n1, n2: ObjStm buffer may be reallocated! */
+ strbuf_s *obuf = os->buf[OBJSTM_BUF];
+ if (os->cur_objstm == 0) /* no object stream started */
return;
- p = pdf->ptr;
- i = 0;
- j = 0;
- while (i <= pdf->os_idx) { /* assemble object number and byte offset pairs */
- 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_newline_char);
+ assert(pdf->buf == obuf); /* yes, pdf_out() still goes into ObjStm */
+ assert(os->idx > 0); /* yes, there are objects for the ObjStm */
+ n1 = (unsigned int) strbuf_offset(obuf); /* remember end of collected object stream contents */
+ /* this is needed here to calculate /First for the ObjStm dict */
+ for (i = 0, j = 0; i < os->idx; i++) { /* add object-number/byte-offset list to buffer */
+ pdf_print_int(pdf, (int) os->obj[i].num);
+ pdf_out(pdf, ' ');
+ pdf_print_int(pdf, (int) os->obj[i].off);
+ if (j == 9 || i == os->idx - 1) { /* print out in groups of ten for better readability */
+ pdf_out(pdf, '\n');
j = 0;
} else {
pdf_out(pdf, ' ');
j++;
}
- i++;
- }
- 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);
- /* 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;
- if (q > p)
- q = p;
- pdf_room(pdf, q - i);
- while (i < q) { /* write the buffered objects */
- pdf_quick_out(pdf, pdf->os_buf[i]);
- i++;
- }
}
+ n2 = (unsigned int) strbuf_offset(obuf); /* remember current buffer end */
+ pdf_begin_obj(pdf, (int) os->cur_objstm, OBJSTM_NEVER); /* switch to PDF stream writing */
+ pdf_begin_dict(pdf);
+ pdf_dict_add_name(pdf, "Type", "ObjStm");
+ pdf_dict_add_int(pdf, "N", (int) os->idx); /* number of objects in ObjStm */
+ pdf_dict_add_int(pdf, "First", (int) (n2 - n1));
+ pdf_dict_add_streaminfo(pdf);
+ pdf_end_dict(pdf);
+ pdf_begin_stream(pdf);
+ /* write object-number/byte-offset list */
+ pdf_out_block(pdf, (const char *) (obuf->data + n1), (size_t) (n2 - n1));
+ /* write collected object stream contents */
+ pdf_out_block(pdf, (const char *) obuf->data, (size_t) n1);
pdf_end_stream(pdf);
- pdf->os_cur_objnum = 0; /* to force object stream generation next time */
+ pdf_end_obj(pdf);
+ os->cur_objstm = 0; /* to force object stream generation next time */
}
-@ begin a PDF dictionary object
+@ begin a PDF dictionary
@c
-void pdf_begin_dict(PDF pdf, int i, int pdf_os_level)
+void pdf_begin_dict(PDF pdf)
{
- 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");
- }
+ pdf_puts(pdf, "<<");
+ pdf->cave = 0;
}
-@ begin a new PDF dictionary object
+@ end a PDF dictionary
@c
-int pdf_new_dict(PDF pdf, int t, int i, int pdf_os_level)
+void pdf_end_dict(PDF pdf)
{
- int k = pdf_create_obj(pdf, t, i);
- pdf_begin_dict(pdf, k, pdf_os_level);
- return k;
+ pdf_puts(pdf, ">>");
+ pdf->cave = 0;
}
-@ end a PDF dictionary object
+@ add integer object to dict
@c
-void pdf_end_dict(PDF pdf)
+void pdf_dict_add_bool(PDF pdf, const char *key, int i)
{
- 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");
- }
+ pdf_add_name(pdf, key);
+ pdf_add_bool(pdf, i);
}
-@ begin a PDF object
+@ add integer object to dict
@c
-void pdf_begin_obj(PDF pdf, int i, int pdf_os_level)
+void pdf_dict_add_int(PDF pdf, const char *key, int i)
{
- 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_add_name(pdf, key);
+ pdf_add_int(pdf, i);
+}
+
+@ add name object to dict
+@c
+void pdf_dict_add_name(PDF pdf, const char *key, const char *val)
+{
+ pdf_add_name(pdf, key);
+ pdf_add_name(pdf, val);
+}
+
+@ add string object to dict
+@c
+void pdf_dict_add_string(PDF pdf, const char *key, const char *val)
+{
+ if (val == NULL)
+ return;
+ pdf_add_name(pdf, key);
+ if (pdf->cave > 0)
+ pdf_out(pdf, ' ');
+ pdf->cave = 0;
+ pdf_print_str(pdf, val);
+}
+
+@ add name reference to dict
+@c
+void pdf_dict_add_ref(PDF pdf, const char *key, int num)
+{
+ pdf_add_name(pdf, key);
+ pdf_add_ref(pdf, num);
+}
+
+@ add objects of different types
+@c
+void pdf_add_null(PDF pdf)
+{
+ if (pdf->cave > 0)
+ pdf_out(pdf, ' ');
+ pdf_puts(pdf, "null");
+ pdf->cave = 1;
+}
+
+void pdf_add_bool(PDF pdf, int i)
+{
+ if (pdf->cave > 0)
+ pdf_out(pdf, ' ');
+ if (i == 0)
+ pdf_puts(pdf, "false");
+ else
+ pdf_puts(pdf, "true");
+ pdf->cave = 1;
+}
+
+void pdf_add_int(PDF pdf, int i)
+{
+ if (pdf->cave > 0)
+ pdf_out(pdf, ' ');
+ pdf_print_int(pdf, i);
+ pdf->cave = 1;
+}
+
+void pdf_add_longint(PDF pdf, longinteger n)
+{
+ if (pdf->cave > 0)
+ pdf_out(pdf, ' ');
+ pdf_print_int(pdf, n);
+ pdf->cave = 1;
+}
+
+void pdf_add_string(PDF pdf, const char *s)
+{
+ if (pdf->cave > 0)
+ pdf_out(pdf, ' ');
+ pdf_print_str(pdf, s);
+ pdf->cave = 1;
+}
+
+void pdf_add_name(PDF pdf, const char *name)
+{
+ pdf_out(pdf, '/');
+ pdf_puts(pdf, name);
+ pdf->cave = 1;
+}
+
+void pdf_add_ref(PDF pdf, int num)
+{
+ if (pdf->cave > 0)
+ pdf_out(pdf, ' ');
+ pdf_print_int(pdf, num);
+ pdf_puts(pdf, " 0 R");
+ pdf->cave = 1;
+}
+
+@ add stream length and filter entries to a stream dictionary,
+remember file position for seek
+@c
+void pdf_dict_add_streaminfo(PDF pdf)
+{
+ assert(pdf->buf == pdf->os->buf[PDFOUT_BUF]);
+ pdf_add_name(pdf, "Length");
+ pdf->stream_length_offset = pdf_offset(pdf) + 1;
+ pdf->seek_write_length = true; /* fill in length at |pdf_end_stream| call */
+ pdf_puts(pdf, " x "); /* space for 10 decimal digits */
+ pdf->cave = 1;
+ if (pdf->compress_level > 0) {
+ pdf_dict_add_name(pdf, "Filter", "FlateDecode");
+ pdf->stream_deflate = true;
}
}
-@ begin a new PDF object
+@ begin a PDF array
@c
-int pdf_new_obj(PDF pdf, int t, int i, int pdf_os_level)
+void pdf_begin_array(PDF pdf)
{
- int k = pdf_create_obj(pdf, t, i);
- pdf_begin_obj(pdf, k, pdf_os_level);
- return k;
+ pdf_out(pdf, '[');
+ pdf->cave = 0;
+}
+
+@ end a PDF array
+@c
+void pdf_end_array(PDF pdf)
+{
+ pdf_out(pdf, ']');
+ pdf->cave = 0;
}
-@ end a PDF object
+@ begin a PDF object
+@c
+void pdf_begin_obj(PDF pdf, int i, int pdf_os_threshold)
+{
+ os_struct *os = pdf->os;
+ ensure_output_state(pdf, ST_HEADER_WRITTEN);
+ pdf_prepare_obj(pdf, i, pdf_os_threshold);
+ assert(pdf->buf == os->buf[os->curbuf]);
+ switch (os->curbuf) {
+ case PDFOUT_BUF:
+ pdf_printf(pdf, "%d 0 obj\n", (int) i);
+ break;
+ case LUASTM_BUF:
+ assert(0);
+ break;
+ case OBJSTM_BUF:
+ if (pdf->compress_level == 0)
+ pdf_printf(pdf, "%% %d 0 obj\n", (int) i); /* debugging help */
+ break;
+ default:
+ assert(0);
+ }
+ pdf->cave = 0;
+}
+
+@ end a PDF object
@c
void pdf_end_obj(PDF pdf)
{
- if (pdf->os_mode) {
- if (pdf->os_idx == pdf_os_max_objs - 1)
+ os_struct *os = pdf->os;
+ assert(pdf->buf == os->buf[os->curbuf]);
+ switch (os->curbuf) {
+ case PDFOUT_BUF:
+ pdf_puts(pdf, "\nendobj\n"); /* end a PDF object */
+ break;
+ case LUASTM_BUF:
+ assert(0);
+ break;
+ case OBJSTM_BUF:
+ os->idx++; /* = number of objects collected so far in ObjStm */
+ os->o_ctr++; /* only for statistics */
+ if (os->idx == PDF_OS_MAX_OBJS)
pdf_os_write_objstream(pdf);
- } else {
- pdf_puts(pdf, "endobj\n"); /* end a PDF object */
+ else
+ pdf_out(pdf, '\n'); /* Adobe Reader seems to need this */
+ break;
+ default:
+ assert(0);
}
}
@@ -1271,7 +1407,7 @@ void pdf_end_obj(PDF pdf)
control characters are octal encoded.
This assumes that the string does not contain any already escaped
characters!
-
+
@c
char *convertStringToPDFString(const char *in, int len)
{
@@ -1311,7 +1447,7 @@ char *convertStringToPDFString(const char *in, int len)
@ Converts any string given in in in an allowed PDF string which is
hexadecimal encoded;
|sizeof(out)| should be at least $|lin|*2+1$.
-
+
@c
static void convertStringToHexString(const char *in, char *out, int lin)
{
@@ -1362,7 +1498,7 @@ static void convertStringToHexString(const char *in, char *out, int lin)
implementation using just the first two items.
@c
-static void print_ID(PDF pdf, const char *file_name)
+static void print_ID(PDF pdf)
{
time_t t;
size_t size;
@@ -1393,12 +1529,16 @@ static void print_ID(PDF pdf, const char *file_name)
#endif
md5_append(&state, (const md5_byte_t *) pwd, (int) strlen(pwd));
md5_append(&state, (const md5_byte_t *) "/", 1);
- md5_append(&state, (const md5_byte_t *) file_name, (int) strlen(file_name));
+ md5_append(&state, (const md5_byte_t *) pdf->file_name,
+ (int) strlen(pdf->file_name));
/* finish md5 */
md5_finish(&state, digest);
/* write the IDs */
convertStringToHexString((char *) digest, id, 16);
- pdf_printf(pdf, "/ID [<%s> <%s>]", id, id);
+ pdf_add_name(pdf, "ID");
+ pdf_begin_array(pdf);
+ pdf_printf(pdf, "<%s> <%s>", id, id);
+ pdf_end_array(pdf);
}
@ Print the /CreationDate entry.
@@ -1516,20 +1656,6 @@ void init_start_time(PDF pdf)
}
@ @c
-static void print_creation_date(PDF pdf)
-{
- init_start_time(pdf);
- pdf_printf(pdf, "/CreationDate (%s)\n", pdf->start_time_str);
-}
-
-@ @c
-static void print_mod_date(PDF pdf)
-{
- init_start_time(pdf);
- pdf_printf(pdf, "/ModDate (%s)\n", pdf->start_time_str);
-}
-
-@ @c
char *getcreationdate(PDF pdf)
{
assert(pdf);
@@ -1549,67 +1675,6 @@ void remove_pdffile(PDF pdf)
}
@ @c
-static void realloc_fb(PDF pdf)
-{
- if (pdf->fb_array == NULL) {
- pdf->fb_limit = SMALL_ARRAY_SIZE;
- pdf->fb_array = xtalloc(pdf->fb_limit, char);
- pdf->fb_ptr = pdf->fb_array;
- } else if ((size_t) (pdf->fb_ptr - pdf->fb_array + 1) > pdf->fb_limit) {
- size_t last_ptr_index = (size_t) (pdf->fb_ptr - pdf->fb_array);
- pdf->fb_limit *= 2;
- if ((size_t) (pdf->fb_ptr - pdf->fb_array + 1) > pdf->fb_limit)
- pdf->fb_limit = (size_t) (pdf->fb_ptr - pdf->fb_array + 1);
- xretalloc(pdf->fb_array, pdf->fb_limit, char);
- pdf->fb_ptr = pdf->fb_array + last_ptr_index;
- }
-}
-
-@ @c
-int fb_offset(PDF pdf)
-{
- return (int) (pdf->fb_ptr - pdf->fb_array);
-}
-
-@ @c
-void fb_seek(PDF pdf, int offset)
-{
- pdf->fb_ptr = pdf->fb_array + offset;
-}
-
-@ @c
-void fb_putchar(PDF pdf, eight_bits b)
-{
- if ((size_t) (pdf->fb_ptr - pdf->fb_array + 1) > pdf->fb_limit)
- realloc_fb(pdf);
- *(pdf->fb_ptr)++ = (char) b;
-}
-
-@ @c
-void fb_flush(PDF pdf)
-{
- char *p;
- int n;
- for (p = pdf->fb_array; p < pdf->fb_ptr;) {
- n = pdf->buf_size - pdf->ptr;
- if (pdf->fb_ptr - p < n)
- n = (int) (pdf->fb_ptr - p);
- memcpy(pdf->buf + pdf->ptr, p, (unsigned) n);
- pdf->ptr += n;
- if (pdf->ptr == pdf->buf_size)
- pdf_flush(pdf);
- p += n;
- }
- pdf->fb_ptr = pdf->fb_array;
-}
-
-@ @c
-void fb_free(PDF pdf)
-{
- xfree(pdf->fb_array);
-}
-
-@ @c
void pdf_error(const char *t, const char *p)
{
normalize_selector();
@@ -1646,7 +1711,7 @@ void pdf_warning(const char *t, const char *p, boolean prepend_nl,
history = warning_issued;
}
-@ Use |check_o_mode()| in the backend-specific "Implement..." chunks
+@ Use |check_o_mode()| in the backend-specific "Implement..." chunks
@c
void check_o_mode(PDF pdf, const char *s, int o_mode_bitpattern, boolean strict)
@@ -1746,64 +1811,81 @@ char *get_resname_prefix(PDF pdf)
void pdf_begin_page(PDF pdf)
{
+ pdffloat f;
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 = xtalloc(1, pdf_resource_struct);
pdf->page_resources->resources_tree = NULL;
}
- pdf->page_resources->last_resources = pdf_new_objnum(pdf);
+ pdf->page_resources->last_resources =
+ pdf_create_obj(pdf, obj_type_others, 0);
reset_page_resources(pdf);
if (global_shipping_mode == SHIPPING_PAGE) {
- pdf->last_page = get_obj(pdf, obj_type_page, total_pages + 1, 0);
+ pdf->last_page = pdf_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->last_stream = pdf_new_dict(pdf, obj_type_pagestream, 0, 0);
+ pdf->last_stream = pdf_create_obj(pdf, obj_type_pagestream, 0);
+ pdf_begin_obj(pdf, pdf->last_stream, OBJSTM_NEVER);
pdf->last_thread = null;
+ pdf_begin_dict(pdf);
pdflua_begin_page(pdf);
} else {
assert(global_shipping_mode == SHIPPING_FORM);
- pdf_begin_dict(pdf, pdf_cur_form, 0);
+ pdf_begin_obj(pdf, pdf_cur_form, OBJSTM_NEVER);
pdf->last_stream = pdf_cur_form;
/* Write out Form stream header */
- pdf_puts(pdf, "/Type /XObject\n");
- pdf_puts(pdf, "/Subtype /Form\n");
+ pdf_begin_dict(pdf);
+ pdf_dict_add_name(pdf, "Type", "XObject");
+ pdf_dict_add_name(pdf, "Subtype", "Form");
if (pdf_xform_attr != null)
- pdf_print_toks_ln(pdf, pdf_xform_attr);
+ pdf_print_toks(pdf, pdf_xform_attr);
if (obj_xform_attr(pdf, pdf_cur_form) != null) {
- pdf_print_toks_ln(pdf, obj_xform_attr(pdf, pdf_cur_form));
+ pdf_print_toks(pdf, obj_xform_attr(pdf, pdf_cur_form));
delete_token_ref(obj_xform_attr(pdf, pdf_cur_form));
set_obj_xform_attr(pdf, pdf_cur_form, null);
}
- pdf_puts(pdf, "/BBox [");
- pdf_print_bp(pdf, -form_margin);
- pdf_out(pdf, ' ');
- pdf_print_bp(pdf, -form_margin);
- pdf_out(pdf, ' ');
- pdf_print_bp(pdf, cur_page_size.h + form_margin);
- pdf_out(pdf, ' ');
- pdf_print_bp(pdf, cur_page_size.v + form_margin);
- pdf_puts(pdf, "]\n");
- pdf_puts(pdf, "/FormType 1\n");
- pdf_puts(pdf, "/Matrix [1 0 0 1 0 0]\n");
- pdf_indirect_ln(pdf, "Resources", pdf->page_resources->last_resources);
+ pdf_add_name(pdf, "BBox");
+ pdf_begin_array(pdf);
+ pdf_add_bp(pdf, -form_margin);
+ pdf_add_bp(pdf, -form_margin);
+ pdf_add_bp(pdf, pdf->page_size.h + form_margin);
+ pdf_add_bp(pdf, pdf->page_size.v + form_margin);
+ pdf_end_array(pdf);
+ pdf_dict_add_int(pdf, "FormType", 1);
+ pdf_add_name(pdf, "Matrix");
+ pdf_begin_array(pdf);
+ pdf_add_int(pdf, 1);
+ pdf_add_int(pdf, 0);
+ pdf_add_int(pdf, 0);
+ pdf_add_int(pdf, 1);
+ pdf_add_int(pdf, 0);
+ pdf_add_int(pdf, 0);
+ pdf_end_array(pdf);
+ pdf_dict_add_ref(pdf, "Resources", pdf->page_resources->last_resources);
}
/* Start stream of page/form contents */
+ pdf_dict_add_streaminfo(pdf);
+ pdf_end_dict(pdf);
+ pdf->os->trigger_luastm = false; /* if it's true, the page stream goes through Lua */
pdf_begin_stream(pdf);
if (global_shipping_mode == SHIPPING_PAGE) {
/* Adjust transformation matrix for the magnification ratio */
if (mag != 1000) {
- pdf_print_real(pdf, mag, 3);
+ setpdffloat(f, mag, 3);
+ print_pdffloat(pdf, f);
pdf_puts(pdf, " 0 0 ");
- pdf_print_real(pdf, mag, 3);
+ print_pdffloat(pdf, f);
pdf_puts(pdf, " 0 0 cm\n");
}
}
- pdf_shipout_begin();
+ pos_stack_used = 0; /* start with empty stack */
+ if (global_shipping_mode == SHIPPING_PAGE) {
+ colorstackpagestart();
+ }
if (global_shipping_mode == SHIPPING_PAGE)
pdf_out_colorstack_startpage(pdf);
}
@@ -1813,13 +1895,17 @@ void print_pdf_table_string(PDF pdf, const char *s)
{
size_t len;
const char *ls;
- lua_getglobal(Luas, "pdf"); /* t ... */
+ 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');
+ if (len > 0) {
+ if (pdf->cave == 1)
+ pdf_out(pdf, ' ');
+ pdf_out_block(pdf, ls, len);
+ pdf->cave = 1;
+ }
}
lua_pop(Luas, 2); /* ... */
}
@@ -1830,84 +1916,92 @@ void print_pdf_table_string(PDF pdf, const char *s)
void pdf_end_page(PDF pdf)
{
+ char s[64], *p;
int j, annots = 0, beads = 0;
pdf_resource_struct *res_p = pdf->page_resources;
pdf_resource_struct local_page_resources;
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 */
+ scaledpos save_cur_page_size; /* to save |pdf->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();
+ if (pos_stack_used > 0) {
+ pdftex_fail("%u unmatched \\pdfsave after %s shipout",
+ (unsigned int) pos_stack_used,
+ ((global_shipping_mode ==
+ SHIPPING_PAGE) ? "page" : "form"));
+ }
pdf_end_stream(pdf);
+ pdf_end_obj(pdf);
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_puts(pdf, "/Type /Page\n");
- pdf_indirect_ln(pdf, "Contents", pdf->last_stream);
- pdf_indirect_ln(pdf, "Resources", res_p->last_resources);
- pdf_puts(pdf, "/MediaBox [0 0 ");
- pdf_print_mag_bp(pdf, cur_page_size.h);
- pdf_out(pdf, ' ');
- pdf_print_mag_bp(pdf, cur_page_size.v);
- pdf_puts(pdf, "]\n");
+ pdf_begin_obj(pdf, pdf->last_page, OBJSTM_ALWAYS);
+ pdf_begin_dict(pdf);
+ pdf_dict_add_name(pdf, "Type", "Page");
+ pdf_dict_add_ref(pdf, "Contents", pdf->last_stream);
+ pdf_dict_add_ref(pdf, "Resources", res_p->last_resources);
+ pdf_add_name(pdf, "MediaBox");
+ pdf_begin_array(pdf);
+ pdf_add_int(pdf, 0);
+ pdf_add_int(pdf, 0);
+ pdf_add_mag_bp(pdf, pdf->page_size.h);
+ pdf_add_mag_bp(pdf, pdf->page_size.v);
+ pdf_end_array(pdf);
if (pdf_page_attr != null)
- pdf_print_toks_ln(pdf, pdf_page_attr);
+ pdf_print_toks(pdf, pdf_page_attr);
print_pdf_table_string(pdf, "pageattributes");
- pdf_indirect_ln(pdf, "Parent", pdf->last_pages);
+ pdf_dict_add_ref(pdf, "Parent", pdf->last_pages);
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_dict_add_ref(pdf, "Group", pdf->img_page_group_val);
}
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);
+ pdf_dict_add_ref(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_dict_add_ref(pdf, "B", beads);
}
pdf_end_dict(pdf);
+ pdf_end_obj(pdf);
pdflua_end_page(pdf, annots, beads);
pdf->img_page_group_val = 0;
/* Generate array of annotations or beads in page */
if (annot_list != NULL || link_list != NULL) {
- pdf_begin_obj(pdf, annots, 1);
- pdf_puts(pdf, "[");
+ pdf_begin_obj(pdf, annots, OBJSTM_ALWAYS);
+ pdf_begin_array(pdf);
while (annot_list != NULL) {
assert(annot_list->info > 0);
- pdf_print_int(pdf, annot_list->info);
- pdf_puts(pdf, " 0 R ");
+ pdf_add_ref(pdf, annot_list->info);
annot_list = annot_list->link;
}
while (link_list != NULL) {
- pdf_print_int(pdf, link_list->info);
- pdf_puts(pdf, " 0 R ");
+ pdf_add_ref(pdf, link_list->info);
link_list = link_list->link;
}
- pdf_puts(pdf, "]\n");
+ pdf_end_array(pdf);
pdf_end_obj(pdf);
}
if (bead_list != NULL) {
- pdf_begin_dict(pdf, beads, 1);
- pdf_puts(pdf, "[");
+ pdf_begin_obj(pdf, beads, OBJSTM_ALWAYS);
+ pdf_begin_array(pdf);
while (bead_list != NULL) {
- pdf_print_int(pdf, bead_list->info);
- pdf_printf(pdf, " 0 R ");
+ pdf_add_ref(pdf, bead_list->info);
bead_list = bead_list->link;
}
- pdf_printf(pdf, "]\n");
- pdf_end_dict(pdf);
+ pdf_end_array(pdf);
+ pdf_end_obj(pdf);
}
}
@@ -1923,19 +2017,19 @@ void pdf_end_page(PDF pdf)
/* Write out pending forms */
/* When flushing pending forms we need to save and restore resource lists
which are also used by page shipping.
- Saving and restoring |cur_page_size| is needed for proper
+ Saving and restoring |pdf->page_size| is needed for proper
writing out pending PDF marks. */
ol = get_page_resources_list(pdf, obj_type_xform);
while (ol != NULL) {
if (!is_obj_written(pdf, ol->info)) {
pdf_cur_form = ol->info;
- save_cur_page_size = cur_page_size;
+ save_cur_page_size = pdf->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), SHIPPING_FORM);
/* Restore page size and page resources */
- cur_page_size = save_cur_page_size;
+ pdf->page_size = save_cur_page_size;
global_shipping_mode = save_shipping_mode;
destroy_page_resources_tree(pdf);
pdf->page_resources = res_p;
@@ -1958,11 +2052,13 @@ void pdf_end_page(PDF pdf)
while (ol != NULL) {
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");
- pdf_print_toks_ln(pdf, pdf_annot_data(j));
+ pdf_begin_obj(pdf, ol->info, OBJSTM_ALWAYS);
+ pdf_begin_dict(pdf);
+ pdf_dict_add_name(pdf, "Type", "Annot");
+ pdf_print_toks(pdf, pdf_annot_data(j));
pdf_rectangle(pdf, j);
pdf_end_dict(pdf);
+ pdf_end_obj(pdf);
}
ol = ol->link;
}
@@ -1971,17 +2067,19 @@ void pdf_end_page(PDF pdf)
if ((ol = get_page_resources_list(pdf, obj_type_link)) != NULL) {
while (ol != NULL) {
j = obj_annot_ptr(pdf, ol->info);
- pdf_begin_dict(pdf, ol->info, 1);
- pdf_puts(pdf, "/Type /Annot\n");
+ pdf_begin_obj(pdf, ol->info, OBJSTM_ALWAYS);
+ pdf_begin_dict(pdf);
+ pdf_dict_add_name(pdf, "Type", "Annot");
if (pdf_action_type(pdf_link_action(j)) != pdf_action_user)
- pdf_puts(pdf, "/Subtype /Link\n");
+ pdf_dict_add_name(pdf, "Subtype", "Link");
if (pdf_link_attr(j) != null)
- pdf_print_toks_ln(pdf, pdf_link_attr(j));
+ pdf_print_toks(pdf, pdf_link_attr(j));
pdf_rectangle(pdf, j);
if (pdf_action_type(pdf_link_action(j)) != pdf_action_user)
pdf_puts(pdf, "/A ");
write_action(pdf, pdf_link_action(j));
pdf_end_dict(pdf);
+ pdf_end_obj(pdf);
ol = ol->link;
}
/* Flush |pdf_start_link_node|'s created by |append_link| */
@@ -2003,17 +2101,18 @@ void pdf_end_page(PDF pdf)
}
/* Write out resources dictionary */
- pdf_begin_dict(pdf, res_p->last_resources, 1);
+ pdf_begin_obj(pdf, res_p->last_resources, OBJSTM_ALWAYS);
+ pdf_begin_dict(pdf);
/* Print additional resources */
if (global_shipping_mode == SHIPPING_PAGE) {
if (pdf_page_resources != null)
- pdf_print_toks_ln(pdf, pdf_page_resources);
+ pdf_print_toks(pdf, pdf_page_resources);
print_pdf_table_string(pdf, "pageresources");
} else {
if (pdf_xform_resources != null)
- pdf_print_toks_ln(pdf, pdf_xform_resources);
+ pdf_print_toks(pdf, pdf_xform_resources);
if (obj_xform_resources(pdf, pdf_cur_form) != null) {
- pdf_print_toks_ln(pdf, obj_xform_resources(pdf, pdf_cur_form));
+ pdf_print_toks(pdf, obj_xform_resources(pdf, pdf_cur_form));
delete_token_ref(obj_xform_resources(pdf, pdf_cur_form));
set_obj_xform_resources(pdf, pdf_cur_form, null);
}
@@ -2021,18 +2120,18 @@ void pdf_end_page(PDF pdf)
/* Generate font resources */
if ((ol = get_page_resources_list(pdf, obj_type_font)) != NULL) {
- pdf_puts(pdf, "/Font << ");
+ pdf_add_name(pdf, "Font");
+ pdf_begin_dict(pdf);
while (ol != NULL) {
assert(ol->info > 0); /* always base font: an object number */
- pdf_puts(pdf, "/F");
- pdf_print_int(pdf, obj_info(pdf, ol->info));
- pdf_print_resname_prefix(pdf);
- pdf_out(pdf, ' ');
- pdf_print_int(pdf, ol->info);
- pdf_puts(pdf, " 0 R ");
+ p = s;
+ p += snprintf(p, 20, "F%i", obj_info(pdf, ol->info));
+ if (pdf->resname_prefix != NULL)
+ p += snprintf(p, 20, "%s", pdf->resname_prefix);
+ pdf_dict_add_ref(pdf, s, ol->info);
ol = ol->link;
}
- pdf_puts(pdf, ">>\n");
+ pdf_end_dict(pdf);
procset |= PROCSET_TEXT;
}
@@ -2040,47 +2139,47 @@ void pdf_end_page(PDF pdf)
ol = get_page_resources_list(pdf, obj_type_xform);
ol1 = get_page_resources_list(pdf, obj_type_ximage);
if (ol != NULL || ol1 != NULL) {
- pdf_puts(pdf, "/XObject << ");
+ pdf_add_name(pdf, "XObject");
+ pdf_begin_dict(pdf);
while (ol != NULL) {
- pdf_printf(pdf, "/Fm");
- pdf_print_int(pdf, obj_info(pdf, ol->info));
- pdf_print_resname_prefix(pdf);
- pdf_out(pdf, ' ');
- pdf_print_int(pdf, ol->info);
- pdf_puts(pdf, " 0 R ");
+ p = s;
+ p += snprintf(p, 20, "Fm%i", obj_info(pdf, ol->info));
+ if (pdf->resname_prefix != NULL)
+ p += snprintf(p, 20, "%s", pdf->resname_prefix);
+ pdf_dict_add_ref(pdf, s, ol->info);
ol = ol->link;
}
while (ol1 != null) {
- pdf_puts(pdf, "/Im");
- pdf_print_int(pdf, obj_data_ptr(pdf, ol1->info));
- pdf_print_resname_prefix(pdf);
- pdf_out(pdf, ' ');
- pdf_print_int(pdf, ol1->info);
- pdf_puts(pdf, " 0 R ");
+ p = s;
+ p += snprintf(p, 20, "Im%i", obj_info(pdf, ol1->info));
+ if (pdf->resname_prefix != NULL)
+ p += snprintf(p, 20, "%s", pdf->resname_prefix);
+ pdf_dict_add_ref(pdf, s, ol1->info);
procset |= img_procset(idict_array[obj_data_ptr(pdf, ol1->info)]);
ol1 = ol1->link;
}
- pdf_puts(pdf, ">>\n");
+ pdf_end_dict(pdf);
}
/* Generate ProcSet */
- pdf_puts(pdf, "/ProcSet [");
+ pdf_add_name(pdf, "ProcSet");
+ pdf_begin_array(pdf);
if ((procset & PROCSET_PDF) != 0)
- pdf_puts(pdf, " /PDF");
+ pdf_add_name(pdf, "PDF");
if ((procset & PROCSET_TEXT) != 0)
- pdf_puts(pdf, " /Text");
+ pdf_add_name(pdf, "Text");
if ((procset & PROCSET_IMAGE_B) != 0)
- pdf_puts(pdf, " /ImageB");
+ pdf_add_name(pdf, "ImageB");
if ((procset & PROCSET_IMAGE_C) != 0)
- pdf_puts(pdf, " /ImageC");
+ pdf_add_name(pdf, "ImageC");
if ((procset & PROCSET_IMAGE_I) != 0)
- pdf_puts(pdf, " /ImageI");
- pdf_puts(pdf, " ]\n");
-
+ pdf_add_name(pdf, "ImageI");
+ pdf_end_array(pdf);
pdf_end_dict(pdf);
+ pdf_end_obj(pdf);
}
-@* Finishing the PDF output file.
+@* Finishing the PDF output file.
@ Destinations that have been referenced but don't exists have
|obj_dest_ptr=null|. Leaving them undefined might cause troubles for
@@ -2105,10 +2204,12 @@ static void check_nonexisting_destinations(PDF pdf)
(" has been referenced but does not exist, replaced by a fixed one");
print_ln();
print_ln();
- pdf_begin_obj(pdf, k, 1);
- pdf_out(pdf, '[');
- pdf_print_int(pdf, pdf->last_page);
- pdf_puts(pdf, " 0 R /Fit]\n");
+
+ pdf_begin_obj(pdf, k, OBJSTM_ALWAYS);
+ pdf_begin_array(pdf);
+ pdf_add_ref(pdf, pdf->last_page);
+ pdf_add_name(pdf, "Fit");
+ pdf_end_array(pdf);
pdf_end_obj(pdf);
}
}
@@ -2145,19 +2246,21 @@ static boolean substr_of_str(const char *s, const char *t)
return true;
}
-static int pdf_print_info(PDF pdf, int luatex_version,
- str_number luatex_revision)
+static int pdf_print_info(PDF pdf, int luatexversion,
+ str_number luatexrevision)
{ /* print info object */
boolean creator_given, producer_given, creationdate_given, moddate_given,
trapped_given;
char *s = NULL;
int k, len = 0;
- k = pdf_new_dict(pdf, obj_type_info, 0, 3); /* keep Info readable unless explicitely forced */
+ k = pdf_create_obj(pdf, obj_type_info, 0);
+ pdf_begin_obj(pdf, k, 3); /* keep Info readable unless explicitely forced */
creator_given = false;
producer_given = false;
creationdate_given = false;
moddate_given = false;
trapped_given = false;
+ pdf_begin_dict(pdf);
if (pdf_info_toks != 0) {
s = tokenlist_to_cstring(pdf_info_toks, true, &len);
creator_given = substr_of_str("/Creator", s);
@@ -2168,36 +2271,41 @@ static int pdf_print_info(PDF pdf, int luatex_version,
}
if (!producer_given) {
/* Print the Producer key */
- pdf_puts(pdf, "/Producer (LuaTeX-");
- pdf_print_int(pdf, luatex_version / 100);
+ pdf_add_name(pdf, "Producer");
+ pdf_puts(pdf, " (LuaTeX-");
+ pdf_print_int(pdf, luatexversion / 100);
pdf_out(pdf, '.');
- pdf_print_int(pdf, luatex_version % 100);
+ pdf_print_int(pdf, luatexversion % 100);
pdf_out(pdf, '.');
- pdf_print(pdf, luatex_revision);
- pdf_puts(pdf, ")\n");
+ pdf_print(pdf, luatexrevision);
+ pdf_out(pdf, ')');
}
if (pdf_info_toks != null) {
if (len > 0) {
+ pdf_out(pdf, '\n');
pdf_puts(pdf, s);
- pdf_print_nl(pdf);
+ pdf_out(pdf, '\n');
xfree(s);
}
delete_token_ref(pdf_info_toks);
pdf_info_toks = null;
}
if (!creator_given)
- pdf_str_entry_ln(pdf, "Creator", "TeX");
+ pdf_dict_add_string(pdf, "Creator", "TeX");
if (!creationdate_given) {
- print_creation_date(pdf);
+ init_start_time(pdf);
+ pdf_dict_add_string(pdf, "CreationDate", pdf->start_time_str);
}
if (!moddate_given) {
- print_mod_date(pdf);
+ init_start_time(pdf);
+ pdf_dict_add_string(pdf, "ModDate", pdf->start_time_str);
}
if (!trapped_given) {
- pdf_puts(pdf, "/Trapped /False\n");
+ pdf_dict_add_name(pdf, "Trapped", "False");
}
- pdf_str_entry_ln(pdf, "PTEX.Fullbanner", pdftex_banner);
+ pdf_dict_add_string(pdf, "PTEX.Fullbanner", pdftex_banner);
pdf_end_dict(pdf);
+ pdf_end_obj(pdf);
return k;
}
@@ -2219,9 +2327,8 @@ static void build_free_object_list(PDF pdf)
are already written completely to PDF output file.
@c
-void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
+void finish_pdf_file(PDF pdf, int luatexversion, str_number luatexrevision)
{
- boolean res;
int i, j, k;
int root, info, xref_stm = 0, outlines, threads, names_tree;
size_t xref_offset_width;
@@ -2233,7 +2340,7 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
tprint_nl("No pages of output.");
print_ln();
} else if (callback_id > 0) {
- res = run_callback(callback_id, "->");
+ run_callback(callback_id, "->");
}
if (pdf->gone > 0)
garbage_warning();
@@ -2242,7 +2349,7 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
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, "->");
+ run_callback(callback_id1, "->");
check_nonexisting_pages(pdf);
check_nonexisting_destinations(pdf);
@@ -2280,7 +2387,7 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
pdf->gen_tounicode = pdf_gen_tounicode;
k = pdf->head_tab[obj_type_font];
while (k != 0) {
- f = obj_info(pdf, k);
+ int f = obj_info(pdf, k);
assert(pdf_font_num(f) > 0);
assert(pdf_font_num(f) == k);
do_pdf_font(pdf, f);
@@ -2305,16 +2412,15 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
/* Output article threads */
if (pdf->head_tab[obj_type_thread] != 0) {
- threads = pdf_new_obj(pdf, obj_type_others, 0, 1);
- pdf_out(pdf, '[');
+ threads = pdf_create_obj(pdf, obj_type_others, 0);
+ pdf_begin_obj(pdf, threads, OBJSTM_ALWAYS);
+ pdf_begin_array(pdf);
k = pdf->head_tab[obj_type_thread];
while (k != 0) {
- pdf_print_int(pdf, k);
- pdf_puts(pdf, " 0 R ");
+ pdf_add_ref(pdf, k);
k = obj_link(pdf, k);
}
- pdf_remove_last_space(pdf);
- pdf_puts(pdf, "]\n");
+ pdf_end_array(pdf);
pdf_end_obj(pdf);
k = pdf->head_tab[obj_type_thread];
while (k != 0) {
@@ -2326,34 +2432,38 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
}
/* 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);
+ root = pdf_create_obj(pdf, obj_type_catalog, 0);
+ pdf_begin_obj(pdf, root, OBJSTM_ALWAYS);
+ pdf_begin_dict(pdf);
+ pdf_dict_add_name(pdf, "Type", "Catalog");
+ pdf_dict_add_ref(pdf, "Pages", pdf->last_pages);
if (threads != 0)
- pdf_indirect_ln(pdf, "Threads", threads);
+ pdf_dict_add_ref(pdf, "Threads", threads);
if (outlines != 0)
- pdf_indirect_ln(pdf, "Outlines", outlines);
+ pdf_dict_add_ref(pdf, "Outlines", outlines);
if (names_tree != 0)
- pdf_indirect_ln(pdf, "Names", names_tree);
+ pdf_dict_add_ref(pdf, "Names", names_tree);
if (pdf_catalog_toks != null) {
- pdf_print_toks_ln(pdf, pdf_catalog_toks);
+ pdf_print_toks(pdf, pdf_catalog_toks);
delete_token_ref(pdf_catalog_toks);
pdf_catalog_toks = null;
}
if (pdf_catalog_openaction != 0)
- pdf_indirect_ln(pdf, "OpenAction", pdf_catalog_openaction);
+ pdf_dict_add_ref(pdf, "OpenAction", pdf_catalog_openaction);
pdf_end_dict(pdf);
+ pdf_end_obj(pdf);
/* last candidate for object stream */
- info = pdf_print_info(pdf, luatex_version, luatex_revision); /* final object for pdf->os_enable == false */
+ info = pdf_print_info(pdf, luatexversion, luatexrevision); /* final object for pdf->os_enable == false */
if (pdf->os_enable) {
- pdf_os_switch(pdf, true);
+ pdf_buffer_select(pdf, OBJSTM_BUF);
pdf_os_write_objstream(pdf);
pdf_flush(pdf);
- pdf_os_switch(pdf, false);
+ pdf_buffer_select(pdf, PDFOUT_BUF);
/* Output the cross-reference stream dictionary */
- xref_stm = pdf_new_dict(pdf, obj_type_others, 0, 0); /* final object for pdf->os_enable == true */
+ xref_stm = pdf_create_obj(pdf, obj_type_others, 0);
+ pdf_begin_obj(pdf, xref_stm, OBJSTM_NEVER); /* 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->obj_ptr) > 16777215)
@@ -2364,30 +2474,37 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
xref_offset_width = 2;
/* Build a linked list of free objects */
build_free_object_list(pdf);
- pdf_puts(pdf, "/Type /XRef\n");
- pdf_puts(pdf, "/Index [0 ");
- pdf_print_int(pdf, pdf->obj_ptr + 1);
- pdf_puts(pdf, "]\n");
- pdf_int_entry_ln(pdf, "Size", pdf->obj_ptr + 1);
- pdf_puts(pdf, "/W [1 ");
- pdf_print_int(pdf, (int) xref_offset_width);
- pdf_puts(pdf, " 1]\n");
- pdf_indirect_ln(pdf, "Root", root);
- pdf_indirect_ln(pdf, "Info", info);
+ pdf_begin_dict(pdf);
+ pdf_dict_add_name(pdf, "Type", "XRef");
+ pdf_add_name(pdf, "Index");
+ pdf_begin_array(pdf);
+ pdf_add_int(pdf, 0);
+ pdf_add_int(pdf, pdf->obj_ptr + 1);
+ pdf_end_array(pdf);
+ pdf_dict_add_int(pdf, "Size", pdf->obj_ptr + 1);
+ pdf_add_name(pdf, "W");
+ pdf_begin_array(pdf);
+ pdf_add_int(pdf, 1);
+ pdf_add_int(pdf, (int) xref_offset_width);
+ pdf_add_int(pdf, 1);
+ pdf_end_array(pdf);
+ pdf_dict_add_ref(pdf, "Root", root);
+ pdf_dict_add_ref(pdf, "Info", info);
if (pdf_trailer_toks != null) {
- pdf_print_toks_ln(pdf, pdf_trailer_toks);
+ pdf_print_toks(pdf, pdf_trailer_toks);
delete_token_ref(pdf_trailer_toks);
pdf_trailer_toks = null;
}
- print_ID(pdf, pdf->file_name);
- pdf_print_nl(pdf);
+ print_ID(pdf);
+ pdf_dict_add_streaminfo(pdf);
+ pdf_end_dict(pdf);
pdf_begin_stream(pdf);
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);
pdf_out(pdf, 255);
- } else if (obj_os_idx(pdf, k) == -1) { /* object not in object stream */
+ } else if (obj_os_idx(pdf, k) == PDF_OS_MAX_OBJS) { /* object not in object stream */
pdf_out(pdf, 1);
pdf_out_bytes(pdf, obj_offset(pdf, k),
xref_offset_width);
@@ -2400,6 +2517,7 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
}
}
pdf_end_stream(pdf);
+ pdf_end_obj(pdf);
/* TODO: generate a debug version of the crossref */
pdf_flush(pdf);
@@ -2429,26 +2547,29 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
/* Output the trailer */
if (!pdf->os_enable) {
pdf_puts(pdf, "trailer\n");
- pdf_puts(pdf, "<< ");
- pdf_int_entry_ln(pdf, "Size", pdf->obj_ptr + 1);
- pdf_indirect_ln(pdf, "Root", root);
- pdf_indirect_ln(pdf, "Info", info);
+ pdf_begin_dict(pdf);
+ pdf_dict_add_int(pdf, "Size", pdf->obj_ptr + 1);
+ pdf_dict_add_ref(pdf, "Root", root);
+ pdf_dict_add_ref(pdf, "Info", info);
if (pdf_trailer_toks != null) {
- pdf_print_toks_ln(pdf, pdf_trailer_toks);
+ pdf_print_toks(pdf, pdf_trailer_toks);
delete_token_ref(pdf_trailer_toks);
pdf_trailer_toks = null;
}
- print_ID(pdf, pdf->file_name);
- pdf_puts(pdf, " >>\n");
+ print_ID(pdf);
+ pdf_end_dict(pdf);
+ pdf_out(pdf, '\n');
}
pdf_puts(pdf, "startxref\n");
+ pdf->cave = 0;
if (pdf->os_enable)
- pdf_print_int_ln(pdf, obj_offset(pdf, xref_stm));
+ pdf_add_longint(pdf, (longinteger) obj_offset(pdf, xref_stm));
else
- pdf_print_int_ln(pdf, pdf_saved_offset(pdf));
- pdf_puts(pdf, "%%EOF\n");
+ pdf_add_longint(pdf, (longinteger) pdf->save_offset);
+ pdf_puts(pdf, "\n%%EOF\n");
pdf_flush(pdf);
+
if (callback_id == 0) {
tprint_nl("Output written on ");
tprint(pdf->file_name);
@@ -2462,7 +2583,7 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
tprint(" bytes).");
print_ln();
} else if (callback_id > 0) {
- res = run_callback(callback_id, "->");
+ run_callback(callback_id, "->");
}
}
libpdffinish(pdf);
@@ -2475,17 +2596,16 @@ void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision)
}
if (callback_id == 0) {
- if (log_opened) {
+ if (log_opened_global) {
fprintf(log_file,
"\nPDF statistics: %d PDF objects out of %d (max. %d)\n",
(int) pdf->obj_ptr, (int) pdf->obj_tab_size,
(int) sup_obj_tab_size);
- if (pdf->os_cntr > 0) {
+ if (pdf->os->ostm_ctr > 0) {
fprintf(log_file,
" %d compressed objects within %d object stream%s\n",
- (int) ((pdf->os_cntr - 1) * pdf_os_max_objs +
- pdf->os_idx + 1), (int) pdf->os_cntr,
- (pdf->os_cntr > 1 ? "s" : ""));
+ (int) pdf->os->o_ctr, (int) pdf->os->ostm_ctr,
+ (pdf->os->ostm_ctr > 1 ? "s" : ""));
}
fprintf(log_file, " %d named destinations out of %d (max. %d)\n",
(int) pdf->dest_names_ptr, (int) pdf->dest_names_size,
@@ -2510,7 +2630,8 @@ void scan_pdfcatalog(PDF pdf)
} else {
check_o_mode(pdf, "\\pdfcatalog", 1 << OMODE_PDF, true);
p = scan_action(pdf);
- pdf_catalog_openaction = pdf_new_obj(pdf, obj_type_others, 0, 1);
+ pdf_catalog_openaction = pdf_create_obj(pdf, obj_type_others, 0);
+ pdf_begin_obj(pdf, pdf_catalog_openaction, OBJSTM_ALWAYS);
write_action(pdf, p);
pdf_end_obj(pdf);
delete_action_ref(p);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.h b/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.h
index 6a19556a0f3..b469ea61e1d 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.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: pdfglyph.h 3261 2009-12-18 11:38:21Z taco $ */
+/* $Id: pdfglyph.h 4575 2013-02-08 20:42:52Z hhenkel $ */
#ifndef PDFGLYPH_H
# define PDFGLYPH_H
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w b/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w
index 6e6c4b26dca..12c2d082750 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w
@@ -1,33 +1,30 @@
% pdfglyph.w
-
-% Copyright 2009-2010 Taco Hoekwater <taco@@luatex.org>
-
+%
+% Copyright 2009-2011 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: 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 $";
+ "$Id: pdfglyph.w 4575 2013-02-08 20:42:52Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfglyph.w $";
#include "ptexlib.h"
-
-@ @c
#include "pdf/pdfpage.h"
-#define lround(a) (long) floor((a) + 0.5)
#define pdf2double(a) ((double) (a).m / ten_pow[(a).e])
@ eternal constants
@@ -58,32 +55,33 @@ void pdf_print_charwidth(PDF pdf, internal_font_number f, int i)
@ @c
static void setup_fontparameters(PDF pdf, internal_font_number f)
{
- float slant, extend, expand;
+ float slant, extend, expand, scale = 1.0;
float u = 1.0;
pdfstructure *p = pdf->pstruct;
/* fix mantis bug \# 0000200 (acroread "feature") */
if ((font_format(f) == opentype_format ||
(font_format(f) == type1_format && font_encodingbytes(f) == 2))
&& font_units_per_em(f) > 0)
- u = (float) (font_units_per_em(f) / 1000.0);
+ u = font_units_per_em(f) / 1000.0;
pdf->f_cur = f;
p->f_pdf = pdf_set_font(pdf, f);
- p->fs.m = lround((float) font_size(f) / u / one_bp * ten_pow[p->fs.e]);
- slant = (float) font_slant(f) / (float) 1000.0;
- extend = (float) font_extend(f) / (float) 1000.0;
- expand = (float) 1.0 + (float) font_expand_ratio(f) / (float) 1000.0;
+ p->fs.m = lround(font_size(f) / u / one_bp * ten_pow[p->fs.e]);
+ slant = font_slant(f) / 1000.0;
+ extend = font_extend(f) / 1000.0;
+ expand = 1.0 + font_expand_ratio(f) / 1000.0;
p->tj_delta.e = p->cw.e - 1; /* "- 1" makes less corrections inside []TJ */
/* no need to be more precise than TeX (1sp) */
while (p->tj_delta.e > 0
&& (double) font_size(f) / ten_pow[p->tj_delta.e + e_tj] < 0.5)
p->tj_delta.e--; /* happens for very tiny fonts */
assert(p->cw.e >= p->tj_delta.e); /* else we would need, e. g., |ten_pow[-1]| */
- p->tm[0].m = lround(expand * extend * (float) ten_pow[p->tm[0].e]);
- p->tm[2].m = lround(slant * (float) ten_pow[p->tm[2].e]);
+ p->tm[0].m = lround(scale * expand * extend * ten_pow[p->tm[0].e]);
+ p->tm[2].m = lround(slant * ten_pow[p->tm[2].e]);
+ p->tm[3].m = lround(scale * ten_pow[p->tm[3].e]);
p->k2 =
ten_pow[e_tj +
- p->cw.e] / (ten_pow[p->pdf.h.e] * pdf2double(p->fs) *
- pdf2double(p->tm[0]));
+ p->cw.e] * scale / (ten_pow[p->pdf.h.e] * pdf2double(p->fs) *
+ pdf2double(p->tm[0]));
}
@ @c
@@ -92,18 +90,13 @@ static void set_font(PDF pdf)
pdfstructure *p = pdf->pstruct;
pdf_printf(pdf, "/F%d", (int) p->f_pdf);
pdf_print_resname_prefix(pdf);
- pdf_printf(pdf, " ");
+ pdf_out(pdf, ' ');
print_pdffloat(pdf, p->fs);
- pdf_printf(pdf, " Tf ");
+ pdf_puts(pdf, " Tf ");
p->f_pdf_cur = p->f_pdf;
p->fs_cur.m = p->fs.m;
-}
-
-@ @c
-static void print_tm(PDF pdf, pdffloat * tm)
-{
- print_pdf_matrix(pdf, tm);
- pdf_printf(pdf, " Tm ");
+ p->need_tf = false;
+ p->need_tm = true; /* always follow Tf by Tm */
}
@ @c
@@ -113,12 +106,40 @@ static void set_textmatrix(PDF pdf, scaledpos pos)
pdfstructure *p = pdf->pstruct;
assert(is_textmode(p));
move = calc_pdfpos(p, pos);
- if (p->need_tm == 1 || move) {
- print_tm(pdf, p->tm);
+ if (p->need_tm || move) {
+ print_pdf_matrix(pdf, p->tm);
+ pdf_puts(pdf, " 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;
+ p->need_tm = false;
}
+ p->tm0_cur.m = p->tm[0].m;
+}
+
+@ Print out a character to PDF buffer; the character will be printed in octal
+form in the following cases: chars <= 32, backslash (92), left parenthesis
+(40), and right parenthesis (41).
+@c
+static void pdf_print_char(PDF pdf, int c)
+{
+ if (c > 255)
+ return;
+ /* pdf_print_escaped(c) */
+ if (c <= 32 || c == '\\' || c == '(' || c == ')' || c > 127) {
+ pdf_room(pdf, 4);
+ pdf_quick_out(pdf, '\\');
+ pdf_quick_out(pdf, (unsigned char) ('0' + ((c >> 6) & 0x3)));
+ pdf_quick_out(pdf, (unsigned char) ('0' + ((c >> 3) & 0x7)));
+ pdf_quick_out(pdf, (unsigned char) ('0' + (c & 0x7)));
+ } else
+ pdf_out(pdf, c);
+}
+
+static void pdf_print_wide_char(PDF pdf, int c)
+{
+ char hex[5];
+ snprintf(hex, 5, "%04X", c);
+ pdf_out_block(pdf, (const char *) hex, 4);
}
@ @c
@@ -127,10 +148,10 @@ static void begin_charmode(PDF pdf, internal_font_number f, pdfstructure * p)
assert(is_chararraymode(p));
if (font_encodingbytes(f) == 2) {
p->ishex = 1;
- pdf_printf(pdf, "<");
+ pdf_out(pdf, '<');
} else {
p->ishex = 0;
- pdf_printf(pdf, "(");
+ pdf_out(pdf, '(');
}
p->mode = PMODE_CHAR;
}
@@ -142,9 +163,9 @@ void end_charmode(PDF pdf)
assert(is_charmode(p));
if (p->ishex == 1) {
p->ishex = 0;
- pdf_printf(pdf, ">");
+ pdf_out(pdf, '>');
} else {
- pdf_printf(pdf, ")");
+ pdf_out(pdf, ')');
}
p->mode = PMODE_CHARARRAY;
}
@@ -156,7 +177,7 @@ static void begin_chararray(PDF pdf)
assert(is_textmode(p));
p->pdf_tj_pos = p->pdf;
p->cw.m = 0;
- pdf_printf(pdf, "[");
+ pdf_out(pdf, '[');
p->mode = PMODE_CHARARRAY;
}
@@ -165,7 +186,7 @@ void end_chararray(PDF pdf)
{
pdfstructure *p = pdf->pstruct;
assert(is_chararraymode(p));
- pdf_printf(pdf, "]TJ\n");
+ pdf_puts(pdf, "]TJ\n");
p->pdf = p->pdf_tj_pos;
p->mode = PMODE_TEXT;
}
@@ -178,29 +199,34 @@ void pdf_place_glyph(PDF pdf, internal_font_number f, int c)
scaledpos pos = pdf->posstruct->pos;
if (!char_exists(f, c))
return;
- if (f != pdf->f_cur || is_textmode(p) || is_pagemode(p)) {
+ /* ensure to be within BT...ET */
+ if (is_pagemode(p)) {
pdf_goto_textmode(pdf);
- if (f != pdf->f_cur)
- setup_fontparameters(pdf, f);
- if (p->f_pdf != p->f_pdf_cur || p->fs.m != p->fs_cur.m) {
+ p->need_tf = true;
+ }
+ /* all font setup */
+ if (f != pdf->f_cur || p->need_tf) {
+ setup_fontparameters(pdf, f);
+ if (p->need_tf || p->f_pdf != p->f_pdf_cur || p->fs.m != p->fs_cur.m) {
+ pdf_goto_textmode(pdf);
set_font(pdf);
- p->need_tm = 1; /* force Tm setting */
+ } else if (p->tm0_cur.m != p->tm[0].m) {
+ /* catch in-line HZ expand change due to efcode */
+ p->need_tm = true;
}
- set_textmatrix(pdf, pos);
- begin_chararray(pdf);
}
- assert(is_charmode(p) || is_chararraymode(p));
- move = calc_pdfpos(p, pos);
- if (move) {
- if ((p->wmode == WMODE_H
- && (p->pdf_bt_pos.v.m + p->tm[5].m) != p->pdf.v.m)
+ /* all movements */
+ move = calc_pdfpos(p, pos); /* within text or chararray or char mode */
+ if (move || p->need_tm) {
+ if (p->need_tm || (p->wmode == WMODE_H
+ && (p->pdf_bt_pos.v.m + p->tm[5].m) != p->pdf.v.m)
|| (p->wmode == WMODE_V
&& (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);
begin_chararray(pdf);
- move = calc_pdfpos(p, pos);
+ move = calc_pdfpos(p, pos); /* for fine adjustment */
}
if (move) {
assert((p->wmode == WMODE_H
@@ -214,6 +240,8 @@ void pdf_place_glyph(PDF pdf, internal_font_number f, int c)
p->cw.m -= p->tj_delta.m * ten_pow[p->cw.e - p->tj_delta.e];
}
}
+ /* glyph output */
+ assert(is_chararraymode(p) || is_charmode(p));
if (is_chararraymode(p))
begin_charmode(pdf, f, p);
pdf_mark_char(f, c);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfimage.w b/Build/source/texk/web2c/luatexdir/pdf/pdfimage.w
index cc1e20c1870..f57d0c07073 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfimage.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfimage.w
@@ -1,26 +1,26 @@
% pdfimage.w
-
+%
% Copyright 2009-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/>.
+% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
static const char _svn_version[] =
- "$Id: pdfimage.w 3571 2010-04-02 13:50:45Z taco $"
- "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfimage.w $";
+ "$Id: pdfimage.w 4442 2012-05-25 22:40:34Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfimage.w $";
#include "ptexlib.h"
@@ -130,12 +130,12 @@ void place_img(PDF pdf, image_dict * idict, scaled_whd dim, int transform)
cm[5] = p->cm[5];
if (pdf->img_page_group_val == 0)
pdf->img_page_group_val = img_group_ref(idict); /* added from web for 1.40.8 */
- pdf_printf(pdf, "q\n");
+ pdf_puts(pdf, "q\n");
pdf_print_cm(pdf, cm);
- pdf_printf(pdf, "/Im");
+ pdf_puts(pdf, "/Im");
pdf_print_int(pdf, img_index(idict));
pdf_print_resname_prefix(pdf);
- pdf_printf(pdf, " Do\nQ\n");
+ pdf_puts(pdf, " Do\nQ\n");
addto_page_resources(pdf, obj_type_ximage, img_objnum(idict));
if (img_state(idict) < DICT_OUTIMG)
img_state(idict) = DICT_OUTIMG;
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdflink.w b/Build/source/texk/web2c/luatexdir/pdf/pdflink.w
index 4cdfa711ed6..378e698bbc5 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdflink.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdflink.w
@@ -1,26 +1,26 @@
% pdflink.w
-
-% Copyright 2009-2010 Taco Hoekwater <taco@@luatex.org>
-
+%
+% Copyright 2009-2012 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/>.
+% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
static const char _svn_version[] =
- "$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 $";
+ "$Id: pdflink.w 4451 2012-07-05 21:13:01Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdflink.w $";
#include "ptexlib.h"
@@ -61,7 +61,7 @@ void do_link(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
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)))
- pdf_link_objnum(p) = pdf_new_objnum(pdf);
+ pdf_link_objnum(p) = pdf_create_obj(pdf, obj_type_others, 0);
push_link_level(pdf, p);
alt_rule.wd = width(p);
alt_rule.ht = height(p);
@@ -93,9 +93,9 @@ void end_link(PDF pdf, halfword p)
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;
+ pdf_ann_top(q) = pdf->page_size.v - getury() - pdf_link_margin;
pdf_ann_right(q) = geturx() + pdf_link_margin;
- pdf_ann_bottom(q) = cur_page_size.v - getlly() + pdf_link_margin;
+ pdf_ann_bottom(q) = pdf->page_size.v - getlly() + pdf_link_margin;
} else {
switch (pdf->posstruct->dir) {
case dir_TLT:
@@ -108,13 +108,14 @@ void end_link(PDF pdf, halfword p)
case dir_RTT:
pdf_ann_bottom(q) = pos.v - pdf_link_margin;
break;
+ default:
+ assert(0);
}
}
}
pop_link_level(pdf);
}
-
@ For ``running'' annotations we must append a new node when the end of
annotation is in other box than its start. The new created node is identical to
corresponding whatsit node representing the start of annotation, but its
@@ -122,7 +123,7 @@ corresponding whatsit node representing the start of annotation, but its
node, in order to use |flush_node_list| to do the job.
-@ Append a new pdf annot to |pdf_link_list|
+@ Append a new pdf annot to |pdf_link_list|.
@c
void append_link(PDF pdf, halfword parent_box, scaledpos cur, small_number i)
@@ -150,7 +151,7 @@ void scan_startlink(PDF pdf)
halfword r;
if (abs(cur_list.mode_field) == vmode)
pdf_error("ext1", "\\pdfstartlink cannot be used in vertical mode");
- k = pdf_new_objnum(pdf);
+ k = pdf_create_obj(pdf, obj_type_others, 0);
new_annot_whatsit(pdf_start_link_node);
set_pdf_link_attr(cur_list.tail_field, null);
if (scan_keyword("attr")) {
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w b/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w
index 6eac5664e48..6d34c04a2e6 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w
@@ -1,19 +1,19 @@
% pdflistout.w
-
+%
% Copyright 2009-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/>.
@@ -21,8 +21,8 @@
@ @c
static const char _svn_version[] =
- "$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 $";
+ "$Id: pdflistout.w 4576 2013-02-08 20:42:57Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdflistout.w $";
#include "ptexlib.h"
@@ -329,7 +329,6 @@ void hlist_out(PDF pdf, halfword this_box)
scaled leader_wd; /* width of leader box being replicated */
scaled lx; /* extra space between leader boxes */
boolean outer_doing_leaders; /* were we doing leaders? */
- halfword prev_p; /* one step behind |p| */
real glue_temp; /* glue value before rounding */
real cur_glue = 0.0; /* glue seen so far */
scaled cur_g = 0; /* rounded equivalent of |cur_glue| times the glue ratio */
@@ -359,7 +358,6 @@ void hlist_out(PDF pdf, halfword this_box)
save_loc = dvi_offset + dvi_ptr /* DVI! */ ;
}
- prev_p = this_box + list_offset;
/* Create link annotations for the current hbox if needed */
for (i = 1; i <= pdf->link_stack_ptr; i++) {
assert(is_running(width(pdf->link_stack[i].link_node)));
@@ -472,7 +470,7 @@ void hlist_out(PDF pdf, halfword this_box)
}
break;
case rule_node:
- if (rule_dir(p)<0)
+ if (rule_dir(p) < 0)
rule_dir(p) = localpos.dir;
if (pardir_parallel(rule_dir(p), localpos.dir)) {
rule.ht = height(p);
@@ -525,6 +523,8 @@ void hlist_out(PDF pdf, halfword this_box)
pos_left(depth(p));
pos_down(width(p));
break;
+ default:
+ assert(0);
}
backend_out_whatsit[subtype(p)] (pdf, p);
cur.h += width(p);
@@ -569,8 +569,8 @@ void hlist_out(PDF pdf, halfword this_box)
break;
case glue_node:
/* (\pdfTeX) Move right or output leaders */
-
- g = glue_ptr(p);
+ {
+ halfword g = glue_ptr(p);
rule.wd = width(g) - cur_g;
if (g_sign != normal) {
if (g_sign == stretching) {
@@ -629,6 +629,8 @@ void hlist_out(PDF pdf, halfword this_box)
cur.h =
refpos->pos.v - shipbox_refpos.v - cur.h;
break;
+ default:
+ assert(0);
}
if (cur.h < save_h)
cur.h += leader_wd;
@@ -701,6 +703,7 @@ void hlist_out(PDF pdf, halfword this_box)
goto NEXTP;
}
}
+ }
goto MOVE_PAST;
break;
case margin_kern_node:
@@ -753,7 +756,8 @@ void hlist_out(PDF pdf, halfword this_box)
pos_left(rule.dp);
pos_down(size.v);
break;
- default:;
+ default:
+ assert(0);
}
backend_out[rule_node] (pdf, p, size); /* |pdf_place_rule(pdf, p, rule.ht + rule.dp, rule.wd);| */
}
@@ -765,7 +769,6 @@ void hlist_out(PDF pdf, halfword this_box)
synctexhorizontalruleorglue(p, this_box);
}
NEXTP:
- prev_p = p;
p = vlink(p);
synch_pos_with_cur(pdf->posstruct, refpos, cur);
}
@@ -913,7 +916,7 @@ void vlist_out(PDF pdf, halfword this_box)
}
break;
case rule_node:
- if (rule_dir(p)<0)
+ if (rule_dir(p) < 0)
rule_dir(p) = localpos.dir;
if (pardir_parallel(rule_dir(p), localpos.dir)) {
rule.ht = height(p);
@@ -966,7 +969,7 @@ void vlist_out(PDF pdf, halfword this_box)
pos_down(width(p));
break;
default:
- break;
+ assert(0);
}
backend_out_whatsit[subtype(p)] (pdf, p);
cur.v += height(p) + depth(p);
@@ -977,7 +980,8 @@ void vlist_out(PDF pdf, halfword this_box)
break;
case glue_node:
/* (\pdfTeX) Move down or output leaders */
- g = glue_ptr(p);
+ {
+ halfword g = glue_ptr(p);
rule.ht = width(g) - cur_g;
if (g_sign != normal) {
if (g_sign == stretching) {
@@ -1032,6 +1036,8 @@ void vlist_out(PDF pdf, halfword this_box)
cur.v =
refpos->pos.v - shipbox_refpos.v - cur.v;
break;
+ default:
+ assert(0);
}
if (cur.v < save_v)
cur.v += leader_ht;
@@ -1073,6 +1079,7 @@ void vlist_out(PDF pdf, halfword this_box)
goto NEXTP;
}
}
+ }
goto MOVE_PAST;
break;
case kern_node:
@@ -1110,7 +1117,8 @@ void vlist_out(PDF pdf, halfword this_box)
pos_left(size.h);
pos_down(size.v);
break;
- default:;
+ default:
+ assert(0);
}
backend_out[rule_node] (pdf, p, size); /* |pdf_place_rule(pdf, rule.ht, rule.wd);| */
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w b/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w
index 798036f80bd..359c7cf46b8 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w
@@ -1,28 +1,28 @@
% pdfliteral.w
%
% Copyright 2009-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
-#include "ptexlib.h"
-
static const char _svn_version[] =
- "$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 $";
+ "$Id: pdfliteral.w 4442 2012-05-25 22:40:34Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfliteral.w $";
+
+#include "ptexlib.h"
@ @c
void pdf_special(PDF pdf, halfword p)
@@ -70,7 +70,7 @@ void pdf_out_literal(PDF pdf, halfword p)
break;
case direct_always:
pdf_end_string_nl(pdf);
- ps->need_tm = 1;
+ ps->need_tm = true;
break;
default:
confusion("literal1");
@@ -136,7 +136,7 @@ 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;
+ p->need_tm = true;
break;
default:
confusion("literal1");
@@ -150,5 +150,5 @@ void pdf_literal(PDF pdf, str_number s, int literal_mode, boolean warn)
assert(s < 256);
pdf_out(pdf, s);
}
- pdf_print_nl(pdf);
+ pdf_out(pdf, '\n');
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.w b/Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.w
index c07c3ce9929..676167eab2e 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.w
@@ -1,26 +1,26 @@
% 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 $";
+ "$Id: pdfluaapi.w 4524 2012-12-20 15:38:02Z taco $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfluaapi.w $";
#include "ptexlib.h"
@@ -41,7 +41,7 @@ int new_pdflua(void)
|| 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); /* - */
+ i = luaL_ref(Luas, LUA_REGISTRYINDEX); /* - */
xfree(uncompr);
return i;
}
@@ -50,7 +50,7 @@ int new_pdflua(void)
void pdflua_begin_page(PDF pdf)
{
int err; /* ... */
- lua_rawgeti(Luas, LUA_GLOBALSINDEX, pdf->pdflua_ref); /* t ... */
+ lua_rawgeti(Luas, LUA_REGISTRYINDEX, pdf->pdflua_ref); /* t ... */
lua_pushstring(Luas, "beginpage"); /* s t ... */
lua_gettable(Luas, -2); /* f t ... */
lua_newtable(Luas); /* t f t ... */
@@ -73,15 +73,15 @@ void pdflua_begin_page(PDF pdf)
void pdflua_end_page(PDF pdf, int annots, int beads)
{
int err; /* ... */
- lua_rawgeti(Luas, LUA_GLOBALSINDEX, pdf->pdflua_ref); /* t ... */
+ lua_rawgeti(Luas, LUA_REGISTRYINDEX, 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_pushnumber(Luas, pdf->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_pushnumber(Luas, pdf->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 ... */
@@ -106,7 +106,7 @@ void pdflua_end_page(PDF pdf, int annots, int beads)
void pdflua_output_pages_tree(PDF pdf)
{
int err;
- lua_rawgeti(Luas, LUA_GLOBALSINDEX, pdf->pdflua_ref); /* t */
+ lua_rawgeti(Luas, LUA_REGISTRYINDEX, pdf->pdflua_ref); /* t */
lua_pushstring(Luas, "outputpagestree"); /* s t */
lua_gettable(Luas, -2); /* f */
err = lua_pcall(Luas, 0, 0, 0); /* - */
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h
index 6b6f628b8ec..01613dd2cc6 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h
@@ -1,6 +1,6 @@
/* pdfobj.h
- Copyright 2009 Taco Hoekwater <taco@luatex.org>
+ Copyright 2009-2011 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
@@ -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 3874 2010-09-11 22:22:05Z hhenkel $ */
+/* $Id: pdfobj.h 4184 2011-04-19 21:15:22Z hhenkel $ */
#ifndef PDFOBJ_H
# define PDFOBJ_H
@@ -32,13 +32,13 @@
# define obj_obj_stream_attr(pdf, A) pdf->mem[obj_data_ptr((pdf), (A)) + 1] /* additional attributes into stream dict */
# define obj_obj_flags(pdf, A) pdf->mem[obj_data_ptr((pdf), (A)) + 2] /* stream/file flags */
# define obj_obj_pdfcompresslevel(pdf, A) pdf->mem[obj_data_ptr((pdf), (A)) + 3] /* overrides \pdfcompresslevel */
-# define obj_obj_pdfoslevel(pdf, A) pdf->mem[obj_data_ptr((pdf), (A)) + 4] /* for object stream compression */
+# define obj_obj_objstm_threshold(pdf, A) pdf->mem[obj_data_ptr((pdf), (A)) + 4] /* for object stream compression */
/* define set_obj_obj_data(pdf, A, B) obj_obj_data((pdf), (A)) = (B) */
/* define set_obj_obj_flags(pdf, A, B) obj_obj_flags((pdf), (A)) = (B) */
/* define set_obj_obj_stream_attr(pdf, A, B) obj_obj_stream_attr((pdf), (A)) = (B) */
/* define set_obj_obj_pdfcompresslevel(pdf, A, B) obj_obj_pdfcompresslevel((pdf), (A)) = (B) */
-/* define set_obj_obj_pdfoslevel(pdf, A, B) obj_obj_pdfoslevel((pdf), (A)) = (B) */
+/* define set_obj_obj_objstm_threshold(pdf, A, B) obj_obj_objstm_threshold((pdf), (A)) = (B) */
/**********************************************************************/
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w
index 2d370ddc54f..914f86981bd 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w
@@ -1,30 +1,28 @@
% pdfobj.w
-
-% Copyright 2009-2010 Taco Hoekwater <taco@@luatex.org>
-
+%
+% Copyright 2009-2011 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/>.
+% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
static const char _svn_version[] =
- "$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 $";
+ "$Id: pdfobj.w 4442 2012-05-25 22:40:34Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfobj.w $";
#include "ptexlib.h"
-
-@ @c
#include "lua/luatex-api.h"
int pdf_last_obj;
@@ -38,16 +36,17 @@ void pdf_write_obj(PDF pdf, int k)
const_lstring st;
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 os_threshold = OBJSTM_ALWAYS; /* gives compressed objects for \.{\\pdfobjcompresslevel} >= |OBJSTM_ALWAYS| */
int l = 0; /* possibly a lua registry reference */
int ll = 0;
data.s = NULL;
if (obj_obj_pdfcompresslevel(pdf, k) > -1) /* -1 = "unset" */
pdf->compress_level = obj_obj_pdfcompresslevel(pdf, k);
- if (obj_obj_pdfoslevel(pdf, k) > -1) /* -1 = "unset" */
- os_level = obj_obj_pdfoslevel(pdf, k);
+ if (obj_obj_objstm_threshold(pdf, k) != OBJSTM_UNSET)
+ os_threshold = obj_obj_objstm_threshold(pdf, k);
if (obj_obj_is_stream(pdf, k)) {
- pdf_begin_dict(pdf, k, 0);
+ pdf_begin_obj(pdf, k, OBJSTM_NEVER);
+ pdf_begin_dict(pdf);
l = obj_obj_stream_attr(pdf, k);
if (l != LUA_NOREF) {
lua_rawgeti(Luas, LUA_REGISTRYINDEX, l);
@@ -60,15 +59,17 @@ void pdf_write_obj(PDF pdf, int k)
luaL_unref(Luas, LUA_REGISTRYINDEX, l);
obj_obj_stream_attr(pdf, k) = LUA_NOREF;
}
+ pdf_dict_add_streaminfo(pdf);
+ pdf_end_dict(pdf);
pdf_begin_stream(pdf);
} else
- pdf_begin_obj(pdf, k, os_level);
+ pdf_begin_obj(pdf, k, os_threshold);
l = obj_obj_data(pdf, k);
lua_rawgeti(Luas, LUA_REGISTRYINDEX, l);
assert(lua_isstring(Luas, -1));
st.s = lua_tolstring(Luas, -1, &li);
st.l = li;
- lua_pop(Luas,1);
+ lua_pop(Luas, 1);
if (obj_obj_is_file(pdf, k)) {
boolean res = false; /* callback status value */
const char *fnam = NULL; /* callback found filename */
@@ -110,9 +111,10 @@ void pdf_write_obj(PDF pdf, int k)
if (!obj_obj_is_stream(pdf, k) && st.s[st.l - 1] != '\n')
pdf_out(pdf, '\n');
}
- if (obj_obj_is_stream(pdf, k))
+ if (obj_obj_is_stream(pdf, k)) {
pdf_end_stream(pdf);
- else
+ pdf_end_obj(pdf);
+ } else
pdf_end_obj(pdf);
luaL_unref(Luas, LUA_REGISTRYINDEX, l);
obj_obj_data(pdf, k) = LUA_NOREF;
@@ -127,7 +129,7 @@ void init_obj_obj(PDF pdf, int k)
unset_obj_obj_is_stream(pdf, k);
unset_obj_obj_is_file(pdf, k);
obj_obj_pdfcompresslevel(pdf, k) = -1; /* unset */
- obj_obj_pdfoslevel(pdf, k) = -1; /* unset */
+ obj_obj_objstm_threshold(pdf, k) = OBJSTM_UNSET; /* unset */
}
@ The \.{\\pdfobj} primitive is used to create a ``raw'' object in the PDF
@@ -148,7 +150,7 @@ void scan_obj(PDF pdf)
if (cur_cmd != spacer_cmd)
back_input();
pdf->obj_count++;
- k = pdf_create_obj(pdf, obj_type_obj, pdf->obj_ptr + 1);
+ k = pdf_create_obj(pdf, obj_type_obj, 0);
} else {
if (scan_keyword("useobjnum")) {
scan_int();
@@ -158,13 +160,13 @@ void scan_obj(PDF pdf)
luaL_error(Luas, "object in use");
} else {
pdf->obj_count++;
- k = pdf_create_obj(pdf, obj_type_obj, pdf->obj_ptr + 1);
+ k = pdf_create_obj(pdf, obj_type_obj, 0);
}
obj_data_ptr(pdf, k) = pdf_get_mem(pdf, pdfmem_obj_size);
init_obj_obj(pdf, k);
if (scan_keyword("uncompressed")) {
obj_obj_pdfcompresslevel(pdf, k) = 0; /* \pdfcompresslevel = 0 */
- obj_obj_pdfoslevel(pdf, k) = 0;
+ obj_obj_objstm_threshold(pdf, k) = OBJSTM_NEVER;
}
if (scan_keyword("stream")) {
set_obj_obj_is_stream(pdf, k);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w b/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w
index dc97c290f30..ce52800f48f 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w
@@ -1,28 +1,28 @@
% pdfoutline.w
-%
-% Copyright 2009-2010 Taco Hoekwater <taco@@luatex.org>
-
+%
+% Copyright 2009-2011 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/>.
+% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
-#include "ptexlib.h"
-
static const char _svn_version[] =
- "$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 $";
+ "$Id: pdfoutline.w 4442 2012-05-25 22:40:34Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfoutline.w $";
+
+#include "ptexlib.h"
@ Data structure of outlines; it's not able to write out outline entries
before all outline entries are defined, so memory allocated for outline
@@ -82,7 +82,7 @@ static int open_subentries(PDF pdf, halfword p)
return k;
}
-@ return number of outline entries in the same level with |p|
+@ return number of outline entries in the same level with |p|
@c
static int outline_list_count(PDF pdf, pointer p)
@@ -115,7 +115,8 @@ void scan_pdfoutline(PDF pdf)
}
scan_pdf_ext_toks();
q = def_ref;
- j = pdf_new_obj(pdf, obj_type_others, 0, 1);
+ j = pdf_create_obj(pdf, obj_type_others, 0);
+ pdf_begin_obj(pdf, j, OBJSTM_ALWAYS);
write_action(pdf, p);
pdf_end_obj(pdf);
delete_action_ref(p);
@@ -123,7 +124,8 @@ void scan_pdfoutline(PDF pdf)
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);
- l = pdf_new_obj(pdf, obj_type_others, 0, 1);
+ l = pdf_create_obj(pdf, obj_type_others, 0);
+ pdf_begin_obj(pdf, l, OBJSTM_ALWAYS);
{
char *s = tokenlist_to_cstring(q, true, NULL);
pdf_print_str_ln(pdf, s);
@@ -172,7 +174,7 @@ void scan_pdfoutline(PDF pdf)
}
@ In the end we must flush PDF objects that cannot be written out
-immediately after shipping out pages.
+immediately after shipping out pages.
@c
int print_outlines(PDF pdf)
@@ -180,7 +182,7 @@ int print_outlines(PDF pdf)
int k, l, a;
int outlines;
if (pdf->first_outline != 0) {
- outlines = pdf_new_dict(pdf, obj_type_others, 0, 1);
+ outlines = pdf_create_obj(pdf, obj_type_others, 0);
l = pdf->first_outline;
k = 0;
do {
@@ -191,11 +193,14 @@ int print_outlines(PDF pdf)
set_obj_outline_parent(pdf, l, pdf->obj_ptr);
l = obj_outline_next(pdf, l);
} while (l != 0);
- pdf_printf(pdf, "/Type /Outlines\n");
- pdf_indirect_ln(pdf, "First", pdf->first_outline);
- pdf_indirect_ln(pdf, "Last", pdf->last_outline);
- pdf_int_entry_ln(pdf, "Count", k);
+ pdf_begin_obj(pdf, outlines, OBJSTM_ALWAYS);
+ pdf_begin_dict(pdf);
+ pdf_dict_add_name(pdf, "Type", "Outlines");
+ pdf_dict_add_ref(pdf, "First", pdf->first_outline);
+ pdf_dict_add_ref(pdf, "Last", pdf->last_outline);
+ pdf_dict_add_int(pdf, "Count", k);
pdf_end_dict(pdf);
+ pdf_end_obj(pdf);
/* Output PDF outline entries */
k = pdf->head_tab[obj_type_outline];
@@ -206,27 +211,31 @@ int print_outlines(PDF pdf)
if (obj_outline_next(pdf, k) == 0)
pdf->last_outline = k;
}
- pdf_begin_dict(pdf, k, 1);
- pdf_indirect_ln(pdf, "Title", obj_outline_title(pdf, k));
- pdf_indirect_ln(pdf, "A", obj_outline_action_objnum(pdf, k));
+ pdf_begin_obj(pdf, k, OBJSTM_ALWAYS);
+ pdf_begin_dict(pdf);
+ pdf_dict_add_ref(pdf, "Title", obj_outline_title(pdf, k));
+ pdf_dict_add_ref(pdf, "A", obj_outline_action_objnum(pdf, k));
if (obj_outline_parent(pdf, k) != 0)
- pdf_indirect_ln(pdf, "Parent", obj_outline_parent(pdf, k));
+ pdf_dict_add_ref(pdf, "Parent", obj_outline_parent(pdf, k));
if (obj_outline_prev(pdf, k) != 0)
- pdf_indirect_ln(pdf, "Prev", obj_outline_prev(pdf, k));
+ pdf_dict_add_ref(pdf, "Prev", obj_outline_prev(pdf, k));
if (obj_outline_next(pdf, k) != 0)
- pdf_indirect_ln(pdf, "Next", obj_outline_next(pdf, k));
+ pdf_dict_add_ref(pdf, "Next", obj_outline_next(pdf, k));
if (obj_outline_first(pdf, k) != 0)
- pdf_indirect_ln(pdf, "First", obj_outline_first(pdf, k));
+ pdf_dict_add_ref(pdf, "First", obj_outline_first(pdf, k));
if (obj_outline_last(pdf, k) != 0)
- pdf_indirect_ln(pdf, "Last", obj_outline_last(pdf, k));
+ pdf_dict_add_ref(pdf, "Last", obj_outline_last(pdf, k));
if (obj_outline_count(pdf, k) != 0)
- pdf_int_entry_ln(pdf, "Count", obj_outline_count(pdf, k));
+ pdf_dict_add_int(pdf, "Count", obj_outline_count(pdf, k));
if (obj_outline_attr(pdf, k) != 0) {
- pdf_print_toks_ln(pdf, obj_outline_attr(pdf, k));
+ pdf_out(pdf, '\n');
+ pdf_print_toks(pdf, obj_outline_attr(pdf, k));
+ pdf_out(pdf, '\n');
delete_token_ref(obj_outline_attr(pdf, k));
set_obj_outline_attr(pdf, k, null);
}
pdf_end_dict(pdf);
+ pdf_end_obj(pdf);
k = obj_link(pdf, k);
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfpage.h b/Build/source/texk/web2c/luatexdir/pdf/pdfpage.h
index 39a15ab5ff9..a4fe0f53ba0 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfpage.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfpage.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: pdfpage.h 3003 2009-08-16 19:55:55Z hhenkel $ */
+/* $Id: pdfpage.h 4313 2011-06-21 18:31:19Z hhenkel $ */
#ifndef PDFPAGE_H
# define PDFPAGE_H
@@ -47,7 +47,6 @@ void init_pdf_pagecalculations(PDF pdf);
void pdf_print_cm(PDF pdf, pdffloat * cm);
void pdf_set_pos(PDF pdf, scaledpos pos);
void pdf_set_pos_temp(PDF pdf, scaledpos pos);
-void print_pdffloat(PDF pdf, pdffloat f);
void print_pdf_matrix(PDF pdf, pdffloat * tm);
#endif
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w b/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w
index 75597439e95..a16f2d98808 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w
@@ -1,26 +1,26 @@
% pdfpage.w
-
-% Copyright 2006-2010 Taco Hoekwater <taco@@luatex.org>
-
+%
+% Copyright 2006-2012 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/>.
+% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
static const char _svn_version[] =
- "$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 $";
+ "$Id: pdfpage.w 4451 2012-07-05 21:13:01Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfpage.w $";
#include "ptexlib.h"
@@ -29,8 +29,6 @@ static const char _svn_version[] =
#include <assert.h>
#include <math.h>
-#define lround(a) (long) floor((a) + 0.5)
-
@ eternal constants
@c
#define one_bp ((double) 65536 * (double) 72.27 / 72) /* number of sp per 1bp */
@@ -56,10 +54,11 @@ void init_pdf_pagecalculations(PDF pdf)
setpdffloat(p->cm[4], 0, decimal_digits); /* horizontal movement on page */
setpdffloat(p->cm[5], 0, decimal_digits); /* vertical movement on page */
/* for placement inside BT...ET */
+ setpdffloat(p->tm0_cur, 0, 6); /* mantissa holds HZ expand * ExtendFont */
setpdffloat(p->tm[0], ten_pow[6], 6); /* mantissa holds HZ expand * ExtendFont */
setpdffloat(p->tm[1], 0, 0);
setpdffloat(p->tm[2], 0, 3); /* mantissa holds SlantFont, 0 = default */
- setpdffloat(p->tm[3], 1, 0);
+ setpdffloat(p->tm[3], ten_pow[6], 6);
setpdffloat(p->tm[4], 0, decimal_digits); /* mantissa holds delta from |pdf_bt_pos.h| */
setpdffloat(p->tm[5], 0, decimal_digits); /* mantissa holds delta from |pdf_bt_pos.v| */
/* */
@@ -68,7 +67,8 @@ void init_pdf_pagecalculations(PDF pdf)
p->wmode = WMODE_H;
p->mode = PMODE_PAGE;
p->ishex = 0;
- p->need_tm = 0;
+ p->need_tf = false;
+ p->need_tm = false;
p->k1 = ten_pow[p->pdf.h.e] / one_bp;
}
@@ -158,38 +158,12 @@ boolean calc_pdfpos(pdfstructure * p, scaledpos pos)
}
@ @c
-void print_pdffloat(PDF pdf, pdffloat f)
-{
- char a[24];
- int e = f.e, i, j;
- long l, m = f.m;
- if (m < 0) {
- pdf_puts(pdf, "-");
- m *= -1;
- }
- l = m / ten_pow[e];
- pdf_print_int(pdf, l);
- l = m % ten_pow[e];
- if (l != 0) {
- pdf_puts(pdf, ".");
- j = snprintf(a, 23, "%ld", l + ten_pow[e]);
- assert((unsigned)j < 23);
- for (i = e; i > 0; i--) {
- if (a[i] != '0')
- break;
- a[i] = '\0';
- }
- pdf_puts(pdf, (a + 1));
- }
-}
-
-@ @c
void print_pdf_matrix(PDF pdf, pdffloat * tm)
{
int i;
for (i = 0; i < 5; i++) {
print_pdffloat(pdf, tm[i]);
- pdf_puts(pdf, " ");
+ pdf_out(pdf, ' ');
}
print_pdffloat(pdf, tm[i]);
}
@@ -234,8 +208,7 @@ static void begin_text(PDF pdf)
p->pdf_bt_pos = p->pdf;
pdf_puts(pdf, "BT\n");
p->mode = PMODE_TEXT;
- p->f_pdf_cur = null_font; /* forces Tf operator */
- p->fs_cur.m = 0;
+ p->need_tf = true;
}
static void end_text(PDF pdf)
@@ -268,14 +241,14 @@ void pdf_goto_pagemode(PDF pdf)
end_chararray(pdf);
if (is_textmode(p))
end_text(pdf);
- assert(is_pagemode(p));
}
+ assert(is_pagemode(p));
}
void pdf_goto_textmode(PDF pdf)
{
pdfstructure *p = pdf->pstruct;
- scaledpos origin = {
+ const scaledpos origin = {
0, 0
};
if (!is_textmode(p)) {
@@ -288,6 +261,6 @@ void pdf_goto_textmode(PDF pdf)
if (is_chararraymode(p))
end_chararray(pdf);
}
- assert(is_textmode(p));
}
+ assert(is_textmode(p));
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pagetree.h b/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.h
index d4b8a11c134..13185874ca0 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pagetree.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.h
@@ -1,6 +1,6 @@
-/* pagetree.h
+/* pdfpagetree.h
- Copyright 2009 Taco Hoekwater <taco@luatex.org>
+ Copyright 2009--2011 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
@@ -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: pagetree.h 3261 2009-12-18 11:38:21Z taco $ */
+/* $Id: pdfpagetree.h 4214 2011-04-27 21:53:38Z hhenkel $ */
#ifndef PAGETREE_H
# define PAGETREE_H
@@ -26,4 +26,4 @@ int output_pages_tree(PDF);
int pdf_do_page_divert(PDF, int, int);
void pdf_do_page_undivert(int, int);
-#endif
+#endif /* PAGETREE_H */
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pagetree.w b/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.w
index b126d8a7a25..88d4ab796b9 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pagetree.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.w
@@ -1,28 +1,28 @@
-% pagetree.w
-%
-% Copyright 2006-2010 Taco Hoekwater <taco@@luatex.org>
-
+% pdfpagetree.w
+%
+% Copyright 2006-2011 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/>.
+% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
-#include "ptexlib.h"
-
static const char _svn_version[] =
- "$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 $";
+ "$Id: pdfpagetree.w 4442 2012-05-25 22:40:34Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfpagetree.w $";
+
+#include "ptexlib.h"
@* Page diversions.
@@ -30,7 +30,7 @@ static const char _svn_version[] =
#ifdef DEBUG
# define PAGES_TREE_KIDSMAX 3
#else
-# define PAGES_TREE_KIDSMAX 6
+# define PAGES_TREE_KIDSMAX 10
#endif
static struct avl_table *divert_list_tree = NULL;
@@ -110,7 +110,7 @@ static divert_list_entry *get_divert_list(int divnum)
return d;
}
-@ |pdf_do_page_divert()| returns the current /Parent object number
+@ |pdf_do_page_divert()| returns the current /Parent object number
@c
int pdf_do_page_divert(PDF pdf, int objnum, int divnum)
{
@@ -209,7 +209,7 @@ void pdf_do_page_undivert(int divnum, int curdivnum)
#endif
}
-@ write a /Pages object
+@ write a /Pages object
@c
#define pdf_pages_attr equiv(pdf_pages_attr_loc)
@@ -217,24 +217,29 @@ static void write_pages(PDF pdf, pages_entry * p, int parent)
{
int i;
assert(p != NULL);
- pdf_begin_dict(pdf, p->objnum, 1);
- pdf_printf(pdf, "/Type /Pages\n");
+ pdf_begin_obj(pdf, p->objnum, OBJSTM_ALWAYS);
+ pdf_begin_dict(pdf);
+ pdf_dict_add_name(pdf, "Type", "Pages");
if (parent == 0) { /* it's root */
- if (pdf_pages_attr != null)
- pdf_print_toks_ln(pdf, pdf_pages_attr);
+ if (pdf_pages_attr != null) {
+ pdf_print_toks(pdf, pdf_pages_attr);
+ pdf_out(pdf, ' ');
+ }
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);
+ pdf_dict_add_ref(pdf, "Parent", parent);
+ pdf_dict_add_int(pdf, "Count", (int) p->number_of_pages);
+ pdf_add_name(pdf, "Kids");
+ pdf_begin_array(pdf);
for (i = 0; i < p->number_of_kids; i++)
- pdf_printf(pdf, "%d 0 R ", (int) p->kids[i]);
- pdf_remove_last_space(pdf);
- pdf_printf(pdf, "]\n");
+ pdf_add_ref(pdf, (int) p->kids[i]);
+ pdf_end_array(pdf);
pdf_end_dict(pdf);
+ pdf_end_obj(pdf);
}
@ loop over all /Pages objects, output them, create their parents,
-recursing bottom up, return the /Pages root object number
+recursing bottom up, return the /Pages root object number
@c
static int output_pages_list(PDF pdf, pages_entry * pe)
{
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w b/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w
index 4b70e9cfa31..3f10c8c9ada 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w
@@ -1,34 +1,30 @@
% pdfrule.w
-%
-% Copyright 2010 Taco Hoekwater <taco@@luatex.org>
-
+%
+% Copyright 2010-2011 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: pdfrule.w 3584 2010-04-02 17:45:55Z hhenkel $"
- "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/pdf/pdfrule.w $";
+ "$Id: pdfrule.w 4442 2012-05-25 22:40:34Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfrule.w $";
#include "ptexlib.h"
-
-@ @c
#include "pdf/pdfpage.h"
-#define lround(a) (long) floor((a) + 0.5)
-
@ @c
void pdf_place_rule(PDF pdf, halfword q, scaledpos size)
{
@@ -41,30 +37,30 @@ void pdf_place_rule(PDF pdf, halfword q, scaledpos size)
dim.h.e = p->pdf.h.e;
dim.v.m = lround(size.v * p->k1);
dim.v.e = p->pdf.v.e;
- pdf_printf(pdf, "q\n");
+ pdf_puts(pdf, "q\n");
if (size.v <= one_bp) {
pos.v += (int) lround(0.5 * size.v);
pdf_set_pos_temp(pdf, pos);
- pdf_printf(pdf, "[]0 d 0 J ");
+ pdf_puts(pdf, "[]0 d 0 J ");
print_pdffloat(pdf, dim.v);
- pdf_printf(pdf, " w 0 0 m ");
+ pdf_puts(pdf, " w 0 0 m ");
print_pdffloat(pdf, dim.h);
- pdf_printf(pdf, " 0 l S\n");
+ pdf_puts(pdf, " 0 l S\n");
} else if (size.h <= one_bp) {
pos.h += (int) lround(0.5 * size.h);
pdf_set_pos_temp(pdf, pos);
- pdf_printf(pdf, "[]0 d 0 J ");
+ pdf_puts(pdf, "[]0 d 0 J ");
print_pdffloat(pdf, dim.h);
- pdf_printf(pdf, " w 0 0 m 0 ");
+ pdf_puts(pdf, " w 0 0 m 0 ");
print_pdffloat(pdf, dim.v);
- pdf_printf(pdf, " l S\n");
+ pdf_puts(pdf, " l S\n");
} else {
pdf_set_pos_temp(pdf, pos);
- pdf_printf(pdf, "0 0 ");
+ pdf_puts(pdf, "0 0 ");
print_pdffloat(pdf, dim.h);
- pdf_printf(pdf, " ");
+ pdf_out(pdf, ' ');
print_pdffloat(pdf, dim.v);
- pdf_printf(pdf, " re f\n");
+ pdf_puts(pdf, " re f\n");
}
- pdf_printf(pdf, "Q\n");
+ pdf_puts(pdf, "Q\n");
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w b/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w
index 5a5f4fea22d..8341240a716 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w
@@ -1,26 +1,26 @@
% pdfsaverestore.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/>.
+% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
static const char _svn_version[] =
- "$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 $";
+ "$Id: pdfsaverestore.w 4442 2012-05-25 22:40:34Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w $";
#include "ptexlib.h"
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w b/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w
index 0dbb8be7cc6..ed14c9f6407 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w
@@ -1,26 +1,26 @@
% pdfsetmatrix.w
-%
+%
% 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/>.
+% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
static const char _svn_version[] =
- "$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 $";
+ "$Id: pdfsetmatrix.w 4442 2012-05-25 22:40:34Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w $";
#include "ptexlib.h"
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w b/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w
index f00ac0b2722..763ee508ac6 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w
@@ -1,26 +1,26 @@
% pdfshipout.w
-
-% Copyright 2010 Taco Hoekwater <taco@@luatex.org>
-
+%
+% Copyright 2010-2012 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/>.
+% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
static const char _svn_version[] =
- "$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 $";
+ "$Id: pdfshipout.w 4451 2012-07-05 21:13:01Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfshipout.w $";
#include "ptexlib.h"
@@ -141,35 +141,39 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
/* Calculate page dimensions and margins */
if (global_shipping_mode == SHIPPING_PAGE) {
if (page_width > 0)
- cur_page_size.h = page_width;
+ pdf->page_size.h = page_width;
else {
switch (page_direction) {
case dir_TLT:
- cur_page_size.h = width(p) + 2 * page_left_offset;
+ pdf->page_size.h = width(p) + 2 * page_left_offset;
break;
case dir_TRT:
- cur_page_size.h = width(p) + 2 * page_right_offset;
+ pdf->page_size.h = width(p) + 2 * page_right_offset;
break;
case dir_LTL:
- cur_page_size.h = height(p) + depth(p) + 2 * page_left_offset;
+ pdf->page_size.h = height(p) + depth(p) + 2 * page_left_offset;
break;
case dir_RTT:
- cur_page_size.h = height(p) + depth(p) + 2 * page_right_offset;
+ pdf->page_size.h = height(p) + depth(p) + 2 * page_right_offset;
break;
+ default:
+ assert(0);
}
}
if (page_height > 0)
- cur_page_size.v = page_height;
+ pdf->page_size.v = page_height;
else {
switch (page_direction) {
case dir_TLT:
case dir_TRT:
- cur_page_size.v = height(p) + depth(p) + 2 * page_top_offset;
+ pdf->page_size.v = height(p) + depth(p) + 2 * page_top_offset;
break;
case dir_LTL:
case dir_RTT:
- cur_page_size.v = width(p) + 2 * page_top_offset;
+ pdf->page_size.v = width(p) + 2 * page_top_offset;
break;
+ default:
+ assert(0);
}
}
@@ -179,13 +183,13 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
switch (pdf->o_mode) {
case OMODE_DVI:
refpoint.pos.h = one_true_inch;
- refpoint.pos.v = cur_page_size.v - one_true_inch;
+ refpoint.pos.v = pdf->page_size.v - one_true_inch;
dvi = refpoint.pos;
break;
case OMODE_PDF:
case OMODE_LUA:
refpoint.pos.h = pdf_h_origin;
- refpoint.pos.v = cur_page_size.v - pdf_v_origin;
+ refpoint.pos.v = pdf->page_size.v - pdf_v_origin;
break;
default:
assert(0);
@@ -203,9 +207,11 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
case dir_TRT:
case dir_RTT:
refpoint.pos.h +=
- cur_page_size.h - page_right_offset - one_true_inch;
+ pdf->page_size.h - page_right_offset - one_true_inch;
refpoint.pos.v -= v_offset;
break;
+ default:
+ assert(0);
}
/* Then switch to page box coordinate system; do |height(p)| movement,
@@ -221,14 +227,16 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
switch (pdf->posstruct->dir) {
case dir_TLT:
case dir_TRT:
- cur_page_size.h = width(p);
- cur_page_size.v = height(p) + depth(p);
+ pdf->page_size.h = width(p);
+ pdf->page_size.v = height(p) + depth(p);
break;
case dir_LTL:
case dir_RTT:
- cur_page_size.h = height(p) + depth(p);
- cur_page_size.v = width(p);
+ pdf->page_size.h = height(p) + depth(p);
+ pdf->page_size.v = width(p);
break;
+ default:
+ assert(0);
}
switch (pdf->posstruct->dir) {
case dir_TLT:
@@ -247,6 +255,8 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
pdf->posstruct->pos.h = depth(p);
pdf->posstruct->pos.v = width(p);
break;
+ default:
+ assert(0);
}
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftables.h b/Build/source/texk/web2c/luatexdir/pdf/pdftables.h
index dd7e5a57c70..38ea72bf328 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdftables.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdftables.h
@@ -1,6 +1,6 @@
/* pdftables.h
- Copyright 2009 Taco Hoekwater <taco@luatex.org>
+ Copyright 2009-2013 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
@@ -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: pdftables.h 4062 2011-01-11 20:47:28Z hhenkel $ */
+/* $Id: pdftables.h 4558 2013-01-19 14:21:59Z oneiros $ */
#ifndef PDFTABLES_H
# define PDFTABLES_H
@@ -67,30 +67,33 @@ structure depending on the object type; however it may be used as a counter as
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
- 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 */
-# define obj_stop(pdf,A) pdf->obj_tab[(A)].v.str4
-# define obj_type(pdf,A) pdf->obj_tab[(A)].objtype
-
-# define obj_data_ptr obj_aux /* pointer to |pdf->mem| */
-
-# define set_obj_link(pdf,A,B) obj_link(pdf,A)=B
-# define set_obj_start(pdf,A,B) obj_start(pdf,A)=B
-# define set_obj_info(pdf,A,B) obj_info(pdf,A)=B
-# define set_obj_offset(pdf,A,B) obj_offset(pdf,A)=B
-# define set_obj_aux(pdf,A,B) obj_aux(pdf,A)=B
-# define set_obj_stop(pdf,A,B) obj_stop(pdf,A)=B
-# define set_obj_data_ptr(pdf,A,B) obj_data_ptr(pdf,A)=B
-
-# define set_obj_fresh(pdf,A) obj_offset(pdf,(A))=-2
-# define set_obj_scheduled(pdf,A) if (obj_offset(pdf,A)==-2) obj_offset(pdf,A)=-1
-# define is_obj_scheduled(pdf,A) (obj_offset(pdf,A)>-2)
-# define is_obj_written(pdf,A) (obj_offset(pdf,A)>-1)
+# 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
+ output file, or ... */
+# define obj_os_objnum(pdf,A) pdf->obj_tab[(A)].int2 /* ... 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 */
+# define obj_stop(pdf,A) pdf->obj_tab[(A)].v.str4
+# define obj_type(pdf,A) pdf->obj_tab[(A)].objtype
+
+# define obj_data_ptr obj_aux /* pointer to |pdf->mem| */
+
+# define set_obj_link(pdf,A,B) obj_link(pdf,A)=(B)
+# define set_obj_start(pdf,A,B) obj_start(pdf,A)=(B)
+# define set_obj_info(pdf,A,B) obj_info(pdf,A)=(B)
+# define set_obj_offset(pdf,A,B) obj_offset(pdf,A)=(B)
+# define set_obj_os_objnum(pdf,A,B) obj_offset(pdf,A)=(B)
+# define set_obj_aux(pdf,A,B) obj_aux(pdf,A)=(B)
+# define set_obj_stop(pdf,A,B) obj_stop(pdf,A)=(B)
+# define set_obj_data_ptr(pdf,A,B) obj_data_ptr(pdf,A)=(B)
+
+# define set_obj_fresh(pdf,A) obj_offset(pdf,(A))=(off_t)-2
+# define set_obj_scheduled(pdf,A) if (obj_offset(pdf,A)==(off_t)-2) obj_offset(pdf,A)=(off_t)-1
+# define is_obj_scheduled(pdf,A) ((obj_offset(pdf,A))>(off_t)-2)
+# define is_obj_written(pdf,A) ((obj_offset(pdf,A))>(off_t)-1)
/* NOTE: The data structure definitions for the nodes on the typesetting side are
inside |nodes.h| */
@@ -102,9 +105,8 @@ well.
extern int find_obj(PDF pdf, int t, int i, boolean byname);
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 int pdf_get_obj(PDF pdf, int t, int i, boolean byname);
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,
scaledpos cur, scaled_whd alt_rule, scaled margin);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftables.w b/Build/source/texk/web2c/luatexdir/pdf/pdftables.w
index b7f7869d3b4..99b9531d95f 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdftables.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdftables.w
@@ -1,26 +1,26 @@
% pdftables.w
-
+%
% Copyright 2009-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/>.
+% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
static const char _svn_version[] =
- "$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 $";
+ "$Id: pdftables.w 4442 2012-05-25 22:40:34Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdftables.w $";
#include "ptexlib.h"
@@ -142,7 +142,7 @@ int pdf_create_obj(PDF pdf, int t, int i)
if (i < 0) {
ss = makecstring(-i);
avl_put_str_obj(pdf, ss, pdf->obj_ptr, t);
- } else
+ } else if (i > 0)
avl_put_int_obj(pdf, i, pdf->obj_ptr, t);
if (t <= HEAD_TAB_MAX) {
obj_link(pdf, pdf->obj_ptr) = pdf->head_tab[t];
@@ -179,7 +179,7 @@ int find_obj(PDF pdf, int t, int i, boolean byname)
|vlist_out|.
@c
-int get_obj(PDF pdf, int t, int i, boolean byname)
+int pdf_get_obj(PDF pdf, int t, int i, boolean byname)
{
int r;
str_number s;
@@ -206,15 +206,8 @@ int get_obj(PDF pdf, int t, int i, boolean byname)
return r;
}
-@ create a new object and return its number
-
+@ object checking
@c
-int pdf_new_objnum(PDF pdf)
-{
- int k = pdf_create_obj(pdf, obj_type_others, 0);
- return k;
-}
-
void check_obj_exists(PDF pdf, int objnum)
{
if (objnum < 0 || objnum > pdf->obj_ptr)
@@ -290,7 +283,7 @@ void set_rect_dimens(PDF pdf, halfword p, halfword parent_box, scaledpos cur,
@ @c
void libpdffinish(PDF pdf)
{
- fb_free(pdf);
+ strbuf_free(pdf->fb);
xfree(pdf->job_id_string);
fm_free();
t1_free();
@@ -302,7 +295,6 @@ void libpdffinish(PDF pdf)
zip_free(pdf);
}
-
@ Store some of the pdftex data structures in the format. The idea here is
to ensure that any data structures referenced from pdftex-specific whatsit
nodes are retained. For the sake of simplicity and speed, all the filled parts
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w b/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w
index 72ba892fa50..c5728143b5c 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w
@@ -1,26 +1,26 @@
% pdfthread.w
-
-% Copyright 2009-2010 Taco Hoekwater <taco@@luatex.org>
-
+%
+% Copyright 2009-2012 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: 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 $";
+ "$Id: pdfthread.w 4451 2012-07-05 21:13:01Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfthread.w $";
#include "ptexlib.h"
@@ -36,8 +36,9 @@ void append_bead(PDF pdf, halfword p)
int a, b, c, t;
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);
+ t = pdf_get_obj(pdf, obj_type_thread, pdf_thread_id(p),
+ pdf_thread_named_id(p));
+ b = pdf_create_obj(pdf, obj_type_others, 0);
obj_bead_ptr(pdf, b) = pdf_get_mem(pdf, pdfmem_bead_size);
set_obj_bead_page(pdf, b, pdf->last_page);
set_obj_bead_data(pdf, b, p);
@@ -132,6 +133,8 @@ void end_thread(PDF pdf, halfword p)
case dir_RTT:
pdf_ann_left(pdf->last_thread) = pos.h - pdf_thread_margin;
break;
+ default:
+ assert(0);
}
}
if (pdf->last_thread_named_id)
@@ -143,12 +146,13 @@ void end_thread(PDF pdf, halfword p)
@c
void thread_title(PDF pdf, int t)
{
- pdf_printf(pdf, "/Title (");
+ pdf_add_name(pdf, "Title");
+ pdf_out(pdf, '(');
if (obj_info(pdf, t) < 0)
pdf_print(pdf, -obj_info(pdf, t));
else
pdf_print_int(pdf, obj_info(pdf, t));
- pdf_printf(pdf, ")\n");
+ pdf_out(pdf, ')');
}
void pdf_fix_thread(PDF pdf, int t)
@@ -166,23 +170,32 @@ 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();
- 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);
- pdf_indirect_ln(pdf, "P", pdf->last_page);
- pdf_printf(pdf, "/R [0 0 ");
- pdf_print_bp(pdf, page_width);
- pdf_out(pdf, ' ');
- pdf_print_bp(pdf, page_height);
- pdf_printf(pdf, "]\n");
+ a = pdf_create_obj(pdf, obj_type_others, 0);
+ pdf_begin_obj(pdf, a, OBJSTM_ALWAYS);
+ pdf_begin_dict(pdf);
+ pdf_dict_add_ref(pdf, "T", t);
+ pdf_dict_add_ref(pdf, "V", a);
+ pdf_dict_add_ref(pdf, "N", a);
+ pdf_dict_add_ref(pdf, "P", pdf->last_page);
+ pdf_add_name(pdf, "R");
+ pdf_begin_array(pdf);
+ pdf_add_int(pdf, 0);
+ pdf_add_int(pdf, 0);
+ pdf_add_bp(pdf, page_width);
+ pdf_add_bp(pdf, page_height);
+ pdf_end_array(pdf);
pdf_end_dict(pdf);
- pdf_begin_dict(pdf, t, 1);
- pdf_printf(pdf, "/I << \n");
+ pdf_end_obj(pdf);
+
+ pdf_begin_obj(pdf, t, OBJSTM_ALWAYS);
+ pdf_begin_dict(pdf);
+ pdf_add_name(pdf, "I");
+ pdf_begin_dict(pdf);
thread_title(pdf, t);
- pdf_printf(pdf, ">>\n");
- pdf_indirect_ln(pdf, "F", a);
pdf_end_dict(pdf);
+ pdf_dict_add_ref(pdf, "F", a);
+ pdf_end_dict(pdf);
+ pdf_end_obj(pdf);
}
void out_thread(PDF pdf, int t)
@@ -193,7 +206,8 @@ void out_thread(PDF pdf, int t)
pdf_fix_thread(pdf, t);
return;
}
- pdf_begin_dict(pdf, t, 1);
+ pdf_begin_obj(pdf, t, OBJSTM_ALWAYS);
+ pdf_begin_dict(pdf);
a = obj_thread_first(pdf, t);
b = a;
last_attr = 0;
@@ -205,26 +219,29 @@ void out_thread(PDF pdf, int t)
if (last_attr != 0) {
pdf_print_ln(pdf, last_attr);
} else {
- pdf_printf(pdf, "/I << \n");
+ pdf_add_name(pdf, "I");
+ pdf_begin_dict(pdf);
thread_title(pdf, t);
- pdf_printf(pdf, ">>\n");
+ pdf_end_dict(pdf);
}
- pdf_indirect_ln(pdf, "F", a);
+ pdf_dict_add_ref(pdf, "F", a);
pdf_end_dict(pdf);
+ pdf_end_obj(pdf);
do {
- pdf_begin_dict(pdf, a, 1);
+ pdf_begin_obj(pdf, a, OBJSTM_ALWAYS);
+ pdf_begin_dict(pdf);
if (a == b)
- pdf_indirect_ln(pdf, "T", t);
- pdf_indirect_ln(pdf, "V", obj_bead_prev(pdf, a));
- pdf_indirect_ln(pdf, "N", obj_bead_next(pdf, a));
- pdf_indirect_ln(pdf, "P", obj_bead_page(pdf, a));
- pdf_indirect_ln(pdf, "R", obj_bead_rect(pdf, a));
+ pdf_dict_add_ref(pdf, "T", t);
+ pdf_dict_add_ref(pdf, "V", obj_bead_prev(pdf, a));
+ pdf_dict_add_ref(pdf, "N", obj_bead_next(pdf, a));
+ pdf_dict_add_ref(pdf, "P", obj_bead_page(pdf, a));
+ pdf_dict_add_ref(pdf, "R", obj_bead_rect(pdf, a));
pdf_end_dict(pdf);
+ pdf_end_obj(pdf);
a = obj_bead_next(pdf, a);
} while (a != b);
}
-
@ @c
void scan_thread_id(void)
{
@@ -260,15 +277,16 @@ void print_bead_rectangles(PDF pdf)
int l;
if ((k = get_page_resources_list(pdf, obj_type_bead)) != NULL) {
while (k != NULL) {
- l = pdf_new_obj(pdf, obj_type_others, 0, 1);
- pdf_out(pdf, '[');
+ l = pdf_create_obj(pdf, obj_type_others, 0);
+ pdf_begin_obj(pdf, l, OBJSTM_ALWAYS);
+ pdf_begin_array(pdf);
i = obj_bead_data(pdf, k->info); /* pointer to a whatsit or whatsit-like node */
- pdf_print_rect_spec(pdf, i);
+ pdf_add_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, l); /* rewrite |obj_bead_data| */
+ pdf_end_array(pdf);
pdf_end_obj(pdf);
+ set_obj_bead_rect(pdf, k->info, l); /* rewrite |obj_bead_data| */
k = k->link;
}
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h b/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h
index f0fef66be0f..981764010fd 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h
@@ -1,6 +1,6 @@
/* pdftypes.h
- Copyright 2009-2010 Taco Hoekwater <taco@luatex.org>
+ Copyright 2009-2011 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
@@ -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: pdftypes.h 3949 2010-11-07 00:09:19Z hhenkel $ */
+/* $Id: pdftypes.h 4558 2013-01-19 14:21:59Z oneiros $ */
#ifndef PDFTYPES_H
# define PDFTYPES_H
@@ -28,6 +28,33 @@
# include <zlib.h>
# include "lua/luatex-api.h"
+/* The prefix "PTEX" for the PDF keys is special to pdfTeX;
+ this has been registered with Adobe by Hans Hagen. */
+
+# define pdfkeyprefix "PTEX"
+
+# define lround(a) (long) floor((a) + 0.5)
+
+# define MAX_OBJ_COMPRESS_LEVEL 3 /* maximum/clipping value for \pdfobjcompresslevel */
+# define OBJSTM_UNSET -1 /* initial value */
+# define OBJSTM_ALWAYS 1 /* \pdfobjcompresslevel >= OBJSTM_ALWAYS: put object into object stream */
+# define OBJSTM_NEVER (MAX_OBJ_COMPRESS_LEVEL + 1)
+ /* above maximum/clipping value for \pdfobjcompresslevel */
+
+typedef int internal_font_number; /* |font| in a |char_node| */
+
+typedef enum {
+ NO_ZIP, /* no \.{ZIP} compression */
+ ZIP_WRITING, /* \.{ZIP} compression being used */
+ ZIP_FINISH /* finish \.{ZIP} compression */
+} zip_write_state_e;
+
+typedef enum {
+ PDFOUT_BUF,
+ OBJSTM_BUF,
+ LUASTM_BUF
+} buffer_e;
+
/* This stucture holds everything that is needed for the actual pdf generation.
Because this structure interfaces with C++, it is not wise to use |boolean|
@@ -38,11 +65,6 @@ the types explicitly defined in this header, and stay away from types like
|integer| and |eight_bits| that are used elsewhere in the \LUATEX\ sources.
*/
-typedef struct os_obj_data_ {
- int num;
- int off;
-} os_obj_data;
-
typedef struct {
long m; /* mantissa (significand) */
int e; /* exponent * -1 */
@@ -104,6 +126,7 @@ typedef struct {
pdffloat tj_delta; /* rel. movement in [(..)..]TJ array (glyph raster) */
pdffloat fs; /* font size in PDF units */
pdffloat fs_cur; /* to check if fs.m has changed and Tf needed */
+ pdffloat tm0_cur; /* to check if tm[0] has changed and Tm needed */
pdffloat cm[6]; /* cm array */
pdffloat tm[6]; /* Tm array */
double k1; /* conv. factor from TeX sp to PDF page raster */
@@ -113,6 +136,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_tf; /* flag whether Tf needs to be set */
int need_tm; /* flag whether Tm needs to be set */
} pdfstructure;
@@ -179,9 +203,62 @@ typedef struct pdf_resource_struct_ {
int last_resources; /* halfword to most recently generated Resources object. */
} pdf_resource_struct;
+/**********************************************************************/
+
+typedef struct os_obj_data_ {
+ int num;
+ int off;
+} os_obj_data;
+
+typedef struct strbuf_s_ {
+ unsigned char *data; /* a PDF stream buffer */
+ unsigned char *p; /* pointer to the next character in the PDF stream buffer */
+ size_t size; /* currently allocated size of the PDF stream buffer, grows dynamically */
+ size_t limit; /* maximum allowed PDF stream buffer size */
+} strbuf_s;
+
+typedef struct os_struct_ {
+ os_obj_data *obj; /* array of object stream objects */
+ strbuf_s *buf[3];
+ buffer_e curbuf; /* select into which buffer to output */
+ luaL_Buffer b; /* Lua buffer connected to luastm_buf */
+ unsigned int cur_objstm; /* number of current object stream object */
+ unsigned int idx; /* index of object within object stream [1...PDF_OS_MAX_OBJS - 1] */
+ unsigned int ostm_ctr; /* statistics: counter for object stream objects */
+ unsigned int o_ctr; /* statistics: counter for objects within object streams */
+ int trigger_luastm;
+} os_struct;
+
+/**********************************************************************/
+
+# define packet_max_recursion 100 /* see |packet_cur_s| */
+# define packet_stack_size 100
+
+typedef struct packet_stack_record_ {
+ float c0;
+ float c1;
+ float c2;
+ float c3;
+ scaledpos pos; /* c4, c5 */
+} packet_stack_record;
+
+typedef struct vf_struct_ {
+ packet_stack_record *packet_stack; /* for "push" and "pop" */
+ int packet_stack_level;
+ int packet_stack_minlevel; /* to check stack underflow */
+ internal_font_number lf; /* local font number, resolved */
+ int fs_f; /* local font size */
+ int packet_cur_s; /* do_vf_packet() nesting level */
+ posstructure *refpos;
+ int vflua; /* flag, whether vf.*() functions are allowed */
+} vf_struct;
+
+/**********************************************************************/
+
typedef struct pdf_output_file_ {
FILE *file; /* the PDF output file handle */
char *file_name; /* the PDF output file name */
+ char *job_name;
output_mode o_mode; /* output mode (DVI/PDF/...) */
output_state o_state;
/* generation parameters */
@@ -200,24 +277,11 @@ typedef struct pdf_output_file_ {
int objcompresslevel; /* fixed level for activating PDF object streams */
char *job_id_string; /* the full job string */
- /* output file buffering */
- unsigned char *op_buf; /* the PDF output buffer */
- int op_buf_size; /* output buffer size (static) */
- int op_ptr; /* store for PDF buffer |pdf_ptr| while inside object streams */
- unsigned char *os_buf; /* the PDF object stream buffer */
- int os_buf_size; /* current size of the PDF object stream buffer, grows dynamically */
- int os_ptr; /* store for object stream |pdf_ptr| while outside object streams */
-
- os_obj_data *os_obj; /* array of object stream objects */
- int os_idx; /* pointer into |pdf_os_objnum| and |pdf_os_objoff| */
- int os_cntr; /* counter for object stream objects */
- int os_mode; /* true if producing object stream */
int os_enable; /* true if object streams are globally enabled */
- int os_cur_objnum; /* number of current object stream object */
+ os_struct *os; /* object stream structure pointer */
+
+ strbuf_s *buf; /* pointer to the current stream buffer (PDF stream, ObjStm, or Lua) */
- unsigned char *buf; /* pointer to the PDF output buffer or PDF object stream buffer */
- int buf_size; /* end of PDF output buffer or PDF object stream buffer */
- int ptr; /* pointer to the first unused byte in the PDF buffer or object stream buffer */
off_t save_offset; /* to save |pdf_offset| */
off_t gone; /* number of bytes that were flushed to output */
@@ -226,14 +290,13 @@ typedef struct pdf_output_file_ {
time_t start_time; /* when this job started */
char *start_time_str; /* minimum size for time_str is 24: "D:YYYYmmddHHMMSS+HH'MM'" */
- /* define fb_ptr, fb_array & fb_limit */
- char *fb_array;
- char *fb_ptr;
- size_t fb_limit;
+ strbuf_s *fb; /* pointer to auxiliary buffer for font stuff */
char *zipbuf;
z_stream *c_stream; /* compression stream pointer */
- int zip_write_state; /* which state of compression we are in */
+ zip_write_state_e zip_write_state; /* which state of compression we are in */
+ int stream_deflate; /* true, if stream dict has /Filter/FlateDecode */
+ int stream_writing; /* true while writing stream */
int pk_scale_factor; /* this is just a preprocessed value that depends on
|pk_resolution| and |decimal_digits| */
@@ -273,6 +336,8 @@ typedef struct pdf_output_file_ {
pdf_resource_struct *page_resources;
+ scaledpos page_size; /* width and height of page being shipped */
+
/* the variables from pdfdest */
int dest_names_size;
int dest_names_ptr;
@@ -293,6 +358,9 @@ typedef struct pdf_output_file_ {
int f_cur; /* TeX font number */
int pdflua_ref;
+ int cave; /* stay away from previous PDF object */
+
+ vf_struct *vfstruct;
} 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 724755f4ebc..b8878d43741 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w
@@ -1,26 +1,26 @@
% pdfxform.w
-
-% Copyright 2009-2010 Taco Hoekwater <taco@@luatex.org>
-
+%
+% Copyright 2009-2011 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/>.
+% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
static const char _svn_version[] =
- "$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 $";
+ "$Id: pdfxform.w 4442 2012-05-25 22:40:34Z hhenkel $"
+ "$URL: http://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdfxform.w $";
#include "ptexlib.h"
@@ -59,11 +59,11 @@ void pdf_place_form(PDF pdf, halfword p)
(void) calc_pdfpos(q, pdf->posstruct->pos);
cm[4] = q->cm[4];
cm[5] = q->cm[5];
- pdf_printf(pdf, "q\n");
+ pdf_puts(pdf, "q\n");
pdf_print_cm(pdf, cm);
pdf_printf(pdf, "/Fm%d", (int) obj_info(pdf, objnum));
pdf_print_resname_prefix(pdf);
- pdf_printf(pdf, " Do\nQ\n");
+ pdf_puts(pdf, " Do\nQ\n");
addto_page_resources(pdf, obj_type_xform, objnum);
}