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.h25
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfaction.w100
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfannot.h7
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfannot.w18
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.h7
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w137
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfdest.h27
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfdest.w146
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdffont.h3
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdffont.w145
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfgen.h104
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfgen.w892
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfglyph.h4
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w111
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfimage.h3
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfimage.w6
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdflink.h10
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdflink.w61
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdflistout.h17
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdflistout.w1002
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfliteral.h4
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w72
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.h29
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.w113
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfobj.h26
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfobj.w37
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfoutline.h3
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w68
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfpage.h10
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfpage.w172
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.h6
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.w96
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfrule.h5
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfrule.w15
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.h12
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w16
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.h5
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w44
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfshipout.h7
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w284
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdftables.h103
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdftables.w221
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfthread.h37
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfthread.w52
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdftypes.h113
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfxform.h51
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfxform.w4
47 files changed, 1888 insertions, 2542 deletions
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfaction.h b/Build/source/texk/web2c/luatexdir/pdf/pdfaction.h
index ed9ba48a2ce..3d7751351df 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfaction.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfaction.h
@@ -15,25 +15,30 @@
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/>.
+*/
#ifndef PDFACTION_H
# define PDFACTION_H
-/* increase count of references to this action. this is used to speed up
- copy_node() */
+/*
+ Increase count of references to this action. this is used to speed up
+ copy_node().
+*/
# define add_action_ref(a) pdf_action_refcount((a))++
-/* decrease count of references to this action; free it if there is no reference
- to this action */
+/*
+ Decrease count of references to this action; free it if there is no reference
+ to this action.
+*/
-# define delete_action_ref(a) { \
+# define delete_action_ref(a) { \
if (pdf_action_refcount(a) == null) { \
- flush_node(a); \
- } else { \
- pdf_action_refcount(a)--; \
- } \
+ flush_node(a); \
+ } else { \
+ pdf_action_refcount(a)--; \
+ } \
}
# define set_pdf_action_type(A,B) pdf_action_type(A)=B
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfaction.w b/Build/source/texk/web2c/luatexdir/pdf/pdfaction.w
index 65c1afcc352..bb0d6e06d50 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfaction.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfaction.w
@@ -19,16 +19,14 @@
@ @c
-
#include "ptexlib.h"
@ read an action specification
-@c
-halfword scan_action(PDF pdf)
+
+@c halfword scan_action(PDF pdf)
{
- int p;
+ int p = new_node(whatsit_node, pdf_action_node);
(void) pdf;
- p = new_node(whatsit_node, pdf_action_node);
if (scan_keyword("user"))
set_pdf_action_type(p, pdf_action_user);
else if (scan_keyword("goto"))
@@ -38,12 +36,12 @@ halfword scan_action(PDF pdf)
else
normal_error("pdf backend", "action type missing");
if (pdf_action_type(p) == pdf_action_user) {
- scan_pdf_ext_toks();
+ scan_toks(false, true);
set_pdf_action_tokens(p, def_ref);
return p;
}
if (scan_keyword("file")) {
- scan_pdf_ext_toks();
+ scan_toks(false, true);
set_pdf_action_file(p, def_ref);
}
if (scan_keyword("page")) {
@@ -55,10 +53,10 @@ halfword scan_action(PDF pdf)
normal_error("pdf backend", "page number must be positive");
set_pdf_action_id(p, cur_val);
set_pdf_action_named_id(p, 0);
- scan_pdf_ext_toks();
+ scan_toks(false, true);
set_pdf_action_tokens(p, def_ref);
} else if (scan_keyword("name")) {
- scan_pdf_ext_toks();
+ scan_toks(false, true);
set_pdf_action_named_id(p, 1);
set_pdf_action_id(p, def_ref);
} else if (scan_keyword("num")) {
@@ -97,8 +95,8 @@ halfword scan_action(PDF pdf)
}
@ write an action specification
-@c
-void write_action(PDF pdf, halfword p)
+
+@c void write_action(PDF pdf, halfword p)
{
char *s;
int d = 0;
@@ -124,44 +122,30 @@ void write_action(PDF pdf, halfword p)
}
}
switch (pdf_action_type(p)) {
- case pdf_action_page:
- pdf_dict_add_name(pdf, "S", "GoTo");
- if (pdf_action_file(p) == null) {
- 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_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_end_array(pdf);
- xfree(tokstr);
- }
- break;
- case pdf_action_goto:
- if (pdf_action_file(p) == null) {
+ case pdf_action_page:
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_dict_add_string(pdf, "D", tokstr);
- xfree(tokstr);
- } else if (pdf_action_file(p) == null) {
- pdf_dict_add_ref(pdf, "D", d);
- } else {
- normal_error("pdf backend","'goto' option cannot be used with both 'file' and 'num'");
- }
- break;
- case pdf_action_thread:
- pdf_dict_add_name(pdf, "S", "Thread");
- if (pdf_action_file(p) == null) {
- d = pdf_get_obj(pdf, obj_type_thread, pdf_action_id(p), pdf_action_named_id(p));
+ if (pdf_action_file(p) == null) {
+ 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_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_end_array(pdf);
+ xfree(tokstr);
+ }
+ break;
+ case pdf_action_goto:
+ if (pdf_action_file(p) == null) {
+ 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_dict_add_string(pdf, "D", tokstr);
@@ -169,10 +153,24 @@ void write_action(PDF pdf, halfword p)
} else if (pdf_action_file(p) == null) {
pdf_dict_add_ref(pdf, "D", d);
} else {
- pdf_dict_add_int(pdf, "D", pdf_action_id(p));
+ normal_error("pdf backend","'goto' option cannot be used with both 'file' and 'num'");
}
- }
- break;
+ break;
+ case pdf_action_thread:
+ pdf_dict_add_name(pdf, "S", "Thread");
+ if (pdf_action_file(p) == null) {
+ 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_dict_add_string(pdf, "D", tokstr);
+ xfree(tokstr);
+ } else if (pdf_action_file(p) == null) {
+ pdf_dict_add_ref(pdf, "D", d);
+ } else {
+ pdf_dict_add_int(pdf, "D", pdf_action_id(p));
+ }
+ }
+ break;
}
pdf_end_dict(pdf);
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfannot.h b/Build/source/texk/web2c/luatexdir/pdf/pdfannot.h
index 0b9ce5b9c12..2c862975db0 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfannot.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfannot.h
@@ -15,7 +15,8 @@
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/>.
+*/
#ifndef PDFANNOT_H
@@ -23,10 +24,10 @@
/* data structure of annotations; words 1..4 represent the coordinates of the annotation */
-# define obj_annot_ptr obj_aux /* pointer to corresponding whatsit node */
+# define obj_annot_ptr obj_aux /* pointer to corresponding whatsit node */
# define set_pdf_annot_objnum(A,B) pdf_annot_objnum(A)=B
-# define set_pdf_annot_data(A,B) pdf_annot_data(A)=B
+# define set_pdf_annot_data(A,B) pdf_annot_data(A)=B
extern void do_annot(PDF pdf, halfword p, halfword parent_box, scaledpos cur);
extern void new_annot_whatsit(small_number w);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w b/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w
index 67bcc69a40c..6bbfec226e7 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w
@@ -19,18 +19,17 @@
@ @c
-
#include "ptexlib.h"
@ @c
-#define tail cur_list.tail_field
+#define tail cur_list.tail_field
void do_annot(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
{
scaled_whd alt_rule;
int k;
if (global_shipping_mode == SHIPPING_FORM)
- normal_error("pdf backend", "annotations cannot be inside an XForm");
+ normal_error("pdf backend", "annotations cannot be inside an xform");
if (doing_leaders)
return;
if (is_obj_scheduled(pdf, pdf_annot_objnum(p))) {
@@ -47,8 +46,8 @@ void do_annot(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
}
@ create a new whatsit node for annotation
-@c
-void new_annot_whatsit(small_number w)
+
+@c void new_annot_whatsit(small_number w)
{
scaled_whd alt_rule;
new_whatsit(w);
@@ -58,7 +57,7 @@ void new_annot_whatsit(small_number w)
set_depth(tail, alt_rule.dp);
if ((w == pdf_thread_node) || (w == pdf_start_thread_node)) {
if (scan_keyword("attr")) {
- scan_pdf_ext_toks();
+ scan_toks(false, true);
set_pdf_thread_attr(tail, def_ref);
} else {
set_pdf_thread_attr(tail, null);
@@ -66,8 +65,9 @@ void new_annot_whatsit(small_number w)
}
}
-@ @c
-void scan_annot(PDF pdf)
+@ scanning at the \TeX\ end
+
+@c void scan_annot(PDF pdf)
{
int k;
if (scan_keyword("reserveobjnum")) {
@@ -89,7 +89,7 @@ void scan_annot(PDF pdf)
new_annot_whatsit(pdf_annot_node);
obj_annot_ptr(pdf, k) = tail;
set_pdf_annot_objnum(tail, k);
- scan_pdf_ext_toks();
+ scan_toks(false, true);
set_pdf_annot_data(tail, def_ref);
}
pdf_last_annot = k;
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.h b/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.h
index cab0a4cb0ae..dfd955c5e2c 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.h
@@ -15,15 +15,16 @@
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/>.
+*/
#ifndef PDFCOLORSTACK_H
# define PDFCOLORSTACK_H
# define set_pdf_colorstack_stack(A,B) pdf_colorstack_stack(A)=B
-# define set_pdf_colorstack_cmd(A,B) pdf_colorstack_cmd(A)=B
-# define set_pdf_colorstack_data(A,B) pdf_colorstack_data(A)=B
+# define set_pdf_colorstack_cmd(A,B) pdf_colorstack_cmd(A)=B
+# define set_pdf_colorstack_data(A,B) pdf_colorstack_data(A)=B
# define STACK_INCREMENT 8
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w b/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w
index eb48ab89ca6..bcc7145c6ce 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w
@@ -19,36 +19,36 @@
@ @c
-
#include "ptexlib.h"
@* Color Stack and Matrix Transformation Support.
-
@ In the following array and especially stack data structures are used.
They have the following properties:
- \item{-} They automatically grow dynamically.
- \item{-} The size never decreases.
- \item{-} The variable with name ending in "size" contains the number how many
- entries the data structure can hold.
- \item{-} The variable with name ending in "used" contains the number of
- actually used entries.
- \item{-} Memory of strings in stack entries must be allocated and
- freed if the stack is cleared.
-
+\item{-} They automatically grow dynamically.
+\item{-} The size never decreases.
+\item{-} The variable with name ending in "size" contains the number how many
+ entries the data structure can hold.
+\item{-} The variable with name ending in "used" contains the number of
+ actually used entries.
+\item{-} Memory of strings in stack entries must be allocated and
+ freed if the stack is cleared.
@ Color Stack
@c
+
#define MAX_COLORSTACKS 32768
-/* The colorstack number is stored in two bytes (info field of the node) */
-/* Condition (newcolorstack): |MAX_COLORSTACKS mod STACK_INCREMENT = 0| */
+
+/*
+ The colorstack number is stored in two bytes (info field of the node);
+ condition (newcolorstack): |MAX_COLORSTACKS mod STACK_INCREMENT = 0|
+*/
#define COLOR_DEFAULT "0 g 0 G"
-/* |literal_mode|s, see pdftex.web */
-#define SET_ORIGIN 0
-#define DIRECT_PAGE 1
+#define SET_ORIGIN 0
+#define DIRECT_PAGE 1
#define DIRECT_ALWAYS 2
typedef struct {
@@ -69,9 +69,9 @@ static colstack_type *colstacks = NULL;
static int colstacks_size = 0;
static int colstacks_used = 0;
-@ Initialization is done, if the color stacks are used,
- |init_colorstacks()| is defined as macro to avoid unnecessary
- procedure calls.
+@ Initialization is done, if the color stacks are used, |init_colorstacks()| is defined
+as macro to avoid unnecessary procedure calls.
+
@c
#define init_colorstacks() if (colstacks_size == 0) colstacks_first_init();
@@ -100,27 +100,26 @@ int colorstackused(void)
return colstacks_used;
}
-@ |newcolorstack()|
- A new color stack is setup with the given parameters.
- The stack number is returned or -1 in case of error (no room).
+@ A new color stack is setup with the given parameters. The stack number is returned
+or -1 in case of error (no room).
+
@c
int newcolorstack(const char *str, int literal_mode, boolean page_start)
{
colstack_type *colstack;
int colstack_num;
-
init_colorstacks();
-
/* make room */
if (colstacks_used == MAX_COLORSTACKS) {
return -1;
}
if (colstacks_used == colstacks_size) {
colstacks_size += STACK_INCREMENT;
- /* If |(MAX_COLORSTACKS mod STACK_INCREMENT = 0)| then we don't
- need to check the case that size overruns |MAX_COLORSTACKS|. */
- colstacks =
- xreallocarray(colstacks, colstack_type, (unsigned) colstacks_size);
+ /*
+ If |(MAX_COLORSTACKS mod STACK_INCREMENT = 0)| then we don't
+ need to check the case that size overruns |MAX_COLORSTACKS|.
+ */
+ colstacks = xreallocarray(colstacks, colstack_type, (unsigned) colstacks_size);
}
/* claim new color stack */
colstack_num = colstacks_used++;
@@ -149,8 +148,8 @@ int newcolorstack(const char *str, int literal_mode, boolean page_start)
#define get_colstack(n) (&colstacks[n])
@ Puts a string on top of the string pool and updates |pool_ptr|.
-@c
-static void put_cstring_on_str_pool(char *str)
+
+@c static void put_cstring_on_str_pool(char *str)
{
int save_selector = selector;
selector = new_string;
@@ -197,8 +196,7 @@ 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;
- 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);
@@ -211,8 +209,7 @@ static int colorstackpush(int colstack_no, str_number s)
} else {
if (colstack->form_used == colstack->form_size) {
colstack->form_size += STACK_INCREMENT;
- 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);
@@ -230,11 +227,9 @@ static int colorstackpush(int colstack_no, str_number s)
int colorstackpop(int colstack_no)
{
colstack_type *colstack = get_colstack(colstack_no);
-
if (global_shipping_mode == SHIPPING_PAGE) {
if (colstack->page_used == 0) {
- luatex_warn("pop empty color page stack %u",
- (unsigned int) colstack_no);
+ formatted_warning("pdf backend","pop empty color page stack %u",(unsigned int) colstack_no);
return colstack->literal_mode;
}
xfree(colstack->page_current);
@@ -242,8 +237,7 @@ int colorstackpop(int colstack_no)
put_cstring_on_str_pool(colstack->page_current);
} else {
if (colstack->form_used == 0) {
- luatex_warn("pop empty color form stack %u",
- (unsigned int) colstack_no);
+ formatted_warning("pdf backend","pop empty color form stack %u",(unsigned int) colstack_no);
return colstack->literal_mode;
}
xfree(colstack->form_current);
@@ -258,7 +252,6 @@ void colorstackpagestart(void)
{
int i, j;
colstack_type *colstack;
-
if (global_shipping_mode == SHIPPING_PAGE) {
/* see procedure |pdf_out_colorstack_startpage| */
return;
@@ -283,7 +276,6 @@ void colorstackpagestart(void)
int colorstackskippagestart(int colstack_no)
{
colstack_type *colstack = get_colstack(colstack_no);
-
if (!colstack->page_start) {
return 1;
}
@@ -302,12 +294,9 @@ void pdf_out_colorstack(PDF pdf, halfword p)
{
int old_setting;
str_number s;
- int cmd;
- int stack_no;
- int literal_mode;
- cmd = pdf_colorstack_cmd(p);
- stack_no = pdf_colorstack_stack(p);
- literal_mode = 0;
+ int cmd = pdf_colorstack_cmd(p);
+ int stack_no = pdf_colorstack_stack(p);
+ int literal_mode = 0;
if (stack_no >= colorstackused()) {
tprint_nl("");
tprint("Color stack ");
@@ -317,30 +306,30 @@ void pdf_out_colorstack(PDF pdf, halfword p)
return;
}
switch (cmd) {
- case colorstack_set:
- case colorstack_push:
- old_setting = selector;
- selector = new_string;
- show_token_list(token_link(pdf_colorstack_data(p)), null, -1);
- selector = old_setting;
- s = make_string();
- if (cmd == colorstack_set)
- literal_mode = colorstackset(stack_no, s);
- else
- literal_mode = colorstackpush(stack_no, s);
- if (str_length(s) > 0)
- pdf_literal(pdf, s, literal_mode, false);
- flush_str(s);
- return;
- break;
- case colorstack_pop:
- literal_mode = colorstackpop(stack_no);
- break;
- case colorstack_current:
- literal_mode = colorstackcurrent(stack_no);
- break;
- default:
- break;
+ case colorstack_set:
+ case colorstack_push:
+ old_setting = selector;
+ selector = new_string;
+ show_token_list(token_link(pdf_colorstack_data(p)), null, -1);
+ selector = old_setting;
+ s = make_string();
+ if (cmd == colorstack_set)
+ literal_mode = colorstackset(stack_no, s);
+ else
+ literal_mode = colorstackpush(stack_no, s);
+ if (str_length(s) > 0)
+ pdf_literal(pdf, s, literal_mode, false);
+ flush_str(s);
+ return;
+ break;
+ case colorstack_pop:
+ literal_mode = colorstackpop(stack_no);
+ break;
+ case colorstack_current:
+ literal_mode = colorstackcurrent(stack_no);
+ break;
+ default:
+ break;
}
if (cur_length > 0) {
s = make_string();
@@ -352,13 +341,11 @@ void pdf_out_colorstack(PDF pdf, halfword p)
@ @c
void pdf_out_colorstack_startpage(PDF pdf)
{
- int i;
- int max;
int start_status;
int literal_mode;
str_number s;
- i = 0;
- max = colorstackused();
+ int i = 0;
+ int max = colorstackused();
while (i < max) {
start_status = colorstackskippagestart(i);
if (start_status == 0) {
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfdest.h b/Build/source/texk/web2c/luatexdir/pdf/pdfdest.h
index 4c2f1911931..576baea0434 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfdest.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfdest.h
@@ -15,7 +15,8 @@
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/>.
+*/
#ifndef PDFDEST_H
@@ -24,17 +25,18 @@
/* types of destinations */
typedef enum {
- pdf_dest_xyz = 0,
- pdf_dest_fit = 1,
- pdf_dest_fith = 2,
- pdf_dest_fitv = 3,
- pdf_dest_fitb = 4,
+ pdf_dest_xyz = 0,
+ pdf_dest_fit = 1,
+ pdf_dest_fith = 2,
+ pdf_dest_fitv = 3,
+ pdf_dest_fitb = 4,
pdf_dest_fitbh = 5,
pdf_dest_fitbv = 6,
- pdf_dest_fitr = 7
+ pdf_dest_fitr = 7
} pdf_destination_types;
/* max number of kids for balanced trees */
+
# define name_tree_kids_max 32 /* max number of kids of node of name tree for name destinations */
/* data structure of destinations */
@@ -42,18 +44,16 @@ typedef enum {
# define obj_dest_ptr obj_aux /* pointer to |pdf_dest_node| */
# define set_obj_dest_ptr(pdf,A,B) obj_dest_ptr(pdf,A)=B
-# define set_pdf_dest_id(A,B) pdf_dest_id(A)=B
+# define set_pdf_dest_id(A,B) pdf_dest_id(A)=B
# define set_pdf_dest_named_id(A,B) pdf_dest_named_id(A)=B
-# define set_pdf_dest_type(A,B) pdf_dest_type(A)=B
+# define set_pdf_dest_type(A,B) pdf_dest_type(A)=B
# define set_pdf_dest_xyz_zoom(A,B) pdf_dest_xyz_zoom(A)=B
-# define inf_dest_names_size 1000 /* min size of the destination names table for PDF output */
-# define sup_dest_names_size 131072 /* max size of the destination names table for PDF output */
+# define inf_dest_names_size 1000 /* min size of the destination names table for PDF output */
+# define sup_dest_names_size 131072 /* max size of the destination names table for PDF output */
extern void append_dest_name(PDF, char *, int);
extern void do_dest(PDF pdf, halfword p, halfword parent_box, scaledpos cur);
-extern void warn_dest_dup(int id, small_number byname, const char *s1,
- const char *s2);
extern void write_out_pdf_mark_destinations(PDF);
extern void scan_pdfdest(PDF);
@@ -61,5 +61,4 @@ extern void init_dest_names(PDF);
extern void sort_dest_names(PDF);
extern int output_name_tree(PDF);
-
#endif
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfdest.w b/Build/source/texk/web2c/luatexdir/pdf/pdfdest.w
index 7aefc45288f..74e8e4b1f13 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfdest.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfdest.w
@@ -19,18 +19,16 @@
@ @c
-
#include "ptexlib.h"
-@ Here we implement subroutines for work with objects and related things.
-Some of them are used in former parts too, so we need to declare them
-forward.
+@ Here we implement subroutines for work with objects and related things. Some of
+them are used in former parts too, so we need to declare them forward.
@c
void init_dest_names(PDF pdf)
{
pdf->dest_names_size = inf_dest_names_size;
- pdf->dest_names = xmallocarray(dest_name_entry, inf_dest_names_size); /* will grow dynamically */
+ pdf->dest_names = xmallocarray(dest_name_entry, inf_dest_names_size); /* will grow dynamically */
}
@ @c
@@ -38,45 +36,35 @@ void append_dest_name(PDF pdf, char *s, int n)
{
int a;
if (pdf->dest_names_ptr == sup_dest_names_size)
- overflow("number of destination names (dest_names_size)",
- (unsigned) pdf->dest_names_size);
+ overflow("number of destination names (dest_names_size)",(unsigned) pdf->dest_names_size);
if (pdf->dest_names_ptr == pdf->dest_names_size) {
a = pdf->dest_names_size / 5;
if (pdf->dest_names_size < sup_dest_names_size - a)
pdf->dest_names_size = pdf->dest_names_size + a;
else
pdf->dest_names_size = sup_dest_names_size;
- pdf->dest_names =
- xreallocarray(pdf->dest_names, dest_name_entry,
- (unsigned) pdf->dest_names_size);
+ pdf->dest_names = xreallocarray(pdf->dest_names, dest_name_entry, (unsigned) pdf->dest_names_size);
}
pdf->dest_names[pdf->dest_names_ptr].objname = xstrdup(s);
pdf->dest_names[pdf->dest_names_ptr].objnum = n;
pdf->dest_names_ptr++;
}
-
@ When a destination is created we need to check whether another destination
with the same identifier already exists and give a warning if needed.
@c
-void warn_dest_dup(int id, small_number byname, const char *s1, const char *s2)
+static void warn_dest_dup(int id, small_number byname)
{
- normal_warning(s1, "destination with the same identifier (", false, false);
if (byname > 0) {
- tprint("name");
- print_mark(id);
+ char *ss = tokenlist_to_cstring(id, true, NULL);
+ formatted_warning("pdf backend", "ignoring duplicate destination with the name '%s'",ss);
} else {
- tprint("num");
- print_int(id);
+ formatted_warning("pdf backend", "ignoring duplicate destination with the num '%d'",id);
}
- tprint(") ");
- tprint(s2);
- print_ln();
- show_context();
+ /* no longer the annoying context */
}
-
@ @c
void do_dest(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
{
@@ -84,13 +72,12 @@ void do_dest(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
scaled_whd alt_rule;
int k;
if (global_shipping_mode == SHIPPING_FORM)
- normal_error("pdf backend", "destinations cannot be inside an XForm");
+ normal_error("pdf backend", "destinations cannot be inside an xform");
if (doing_leaders)
return;
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),
- "pdf backend", "has been already used, duplicate ignored");
+ warn_dest_dup(pdf_dest_id(p), (small_number) pdf_dest_named_id(p));
return;
}
obj_dest_ptr(pdf, k) = p;
@@ -149,50 +136,50 @@ void write_out_pdf_mark_destinations(PDF pdf)
pdf_begin_array(pdf);
pdf_add_ref(pdf, pdf->last_page);
switch (pdf_dest_type(i)) {
- case pdf_dest_xyz:
- 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_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_add_name(pdf, "Fit");
- break;
- case pdf_dest_fith:
- pdf_add_name(pdf, "FitH");
- pdf_add_mag_bp(pdf, pdf_ann_top(i));
- break;
- case pdf_dest_fitv:
- pdf_add_name(pdf, "FitV");
- pdf_add_mag_bp(pdf, pdf_ann_left(i));
- break;
- case pdf_dest_fitb:
- pdf_add_name(pdf, "FitB");
- break;
- case pdf_dest_fitbh:
- pdf_add_name(pdf, "FitBH");
- pdf_add_mag_bp(pdf, pdf_ann_top(i));
- break;
- case pdf_dest_fitbv:
- pdf_add_name(pdf, "FitBV");
- pdf_add_mag_bp(pdf, pdf_ann_left(i));
- break;
- case pdf_dest_fitr:
- pdf_add_name(pdf, "FitR");
- pdf_add_rect_spec(pdf, i);
- break;
- default:
- normal_error("pdf backend", "unknown dest type");
- break;
+ case pdf_dest_xyz:
+ pdf_add_name(pdf, "XYZ");
+ pdf_add_bp(pdf, pdf_ann_left(i));
+ pdf_add_bp(pdf, pdf_ann_top(i));
+ if (pdf_dest_xyz_zoom(i) == 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_add_name(pdf, "Fit");
+ break;
+ case pdf_dest_fith:
+ pdf_add_name(pdf, "FitH");
+ pdf_add_bp(pdf, pdf_ann_top(i));
+ break;
+ case pdf_dest_fitv:
+ pdf_add_name(pdf, "FitV");
+ pdf_add_bp(pdf, pdf_ann_left(i));
+ break;
+ case pdf_dest_fitb:
+ pdf_add_name(pdf, "FitB");
+ break;
+ case pdf_dest_fitbh:
+ pdf_add_name(pdf, "FitBH");
+ pdf_add_bp(pdf, pdf_ann_top(i));
+ break;
+ case pdf_dest_fitbv:
+ pdf_add_name(pdf, "FitBV");
+ pdf_add_bp(pdf, pdf_ann_left(i));
+ break;
+ case pdf_dest_fitr:
+ pdf_add_name(pdf, "FitR");
+ pdf_add_rect_spec(pdf, i);
+ break;
+ default:
+ normal_error("pdf backend", "unknown dest type");
+ break;
}
pdf_end_array(pdf);
if (pdf_dest_named_id(i) > 0)
@@ -222,7 +209,7 @@ void scan_pdfdest(PDF pdf)
set_pdf_dest_id(cur_list.tail_field, cur_val);
set_pdf_dest_named_id(cur_list.tail_field, 0);
} else if (scan_keyword("name")) {
- scan_pdf_ext_toks();
+ scan_toks(false, true);
set_pdf_dest_id(cur_list.tail_field, def_ref);
set_pdf_dest_named_id(cur_list.tail_field, 1);
} else {
@@ -271,13 +258,10 @@ void scan_pdfdest(PDF pdf)
k = find_obj(pdf, obj_type_dest, i, true);
flush_str(i);
} else {
- k = find_obj(pdf, obj_type_dest, pdf_dest_id(cur_list.tail_field),
- false);
+ k = find_obj(pdf, obj_type_dest, pdf_dest_id(cur_list.tail_field), false);
}
if ((k != 0) && (obj_dest_ptr(pdf, k) != null)) {
- warn_dest_dup(pdf_dest_id(cur_list.tail_field),
- (small_number) pdf_dest_named_id(cur_list.tail_field),
- "pdf backend", "has been already used, duplicate ignored");
+ warn_dest_dup(pdf_dest_id(cur_list.tail_field),(small_number) pdf_dest_named_id(cur_list.tail_field));
flush_node_list(cur_list.tail_field);
cur_list.tail_field = q;
vlink(q) = null;
@@ -296,8 +280,7 @@ static int dest_cmp(const void *a, const void *b)
@ @c
void sort_dest_names(PDF pdf)
{
- qsort(pdf->dest_names, (size_t) pdf->dest_names_ptr,
- sizeof(dest_name_entry), dest_cmp);
+ qsort(pdf->dest_names, (size_t) pdf->dest_names_ptr, sizeof(dest_name_entry), dest_cmp);
}
@ Output the name tree. The tree nature of the destination list forces the
@@ -309,18 +292,18 @@ pointers.
int output_name_tree(PDF pdf)
{
boolean is_names = true; /* flag for name tree output: is it Names or Kids? */
- int b = 0, j, l;
int k = 0; /* index of current child of |l|; if |k < pdf_dest_names_ptr|
then this is pointer to |dest_names| array;
otherwise it is the pointer to |obj_tab| (object number) */
- int m;
+ int b = 0;
+ int m, j, l;
int dests = 0;
- int names_head = 0, names_tail = 0;
+ int names_head = 0;
+ int names_tail = 0;
if (pdf->dest_names_ptr == 0) {
goto DONE;
}
sort_dest_names(pdf);
-
while (true) {
do {
l = pdf_create_obj(pdf, obj_type_others, 0); /* create a new node */
@@ -385,7 +368,6 @@ int output_name_tree(PDF pdf)
goto DONE;
}
}
-
DONE:
if ((dests != 0) || (pdf_names_toks != null)) {
m = pdf_create_obj(pdf, obj_type_others, 0);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdffont.h b/Build/source/texk/web2c/luatexdir/pdf/pdffont.h
index 78726a0aa9e..47f987dd685 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdffont.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdffont.h
@@ -15,7 +15,8 @@
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/>.
+*/
#ifndef PDFFONT_H
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdffont.w b/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
index 4a7319db8a3..b3f1605154c 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
@@ -21,7 +21,6 @@
@ @c
-
#include "ptexlib.h"
@ As \pdfTeX{} should also act as a back-end driver, it needs to support virtual
@@ -37,38 +36,38 @@ The |has_packet()| C macro checks for this condition.
@c
scaled_whd output_one_char(PDF pdf, halfword p)
{
- scaled_whd ci; /* the real width, height and depth of the character */
internal_font_number f = font(p);
int c = character(p);
int ex_glyph = ex_glyph(p)/1000;
- ci = get_charinfo_whd(f, c);
+ scaled_whd ci = get_charinfo_whd(f, c); /* the real width, height and depth of the character */
if (!(char_exists(f,c))) {
char_warning(f,c);
return ci;
}
- //ci.wd = round_xn_over_d(ci.wd, 1000 + ex_glyph, 1000);
ci.wd = ext_xn_over_d(ci.wd, 1000000 + ex_glyph(p), 1000000);
switch (pdf->posstruct->dir) {
- case dir_TLT:
- break;
- case dir_TRT:
- pos_left(ci.wd);
- break;
- case dir_LTL:
- pos_down(ci.ht);
- pos_left(ci.wd);
- break;
- case dir_RTT:
- pos_down(ci.ht);
- pos_left(ci.wd / 2);
- break;
- default:
- assert(0);
+ case dir_TLT:
+ break;
+ case dir_TRT:
+ pos_left(ci.wd);
+ break;
+ case dir_LTL:
+ pos_down(ci.ht);
+ pos_left(ci.wd);
+ break;
+ case dir_RTT:
+ pos_down(ci.ht);
+ pos_left(ci.wd / 2);
+ break;
+ default:
+ formatted_warning("pdf backend","ignoring bad dir %i when outputting a character",pdf->posstruct->dir);
}
if (has_packet(f, c)) {
do_vf_packet(pdf, f, c, ex_glyph);
- } else
- backend_out[glyph_node] (pdf, f, c, ex_glyph); /* |pdf_place_glyph(pdf, f, c, ex_glyph);| */
+ } else {
+ /* |pdf_place_glyph(pdf, f, c, ex_glyph);| */
+ backend_out[glyph_node] (pdf, f, c, ex_glyph);
+ }
return ci;
}
@@ -77,72 +76,59 @@ scaled_whd output_one_char(PDF pdf, halfword p)
static void pdf_use_font(internal_font_number f, int fontnum)
{
set_font_used(f, true);
- assert((fontnum > 0) || ((fontnum < 0) && (pdf_font_num(-fontnum) > 0)));
- set_pdf_font_num(f, fontnum);
+ if ((fontnum > 0) || ((fontnum < 0) && (pdf_font_num(-fontnum) > 0))) {
+ set_pdf_font_num(f, fontnum);
+ } else {
+ normal_error("pdf backend","bad font id");
+ }
}
-@ To set PDF font we need to find out fonts with the same name, because \TeX\
-can load the same font several times for various sizes. For such fonts we
-define only one font resource. The array |pdf_font_num| holds the object
-number of font resource. A negative value of an entry of |pdf_font_num|
-indicates that the corresponding font shares the font resource with the font
+@ To set PDF font we need to find out fonts with the same name, because \TeX\ can
+load the same font several times for various sizes. For such fonts we define only
+one font resource. The array |pdf_font_num| holds the object number of font
+resource. A negative value of an entry of |pdf_font_num| indicates that the
+corresponding font shares the font resource with the font
@c
#define same(n,f,k) (n(f) != NULL && n(k) != NULL && strcmp(n(f), n(k)) == 0)
+/*
+ For some lua-loaded (for instance AFM) fonts, it is normal to have
+ a zero cidregistry, and such fonts do not have a fontmap entry yet
+ at this point, so the test should use the other branch
+*/
+
static boolean font_shareable(internal_font_number f, internal_font_number k)
{
- int ret = 0;
- /* For some lua-loaded (for instance AFM) fonts, it is normal to have
- a zero cidregistry, and such fonts do not have a fontmap entry yet
- at this point, so the test should use the other branch */
- if (font_cidregistry(f) == NULL && font_cidregistry(k) == NULL &&
- font_encodingbytes(f) != 2 && font_encodingbytes(k) != 2) {
- if (font_map(k) != NULL &&
- font_map(f) != NULL && (same(font_name, k, f))) {
- ret = 1;
+ if (font_cidregistry(f) == NULL && font_cidregistry(k) == NULL && font_encodingbytes(f) != 2 && font_encodingbytes(k) != 2) {
+ if (font_map(k) != NULL && font_map(f) != NULL && (same(font_name, k, f))) {
+ return 1;
}
- } else {
- if ((same(font_filename, k, f) && same(font_fullname, k, f))) {
- ret = 1;
- }
-#ifdef DEBUG
- printf("\nfont_shareable(%d:%s:%s,%d:%s:%s): => %d\n",
- f, font_filename(f), font_fullname(f),
- k, font_filename(k), font_fullname(k), ret);
-#endif
+ } else if ((same(font_filename, k, f) && same(font_fullname, k, f))) {
+ return 1;
}
- return ret;
+ return 0;
}
@ create a font object
@c
void pdf_init_font(PDF pdf, internal_font_number f)
{
- internal_font_number k/*, b*/;
+ internal_font_number k;
fm_entry *fm;
int i, l;
- assert(!font_used(f));
-
- ///* if |f| is auto expanded then ensure the base font is initialized */
- //
- // if (font_auto_expand(f) && ((b = pdf_font_blink(f)) != null_font)) {
- // if (!font_used(b))
- // pdf_init_font(pdf, b);
- // set_font_map(f, font_map(b));
- // /* propagate slant and extend from unexpanded base font */
- // set_font_slant(f, font_slant(b));
- // set_font_extend(f, font_extend(b));
- //}
- /* check whether |f| can share the font object with some |k|: we have 2 cases
- here: 1) |f| and |k| have the same tfm name (so they have been loaded at
- different sizes, eg 'cmr10' and 'cmr10 at 11pt'); 2) |f| has been auto
- expanded from |k|
- */
-
- /* take over slant and extend from map entry, if not already set;
- this should also be the only place where getfontmap() may be called. */
-
+ if (font_used(f)) {
+ formatted_error("pdf backend","font %i gets initialized twice",(int) f);
+ }
+ /*
+ check whether |f| can share the font object with some |k|: we have 2 cases
+ here: 1) |f| and |k| have the same tfm name (so they have been loaded at
+ different sizes, eg 'cmr10' and 'cmr10 at 11pt'); 2) |f| has been auto
+ expanded from |k|
+
+ take over slant and extend from map entry, if not already set;
+ this should also be the only place where getfontmap() may be called.
+ */
fm = getfontmap(font_name(f));
if (font_map(f) == NULL && fm != NULL) {
font_map(f) = fm;
@@ -155,7 +141,6 @@ void pdf_init_font(PDF pdf, internal_font_number f)
while (i != 0) {
k = obj_info(pdf, i);
if (font_shareable(f, k)) {
- assert(pdf_font_num(k) != 0);
if (pdf_font_num(k) < 0)
pdf_use_font(f, pdf_font_num(k));
else
@@ -169,20 +154,18 @@ void pdf_init_font(PDF pdf, internal_font_number f)
pdf_use_font(f, l);
}
-@ set the actual font on PDF page
+@ set the actual font on PDF page; sets |ff| to the tfm number of the base font
+sharing the font object with |f|; |ff| is either |f| itself (then it is its own
+base font), or some font with the same tfm name at different size and/or
+expansion.
+
@c
internal_font_number pdf_set_font(PDF pdf, internal_font_number f)
{
- int ff; /* for use with |set_ff| */
+ int ff; /* for use with |set_ff| */
if (!font_used(f))
pdf_init_font(pdf, f);
- /*
- set |ff| to the tfm number of the base font sharing the font object with |f|;
- |ff| is either |f| itself (then it is its own base font),
- or some font with the same tfm name at different size and/or expansion.
- */
- ff = pdf_font_num(f) < 0 ? -pdf_font_num(f) : f; /* aka |set_ff(f)| */
- assert(pdf_font_num(ff) > 0); /* base font object number */
+ ff = pdf_font_num(f) < 0 ? -pdf_font_num(f) : f; /* aka |set_ff(f)| */
addto_page_resources(pdf, obj_type_font, pdf_font_num(ff));
return ff;
}
@@ -191,7 +174,7 @@ internal_font_number pdf_set_font(PDF pdf, internal_font_number f)
void pdf_include_chars(PDF pdf)
{
str_number s;
- unsigned char *k, *j; /* running index */
+ unsigned char *k, *j; /* running index */
internal_font_number f;
scan_font_ident();
f = cur_val;
@@ -200,7 +183,7 @@ void pdf_include_chars(PDF pdf)
pdf_check_vf(cur_val);
if (!font_used(f))
pdf_init_font(pdf, f);
- scan_pdf_ext_toks();
+ scan_toks(false, true);
s = tokens_to_string(def_ref);
delete_token_ref(def_ref);
j = str_string(s) + str_length(s);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h
index d0677c1748f..0a8e099b177 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h
@@ -15,8 +15,8 @@
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/>.
+*/
#ifndef PDFGEN_H
# define PDFGEN_H
@@ -27,46 +27,49 @@
# 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 sup_pdf_mem_size 10000000 /* max 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;
extern int pdf_get_mem(PDF pdf, int s);
/*
-We use the similiar subroutines to handle the output buffer for
-PDF output. When compress is used, the state of writing to buffer
-is held in |zip_write_state|. We must write the header of PDF
-output file in initialization to ensure that it will be the first
-written bytes.
+
+We use the similiar subroutines to handle the output buffer for PDF output. When
+compress is used, the state of writing to buffer is held in |zip_write_state|. We
+must write the header of PDF output file in initialization to ensure that it will
+be the first written bytes.
+
*/
-# 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 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 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 */
+# 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 + (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 + (off_t)(pdf->buf->p - pdf->buf->data))
-# define set_ff(A) do { \
- if (pdf_font_num(A) < 0) \
- ff = -pdf_font_num(A); \
- else \
- ff = A; \
- } while (0)
+# define set_ff(A) do { \
+ if (pdf_font_num(A) < 0) \
+ ff = -pdf_font_num(A); \
+ else \
+ ff = A; \
+} while (0)
-typedef enum { NOT_SHIPPING, SHIPPING_PAGE, SHIPPING_FORM } shipping_mode_e; /* needs pdf_prefix */
+typedef enum { /* needs pdf_prefix */
+ NOT_SHIPPING,
+ SHIPPING_PAGE,
+ SHIPPING_FORM
+} shipping_mode_e;
extern scaled one_hundred_inch;
extern scaled one_inch;
@@ -80,29 +83,36 @@ extern void pdf_room(PDF, int);
extern void fix_pdf_minorversion(PDF);
- /* output a byte to PDF buffer without checking of overflow */
+/* output a byte to PDF buffer without checking of overflow */
+
# 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)
+
+# 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
-printing ones but the output is going to PDF buffer. Subroutines with
-suffix |_ln| append a new-line character to the PDF output.
+printing ones but the output is going to PDF buffer. Subroutines with suffix
+|_ln| append a new-line character to the PDF output.
+
*/
-/* 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_out(pdf, '\n'); \
- } while (0)
+# define pdf_print_ln(pdf,A) do { \
+ pdf_print(pdf,A); \
+ 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_out(pdf, '\n'); \
- } while (0)
+
+# 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 *, ...);
@@ -131,7 +141,6 @@ extern void pdf_begin_stream(PDF);
extern void pdf_end_stream(PDF);
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);
@@ -149,10 +158,10 @@ extern void pdf_out_block(PDF pdf, const char *s, size_t n);
# define pdf_puts(pdf, s) pdf_out_block((pdf), (s), strlen(s))
-# define pdf_print_resname_prefix(pdf) do { \
- if (pdf->resname_prefix != NULL) \
- pdf_puts(pdf, pdf->resname_prefix); \
- } while (0)
+# define pdf_print_resname_prefix(pdf) do { \
+ if (pdf->resname_prefix != NULL) \
+ pdf_puts(pdf, pdf->resname_prefix); \
+} while (0)
extern void pdf_print_str_ln(PDF, const char *);
@@ -195,15 +204,14 @@ extern int get_pdf_table_bool(PDF, const char *, int);
extern void ensure_output_state(PDF pdf, output_state s);
extern PDF init_pdf_struct(PDF pdf);
-extern halfword pdf_info_toks; /* additional keys of Info dictionary */
+extern halfword pdf_info_toks; /* additional keys of Info dictionary */
extern halfword pdf_catalog_toks; /* additional keys of Catalog dictionary */
extern halfword pdf_catalog_openaction;
-extern halfword pdf_names_toks; /* additional keys of Names dictionary */
+extern halfword pdf_names_toks; /* additional keys of Names dictionary */
extern halfword pdf_trailer_toks; /* additional keys of Trailer dictionary */
extern void scan_pdfcatalog(PDF pdf);
-extern void finish_pdf_file(PDF pdf, int luatex_version,
- str_number luatex_revision);
+extern void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision);
extern shipping_mode_e global_shipping_mode;
-#endif /* PDFGEN_H */
+#endif
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w
index f9a96aac808..94bfbaddcbf 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w
@@ -30,11 +30,12 @@
#define check_nprintf(size_get, size_want) \
if ((unsigned)(size_get) >= (unsigned)(size_want)) \
- luatex_fail ("snprintf failed: file %s, line %d", __FILE__, __LINE__);
+ formatted_error("pdf backend","snprintf() failed in file %s at line %d", __FILE__, __LINE__);
PDF static_pdf = NULL;
@ commandline interface
+
@c
int output_mode_used;
int output_mode_option;
@@ -42,12 +43,12 @@ int output_mode_value;
int draft_mode_option;
int draft_mode_value;
-halfword pdf_info_toks; /* additional keys of Info dictionary */
-halfword pdf_catalog_toks; /* additional keys of Catalog dictionary */
+halfword pdf_info_toks; /* additional keys of Info dictionary */
+halfword pdf_catalog_toks; /* additional keys of Catalog dictionary */
halfword pdf_catalog_openaction;
-halfword pdf_names_toks; /* additional keys of Names dictionary */
-halfword pdf_trailer_toks; /* additional keys of Trailer dictionary */
-shipping_mode_e global_shipping_mode = NOT_SHIPPING; /* set to |shipping_mode| when |ship_out| starts */
+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 */
@ Create a new buffer |strbuf_s| of size |size| and maximum allowed size |limit|.
Initialize it and set |p| to begin of data.
@@ -56,14 +57,13 @@ Initialize it and set |p| to begin of data.
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 */
+ b->p = b->data = NULL; /* for other alloc */
return b;
}
@@ -94,7 +94,6 @@ static void strbuf_room(strbuf_s * b, size_t n)
@c
void strbuf_seek(strbuf_s * b, off_t offset)
{
- assert(offset >= 0 && offset < (off_t) b->size);
b->p = b->data + offset;
}
@@ -140,12 +139,11 @@ void strbuf_free(strbuf_s * b)
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);
- output_mode_used = OMODE_NONE; /* will be set by |fix_o_mode()| */
+ output_mode_used = OMODE_NONE; /* will be set by |fix_o_mode()| */
pdf->o_mode = output_mode_used; /* used by synctex, we need to use output_mode_used there */
pdf->o_state = ST_INITIAL;
@@ -159,20 +157,27 @@ PDF init_pdf_struct(PDF pdf)
os->curbuf = PDFOUT_BUF;
pdf->buf = os->buf[os->curbuf];
-
- /* Later ttf_seek_outbuf(TABDIR_OFF + n * 4 * TTF_ULONG_SIZE) */
- /* in ttf_init_font will need 236 bytes, so we start with 256 bytes as in pdftex. */
+ /*
+ Later ttf_seek_outbuf(TABDIR_OFF + n * 4 * TTF_ULONG_SIZE); in ttf_init_font
+ we need 236 bytes, so we start with 256 bytes as in pdftex.
+ */
pdf->fb = new_strbuf(256, 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. */
- pdf->mem_size = inf_pdf_mem_size; /* allocated size of |mem| array */
+ /*
+ Sometimes it is neccesary to allocate memory for PDF output that cannot be
+ deallocated then, so we use |mem| for this purpose.
+ */
+ pdf->mem_size = inf_pdf_mem_size;
pdf->mem = xtalloc(pdf->mem_size, int);
- pdf->mem_ptr = 1; /* the first word is not used so we can use zero as a value for testing
- whether a pointer to |mem| is valid */
+ /*
+ The first word is not used so we can use zero as a value for testing
+ whether a pointer to |mem| is valid.
+ */
+ pdf->mem_ptr = 1;
+
pdf->pstruct = NULL;
pdf->posstruct = xtalloc(1, posstructure);
@@ -180,11 +185,12 @@ PDF init_pdf_struct(PDF pdf)
pdf->posstruct->pos.v = 0;
pdf->posstruct->dir = dir_TLT;
- pdf->obj_tab_size = (unsigned) inf_obj_tab_size; /* allocated size of |obj_tab| array */
+ /* allocated size of |obj_tab| array */
+ pdf->obj_tab_size = (unsigned) inf_obj_tab_size;
pdf->obj_tab = xtalloc(pdf->obj_tab_size + 1, obj_entry);
memset(pdf->obj_tab, 0, sizeof(obj_entry));
- pdf->minor_version = -1; /* unset */
+ pdf->minor_version = -1;
pdf->decimal_digits = 4;
pdf->gamma = 65536;
pdf->image_gamma = 65536;
@@ -194,7 +200,6 @@ PDF init_pdf_struct(PDF pdf)
pdf->compress_level = 0;
pdf->draftmode = 0;
pdf->inclusion_copy_font = 1;
- pdf->replace_font = 0;
pdf->pk_resolution = 0;
pdf->pk_scale_factor = 0;
@@ -202,7 +207,6 @@ PDF init_pdf_struct(PDF pdf)
pdf->page_resources = NULL;
init_pdf_pagecalculations(pdf);
- pdf->pdflua_ref = new_pdflua();
pdf->vfstruct = new_vfstruct();
@@ -213,11 +217,11 @@ PDF init_pdf_struct(PDF pdf)
@c
int pdf_get_mem(PDF pdf, int s)
-{ /* allocate |s| words in |mem| */
+{
int a;
int ret;
if (s > sup_pdf_mem_size - pdf->mem_ptr)
- overflow("PDF memory size (pdf_mem_size)", (unsigned) pdf->mem_size);
+ overflow("pdf memory size (pdf_mem_size)", (unsigned) pdf->mem_size);
if (pdf->mem_ptr + s > pdf->mem_size) {
a = pdf->mem_size >> 2;
if (pdf->mem_ptr + s > pdf->mem_size + a) {
@@ -258,10 +262,10 @@ void fix_o_mode(void)
}
}
-@ This ensures that |pdfminorversion| is set only before any bytes have
-been written to the generated \.{PDF} file. Here also all variables for
-\.{PDF} output are initialized, the \.{PDF} file is opened by |ensure_pdf_open|,
-and the \.{PDF} header is written.
+@ This ensures that |pdfminorversion| is set only before any bytes have been
+written to the generated \.{PDF} file. Here also all variables for \.{PDF} output
+are initialized, the \.{PDF} file is opened by |ensure_pdf_open|, and the \.{PDF}
+header is written.
@c
void fix_pdf_minorversion(PDF pdf)
@@ -292,9 +296,9 @@ void fix_pdf_minorversion(PDF pdf)
@ @c
#define ZIP_BUF_SIZE 32768
-#define check_err(f, fn) \
- if (f != Z_OK) \
- luatex_fail("zlib: %s() failed (error code %d)", fn, f)
+#define check_err(f, fn) \
+ if (f != Z_OK) \
+ formatted_error("pdf backend","zlib %s() failed (error code %d)", fn, f)
@ @c
static void write_zip(PDF pdf)
@@ -304,15 +308,6 @@ static void write_zip(PDF pdf)
strbuf_s *buf = pdf->buf;
z_stream *s = pdf->c_stream;
boolean finish = pdf->zip_write_state == ZIP_FINISH;
- assert(pdf->compress_level > 0);
- /* This was just to suppress the filename report in |luatex_fail|
- but zlib errors are rare enough (especially now that the
- compress level is fixed) that I don't care about the slightly
- ugly error message that could result.
- */
-#if 0
- cur_file_name = NULL;
-#endif
if (pdf->stream_length == 0) {
if (s == NULL) {
s = pdf->c_stream = xtalloc(1, z_stream);
@@ -320,15 +315,12 @@ static void write_zip(PDF pdf)
s->zfree = (free_func) 0;
s->opaque = (voidpf) 0;
check_err(deflateInit(s, pdf->compress_level), "deflateInit");
- assert(pdf->zipbuf == NULL);
pdf->zipbuf = xtalloc(ZIP_BUF_SIZE, char);
} else
check_err(deflateReset(s), "deflateReset");
s->next_out = (Bytef *) pdf->zipbuf;
s->avail_out = ZIP_BUF_SIZE;
}
- assert(s != NULL);
- assert(pdf->zipbuf != NULL);
s->next_in = buf->data;
s->avail_in = (uInt) (buf->p - buf->data);
while (true) {
@@ -341,8 +333,6 @@ static void write_zip(PDF pdf)
}
if (finish) {
if (err == Z_STREAM_END) {
- assert(s->avail_in == 0);
- assert(s->avail_out == ZIP_BUF_SIZE);
xfflush(pdf->file);
pdf->zip_write_state = NO_ZIP;
break;
@@ -355,7 +345,7 @@ static void write_zip(PDF pdf)
}
err = deflate(s, flush);
if (err != Z_OK && err != Z_STREAM_END)
- luatex_fail("zlib: deflate() failed (error code %d)", err);
+ formatted_error("pdf backend","zlib deflate() failed (error code %d)", err);
}
pdf->stream_length = (off_t) s->total_out;
}
@@ -378,8 +368,7 @@ static void write_nozip(PDF pdf)
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->gone += (off_t) xfwrite((char *) buf->data, sizeof(char), l, pdf->file);
pdf->last_byte = *(buf->p - 1);
}
@@ -390,34 +379,33 @@ 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| */
+{
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);
- break;
- default:
- assert(0);
- }
- } else
- pdf->zip_write_state = NO_ZIP;
- strbuf_seek(pdf->buf, 0);
- if (saved_pdf_gone > pdf->gone)
- normal_error("pdf backend", "file size exceeds architectural limits (pdf_gone wraps around)");
- break;
- case OBJSTM_BUF:
- break;
- default:
- assert(0);
+ 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);
+ break;
+ default:
+ normal_error("pdf backend", "bad zip state");
+ }
+ } else
+ pdf->zip_write_state = NO_ZIP;
+ strbuf_seek(pdf->buf, 0);
+ if (saved_pdf_gone > pdf->gone)
+ normal_error("pdf backend", "file size exceeds architectural limits (pdf_gone wraps around)");
+ break;
+ case OBJSTM_BUF:
+ break;
+ default:
+ normal_error("pdf backend", "bad buffer state");
}
}
@@ -426,9 +414,9 @@ 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 */
+ os->curbuf = OBJSTM_BUF; /* switch to object stream */
else
- os->curbuf = PDFOUT_BUF; /* switch to PDF stream */
+ os->curbuf = PDFOUT_BUF; /* switch to PDF stream */
pdf->buf = os->buf[pdf->os->curbuf];
}
@@ -439,64 +427,53 @@ 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(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 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 */
- }
- 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);
+ 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 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, 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:
+ normal_error("pdf backend", "bad object state");
}
}
@* Low-level buffer checkers.
-@ Set the active buffer pointer.
-Make sure that there are at least |n| bytes free in that buffer,
-flush if needed.
+@ 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)
+inline void pdf_room(PDF pdf, int n)
{
- os_struct *os = pdf->os;
strbuf_s *buf = pdf->buf;
if ((size_t) (n + buf->p - buf->data) <= buf->size)
return;
- assert(buf == os->buf[os->curbuf]);
- switch (os->curbuf) {
- case PDFOUT_BUF:
+ if (pdf->os->curbuf == 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 */
+ strbuf_room(buf, (size_t) n);
else
pdf_flush(pdf);
- break;
- case OBJSTM_BUF:
- strbuf_room(buf, (size_t) n); /* just grow it */
- break;
- default:
- assert(0);
+ } else {
+ strbuf_room(buf, (size_t) n);
}
}
@@ -543,7 +520,6 @@ void pdf_print(PDF pdf, str_number s)
l = str_length(s);
pdf_out_block(pdf, ss, l);
} else {
- assert(s < 256);
pdf_out(pdf, s);
}
}
@@ -564,7 +540,7 @@ void pdf_print_int(PDF pdf, longinteger n)
void print_pdffloat(PDF pdf, pdffloat f)
{
char a[24];
- int e = f.e, i, j, l;
+ int e = f.e, i, l;
int64_t m = f.m;
if (m < 0) {
pdf_out(pdf, '-');
@@ -575,8 +551,7 @@ void print_pdffloat(PDF pdf, pdffloat f)
l = m % ten_pow[e];
if (l != 0) {
pdf_out(pdf, '.');
- j = snprintf(a, 23, "%d", l + ten_pow[e]);
- assert(j < 23);
+ snprintf(a, 23, "%d", l + ten_pow[e]);
for (i = e; i > 0; i--) {
if (a[i] != '0')
break;
@@ -592,7 +567,7 @@ void print_pdffloat(PDF pdf, pdffloat f)
void pdf_print_str(PDF pdf, const char *s)
{
const char *orig = s;
- int l = (int) strlen(s) - 1; /* last string index */
+ int l = (int) strlen(s) - 1; /* last string index */
if (l < 0) {
pdf_puts(pdf, "()");
return;
@@ -617,7 +592,7 @@ void pdf_print_str(PDF pdf, const char *s)
pdf_out(pdf, ')');
return;
}
- pdf_puts(pdf, orig); /* it was a hex string after all */
+ pdf_puts(pdf, orig); /* it was a hex string after all */
}
@ begin a stream (needs to have a stream dictionary also)
@@ -625,15 +600,10 @@ void pdf_print_str(PDF pdf, const char *s)
@c
void pdf_begin_stream(PDF pdf)
{
- os_struct *os = pdf->os;
- 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 (pdf->stream_deflate) {
- assert(pdf->compress_level > 0);
pdf->zip_write_state = ZIP_WRITING;
}
pdf->stream_writing = true;
@@ -647,30 +617,25 @@ void pdf_begin_stream(PDF pdf)
void pdf_end_stream(PDF pdf)
{
os_struct *os = pdf->os;
- 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 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]);
+ 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 OBJSTM_BUF:
+ normal_error("pdf backend", "bad buffer in end stream, case 1");
+ break;
+ default:
+ normal_error("pdf backend", "bad buffer in end stream, case 2");
+ }
pdf->stream_deflate = false;
pdf->stream_writing = false;
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);
+ xfseeko(pdf->file, (off_t)pdf->stream_length_offset, SEEK_SET, pdf->job_name);
fprintf(pdf->file, "%" LONGINTEGER_PRI "i", (LONGINTEGER_TYPE) pdf->stream_length);
xfseeko(pdf->file, 0, SEEK_END, pdf->job_name);
}
@@ -705,8 +670,8 @@ for optimizations that are not possible in pascal.
@c
scaled round_xn_over_d(scaled x, int n, unsigned int d)
{
- boolean positive = true; /* was |x>=0|, |n>=0| ? */
- unsigned t, u, v; /* intermediate quantities */
+ boolean positive = true;
+ unsigned t, u, v;
if (x < 0) {
positive = !positive;
x = -(x);
@@ -733,10 +698,9 @@ scaled round_xn_over_d(scaled x, int n, unsigned int d)
@ @c
void pdf_add_bp(PDF pdf, scaled s)
-{ /* print scaled as |bp| */
+{
pdffloat a;
pdfstructure *p = pdf->pstruct;
- assert(p != NULL);
a.m = i64round(s * p->k1);
a.e = pdf->decimal_digits;
if (pdf->cave > 0)
@@ -745,22 +709,6 @@ void pdf_add_bp(PDF pdf, scaled s)
pdf->cave = 1;
}
-void pdf_add_mag_bp(PDF pdf, scaled s)
-{ /* take |mag| into account */
- pdffloat a;
- pdfstructure *p = pdf->pstruct;
- prepare_mag();
- if (int_par(mag_code) != 1000)
- a.m = i64round(s * (double) int_par(mag_code) / 1000.0 * p->k1);
- else
- a.m = i64round(s * p->k1);
- a.e = pdf->decimal_digits;
- if (pdf->cave > 0)
- pdf_out(pdf, ' ');
- print_pdffloat(pdf, a);
- pdf->cave = 1;
-}
-
@* handling page resources.
@c
@@ -772,10 +720,9 @@ typedef struct {
@ @c
static int comp_page_resources(const void *pa, const void *pb, void *p)
{
- int a, b;
+ int a = ((const pr_entry *) pa)->obj_type;
+ int b = ((const pr_entry *) pb)->obj_type;
(void) p;
- a = ((const pr_entry *) pa)->obj_type;
- b = ((const pr_entry *) pb)->obj_type;
if (a > b)
return 1;
if (a < b)
@@ -790,16 +737,11 @@ void addto_page_resources(PDF pdf, pdf_obj_type t, int k)
pr_entry *pr, tmp;
void **pp;
pdf_object_list *p, *item = NULL;
- assert(pdf != NULL);
re = pdf->page_resources;
- assert(re != NULL);
- assert(t <= PDF_OBJ_TYPE_MAX);
if (re->resources_tree == NULL) {
- re->resources_tree =
- avl_create(comp_page_resources, NULL, &avl_xallocator);
+ re->resources_tree = avl_create(comp_page_resources, NULL, &avl_xallocator);
if (re->resources_tree == NULL)
- luatex_fail
- ("addto_page_resources(): avl_create() page_resource_tree failed");
+ formatted_error("pdf backend","addto_page_resources(): avl_create() page_resource_tree failed");
}
tmp.obj_type = t;
pr = (pr_entry *) avl_find(re->resources_tree, &tmp);
@@ -809,8 +751,7 @@ void addto_page_resources(PDF pdf, pdf_obj_type t, int k)
pr->list = NULL;
pp = avl_probe(re->resources_tree, pr);
if (pp == NULL)
- luatex_fail
- ("addto_page_resources(): avl_probe() out of memory in insertion");
+ formatted_error("pdf backend","addto_page_resources(): avl_probe() out of memory in insertion");
}
if (pr->list == NULL) {
item = xtalloc(1, pdf_object_list);
@@ -949,10 +890,10 @@ void pdf_print_toks(PDF pdf, halfword p)
@c
void pdf_add_rect_spec(PDF pdf, halfword 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));
+ pdf_add_bp(pdf, pdf_ann_left(r));
+ pdf_add_bp(pdf, pdf_ann_bottom(r));
+ pdf_add_bp(pdf, pdf_ann_right(r));
+ pdf_add_bp(pdf, pdf_ann_top(r));
}
@ output a rectangle specification to PDF file
@@ -960,7 +901,6 @@ void pdf_add_rect_spec(PDF pdf, halfword r)
@c
void pdf_rectangle(PDF pdf, halfword r)
{
- prepare_mag();
pdf_add_name(pdf, "Rect");
pdf_begin_array(pdf);
pdf_add_rect_spec(pdf, r);
@@ -971,7 +911,6 @@ void pdf_rectangle(PDF pdf, halfword r)
static void init_pdf_outputparameters(PDF pdf)
{
int pk_mode;
- assert(output_mode_used == OMODE_PDF);
pdf->draftmode = fix_int(int_par(draft_mode_code), 0, 1);
pdf->compress_level = fix_int(pdf_compress_level, 0, 9);
pdf->decimal_digits = fix_int(pdf_decimal_digits, 0, 4);
@@ -981,21 +920,19 @@ static void init_pdf_outputparameters(PDF pdf)
pdf->image_apply_gamma = fix_int(pdf_image_apply_gamma, 0, 1);
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);
if ((pdf->minor_version >= 5) && (pdf->objcompresslevel > 0)) {
pdf->os_enable = true;
} else {
if (pdf->objcompresslevel > 0) {
- normal_warning("pdf backend","objcompresslevel > 0 requires minorversion > 4", true, true);
+ normal_warning("pdf backend","objcompresslevel > 0 requires minorversion > 4");
pdf->objcompresslevel = 0;
}
pdf->os_enable = false;
}
if (pdf->pk_resolution == 0) /* if not set from format file or by user */
pdf->pk_resolution = pk_dpi; /* take it from \.{texmf.cnf} */
- pdf->pk_scale_factor =
- divide_scaled(72, pdf->pk_resolution, 5 + pdf->decimal_digits);
+ pdf->pk_scale_factor = divide_scaled(72, pdf->pk_resolution, 5 + pdf->decimal_digits);
if (!callback_defined(read_pk_file_callback)) {
pk_mode = pdf_pk_mode; /* lookup once */
if (pk_mode != null) {
@@ -1008,8 +945,7 @@ static void init_pdf_outputparameters(PDF pdf)
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));
+ set_job_id(pdf, int_par(year_code), int_par(month_code), int_par(day_code), int_par(time_code));
if ((pdf_unique_resname > 0) && (pdf->resname_prefix == NULL))
pdf->resname_prefix = get_resname_prefix(pdf);
}
@@ -1035,8 +971,6 @@ static void ensure_output_file_open(PDF pdf, const char *ext)
@ @c
static void ensure_pdf_header_written(PDF pdf)
{
- assert(pdf->o_state == ST_FILE_OPEN);
- assert(output_mode_used == OMODE_PDF);
/* Initialize variables for \.{PDF} output */
fix_pdf_minorversion(pdf);
init_pdf_outputparameters(pdf);
@@ -1057,39 +991,39 @@ void ensure_output_state(PDF pdf, output_state s)
if (s > ST_INITIAL)
ensure_output_state(pdf, s - 1);
switch (s - 1) {
- case ST_INITIAL:
- fix_o_mode();
- break;
- case ST_OMODE_FIX:
- switch (output_mode_used) {
- case OMODE_DVI:
- ensure_output_file_open(pdf, ".dvi");
+ case ST_INITIAL:
+ fix_o_mode();
break;
- case OMODE_PDF:
- ensure_output_file_open(pdf, ".pdf");
+ case ST_OMODE_FIX:
+ switch (output_mode_used) {
+ case OMODE_DVI:
+ ensure_output_file_open(pdf, ".dvi");
+ break;
+ case OMODE_PDF:
+ ensure_output_file_open(pdf, ".pdf");
+ break;
+ default:
+ normal_error("pdf backend","weird output state");
+ }
break;
- default:
- assert(0);
- }
- break;
- case ST_FILE_OPEN:
- switch (output_mode_used) {
- case OMODE_DVI:
- ensure_dvi_header_written(pdf);
+ case ST_FILE_OPEN:
+ switch (output_mode_used) {
+ case OMODE_DVI:
+ ensure_dvi_header_written(pdf);
+ break;
+ case OMODE_PDF:
+ ensure_pdf_header_written(pdf);
+ break;
+ default:
+ normal_error("pdf backend","weird output state");
+ }
break;
- case OMODE_PDF:
- ensure_pdf_header_written(pdf);
+ case ST_HEADER_WRITTEN:
+ break;
+ case ST_FILE_CLOSED:
break;
default:
- assert(0);
- }
- break;
- case ST_HEADER_WRITTEN:
- break;
- case ST_FILE_CLOSED:
- break;
- default:
- assert(0);
+ normal_error("pdf backend","weird output state");
}
pdf->o_state++;
}
@@ -1097,12 +1031,11 @@ void ensure_output_state(PDF pdf, output_state s)
@ Write out an accumulated object stream.
-First the object number and byte offset pairs are generated
-and appended to the ready buffered object stream.
-By this the value of \.{/First} can be calculated.
-Then a new \.{/ObjStm} object is generated, and everything is
-copied to the PDF output buffer, where also compression is done.
-When calling this procedure, |pdf_os_mode| must be |true|.
+First the object number and byte offset pairs are generated and appended to the
+ready buffered object stream. By this the value of \.{/First} can be calculated.
+Then a new \.{/ObjStm} object is generated, and everything is copied to the PDF
+output buffer, where also compression is done. When calling this procedure,
+|pdf_os_mode| must be |true|.
@c
static void pdf_os_write_objstream(PDF pdf)
@@ -1112,8 +1045,6 @@ static void pdf_os_write_objstream(PDF pdf)
strbuf_s *obuf = os->buf[OBJSTM_BUF];
if (os->cur_objstm == 0) /* no object stream started */
return;
- 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 */
@@ -1282,11 +1213,10 @@ 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->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");
@@ -1320,17 +1250,16 @@ 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 OBJSTM_BUF:
- if (pdf->compress_level == 0)
- pdf_printf(pdf, "%% %d 0 obj\n", (int) i); /* debugging help */
- break;
- default:
- assert(0);
+ case PDFOUT_BUF:
+ pdf_printf(pdf, "%d 0 obj\n", (int) i);
+ break;
+ case OBJSTM_BUF:
+ if (pdf->compress_level == 0)
+ pdf_printf(pdf, "%% %d 0 obj\n", (int) i); /* debugging help */
+ break;
+ default:
+ normal_error("pdf backend","weird begin object");
}
pdf->cave = 0;
}
@@ -1341,21 +1270,20 @@ void pdf_begin_obj(PDF pdf, int i, int pdf_os_threshold)
void pdf_end_obj(PDF pdf)
{
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 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_out(pdf, '\n'); /* Adobe Reader seems to need this */
- break;
- default:
- assert(0);
+ case PDFOUT_BUF:
+ pdf_puts(pdf, "\nendobj\n"); /* end a PDF object */
+ 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_out(pdf, '\n'); /* Adobe Reader seems to need this */
+ break;
+ default:
+ normal_error("pdf backend","weird end object");
}
}
@@ -1400,16 +1328,15 @@ char *convertStringToPDFString(const char *in, int len)
return pstrbuf;
}
-@ Converts any string given in in in an allowed PDF string which is
- hexadecimal encoded;
- |sizeof(out)| should be at least $|lin|*2+1$.
+@ 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)
{
- int i, j, k;
+ int i, k;
char buf[3];
- j = 0;
+ int j = 0;
for (i = 0; i < lin; i++) {
k = snprintf(buf, sizeof(buf), "%02X", (unsigned int) (unsigned char) in[i]);
check_nprintf(k, sizeof(buf));
@@ -1420,37 +1347,32 @@ static void convertStringToHexString(const char *in, char *out, int lin)
}
@ Compute the ID string as per PDF1.4 9.3:
-\medskip
-{\obeylines\obeyspaces
- File identifers are defined by the optional ID entry in a PDF file's
- trailer dictionary (see Section 3.4.4, "File Trailer"; see also
- implementation note 105 in Appendix H). The value of this entry is an
- array of two strings. The first string is a permanent identifier based
- on the contents of the file at the time it was originally created, and
- does not change when the file is incrementally updated. The second
- string is a changing identifier based on the file's contents at the
- time it was last updated. When a file is first written, both
- identifiers are set to the same value. If both identifiers match when a
- file reference is resolved, it is very likely that the correct file has
- been found; if only the first identifier matches, then a different
- version of the correct file has been found.
- To help ensure the uniqueness of file identifiers, it is recommend
- that they be computed using a message digest algorithm such as MD5
- (described in Internet RFC 1321, The MD5 Message-Digest Algorithm; see
- the Bibliography), using the following information (see implementation
- note 106 in Appendix H):
- - The current time
- - A string representation of the file's location, usually a pathname
- - The size of the file in bytes
- - The values of all entries in the file's document information
- dictionary (see Section 9.2.1, Document Information Dictionary )
-}
-\medskip
- This stipulates only that the two IDs must be identical when the file is
- created and that they should be reasonably unique. Since it's difficult
- to get the file size at this point in the execution of pdfTeX and
- scanning the info dict is also difficult, we start with a simpler
- implementation using just the first two items.
+
+File identifers are defined by the optional ID entry in a PDF file's trailer
+dictionary (see Section 3.4.4, "File Trailer"; see also implementation note 105
+in Appendix H). The value of this entry is an array of two strings. The first
+string is a permanent identifier based on the contents of the file at the time it
+was originally created, and does not change when the file is incrementally
+updated. The second string is a changing identifier based on the file's contents
+at the time it was last updated. When a file is first written, both identifiers
+are set to the same value. If both identifiers match when a file reference is
+resolved, it is very likely that the correct file has been found; if only the
+first identifier matches, then a different version of the correct file has been
+found. To help ensure the uniqueness of file identifiers, it is recommend that
+they be computed using a message digest algorithm such as MD5 (described in
+Internet RFC 1321, The MD5 Message-Digest Algorithm; see the Bibliography), using
+the following information (see implementation note 106 in Appendix H): - The
+current time
+
+- A string representation of the file's location, usually a pathname
+- The size of the file in bytes
+- The values of all entries in the file's document information
+ dictionary (see Section 9.2.1, Document Information Dictionary )
+
+This stipulates only that the two IDs must be identical when the file is created
+and that they should be reasonably unique. Since it's difficult to get the file
+size at this point in the execution of pdfTeX and scanning the info dict is also
+difficult, we start with a simpler implementation using just the first two items.
@c
static void print_ID(PDF pdf)
@@ -1470,7 +1392,7 @@ static void print_ID(PDF pdf)
md5_append(&state, (const md5_byte_t *) time_str, (int) size);
/* get the file name */
if (getcwd(pwd, sizeof(pwd)) == NULL)
- luatex_fail("getcwd() failed (%s), (path too long?)", strerror(errno));
+ formatted_error("pdf backend","getcwd() failed (%s), (path too long?)", strerror(errno));
#ifdef WIN32
{
char *p;
@@ -1498,56 +1420,50 @@ static void print_ID(PDF pdf)
@ Print the /CreationDate entry.
- PDF Reference, third edition says about the expected date format:
-\medskip
-{\obeylines\obeyspaces
- 3.8.2 Dates
-
- PDF defines a standard date format, which closely follows that of
- the international standard ASN.1 (Abstract Syntax Notation One),
- defined in ISO/IEC 8824 (see the Bibliography). A date is a string
- of the form
-
- (D:YYYYMMDDHHmmSSOHH'mm')
-
- where
-
- YYYY is the year
- MM is the month
- DD is the day (01-31)
- HH is the hour (00-23)
- mm is the minute (00-59)
- SS is the second (00-59)
- O is the relationship of local time to Universal Time (UT),
- denoted by one of the characters +, -, or Z (see below)
- HH followed by ' is the absolute value of the offset from UT
- in hours (00-23)
- mm followed by ' is the absolute value of the offset from UT
- in minutes (00-59)
-
- The apostrophe character (') after HH and mm is part of the syntax.
- All fields after the year are optional. (The prefix D:, although also
- optional, is strongly recommended.) The default values for MM and DD
- are both 01; all other numerical fields default to zero values. A plus
- sign (+) as the value of the O field signifies that local time is
- later than UT, a minus sign (-) that local time is earlier than UT,
- and the letter Z that local time is equal to UT. If no UT information
- is specified, the relationship of the specified time to UT is
- considered to be unknown. Whether or not the time zone is known, the
- rest of the date should be specified in local time.
-
- For example, December 23, 1998, at 7:52 PM, U.S. Pacific Standard
- Time, is represented by the string
-
- D:199812231952-08'00'
-}
-
- The main difficulty is get the time zone offset. |strftime()| does this in ISO
- C99 (e.g. newer glibc) with \%z, but we have to work with other systems (e.g.
- Solaris 2.5).
+PDF Reference, third edition says about the expected date format:
+
+3.8.2 Dates
+
+PDF defines a standard date format, which closely follows that of the
+international standard ASN.1 (Abstract Syntax Notation One), defined in ISO/IEC
+8824 (see the Bibliography). A date is a string of the form
+
+(D:YYYYMMDDHHmmSSOHH'mm')
+
+where
+
+YYYY is the year
+MM is the month
+DD is the day (01-31)
+HH is the hour (00-23)
+mm is the minute (00-59)
+SS is the second (00-59)
+O is the relationship of local time to Universal Time (UT), denoted by one
+ of the characters +, -, or Z (see below)
+HH followed by ' is the absolute value of the offset from UT in hours (00-23)
+mm followed by ' is the absolute value of the offset from UT in minutes (00-59)
+
+The apostrophe character (') after HH and mm is part of the syntax. All fields
+after the year are optional. (The prefix D:, although also optional, is strongly
+recommended.) The default values for MM and DD are both 01; all other numerical
+fields default to zero values. A plus sign (+) as the value of the O field
+signifies that local time is later than UT, a minus sign (-) that local time is
+earlier than UT, and the letter Z that local time is equal to UT. If no UT
+information is specified, the relationship of the specified time to UT is
+considered to be unknown. Whether or not the time zone is known, the rest of the
+date should be specified in local time.
+
+For example, December 23, 1998, at 7:52 PM, U.S. Pacific Standard Time, is
+represented by the string
+
+D:199812231952-08'00'
+
+The main difficulty is get the time zone offset. |strftime()| does this in ISO
+C99 (e.g. newer glibc) with \%z, but we have to work with other systems (e.g.
+Solaris 2.5).
@c
-#define TIME_STR_SIZE 30 /* minimum size for |time_str| is 24: |"D:YYYYmmddHHMMSS+HH'MM'"| */
+#define TIME_STR_SIZE 30 /* minimum size for |time_str| is 24: |"D:YYYYmmddHHMMSS+HH'MM'"| */
static void makepdftime(PDF pdf)
{
@@ -1556,7 +1472,6 @@ static void makepdftime(PDF pdf)
int i, off, off_hours, off_mins;
time_t t = pdf->start_time;
char *time_str = pdf->start_time_str;
-
/* get the time */
lt = *localtime(&t);
size = strftime(time_str, TIME_STR_SIZE, "D:%Y%m%d%H%M%S", &lt);
@@ -1566,19 +1481,18 @@ static void makepdftime(PDF pdf)
time_str[0] = '\0';
return;
}
-
- /* correction for seconds: \%S can be in range 00..61,
- the PDF reference expects 00..59,
- therefore we map "60" and "61" to "59" */
+ /*
+ correction for seconds: \%S can be in range 00..61, the PDF reference
+ expects 00..59, therefore we map "60" and "61" to "59"
+ */
if (time_str[14] == '6') {
time_str[14] = '5';
time_str[15] = '9';
- time_str[16] = '\0'; /* for safety */
+ /* for safety */
+ time_str[16] = '\0';
}
-
/* get the time zone offset */
gmt = *gmtime(&t);
-
/* this calculation method was found in exim's tod.c */
off = 60 * (lt.tm_hour - gmt.tm_hour) + lt.tm_min - gmt.tm_min;
if (lt.tm_year != gmt.tm_year) {
@@ -1586,7 +1500,6 @@ static void makepdftime(PDF pdf)
} else if (lt.tm_yday != gmt.tm_yday) {
off += (lt.tm_yday > gmt.tm_yday) ? 1440 : -1440;
}
-
if (off == 0) {
time_str[size++] = 'Z';
time_str[size] = 0;
@@ -1602,7 +1515,6 @@ static void makepdftime(PDF pdf)
@ @c
void init_start_time(PDF pdf)
{
- assert(pdf);
if (pdf->start_time == 0) {
pdf->start_time = time((time_t *) NULL);
pdf->start_time_str = xtalloc(TIME_STR_SIZE, char);
@@ -1613,7 +1525,6 @@ void init_start_time(PDF pdf)
@ @c
char *getcreationdate(PDF pdf)
{
- assert(pdf);
init_start_time(pdf);
return pdf->start_time_str;
}
@@ -1635,20 +1546,16 @@ void remove_pdffile(PDF pdf)
void check_o_mode(PDF pdf, const char *s, int o_mode_bitpattern, boolean strict) /* s ignored now */
{
- char warn_string[100];
output_mode o_mode;
const char *m = NULL;
-
if (lua_only) {
normal_error("lua only","no backend present, needed for what you asked for");
return ;
}
-
- /* in warn mode (strict == false):
- only check, don't do |fix_o_mode()| here! |output_mode_used| is left
- in possibly wrong state until real output, ok.
- */
-
+ /*
+ in warn mode (strict == false): only check, don't do |fix_o_mode()| here! |output_mode_used|
+ is left in possibly wrong state until real output, ok.
+ */
if (output_mode_used == OMODE_NONE)
o_mode = get_o_mode();
else
@@ -1656,21 +1563,19 @@ void check_o_mode(PDF pdf, const char *s, int o_mode_bitpattern, boolean strict)
pdf->o_mode = output_mode_used; /* used by synctex, we need to use output_mode_used there */
if (!((1 << o_mode) & o_mode_bitpattern)) { /* warning or error */
switch (o_mode) {
- case OMODE_DVI:
- m = "DVI";
- break;
- case OMODE_PDF:
- m = "PDF";
- break;
- default:
- assert(0);
- }
- snprintf(warn_string, 99, "%s not allowed in %s mode (outputmode = %d)",
- s, m, (int) int_par(output_mode_code));
+ case OMODE_DVI:
+ m = "DVI";
+ break;
+ case OMODE_PDF:
+ m = "PDF";
+ break;
+ default:
+ normal_error("pdf backend","weird output state");
+ }
if (strict)
- normal_error("pdf backend", warn_string);
+ formatted_error("pdf backend", "%s not allowed in %s mode (outputmode = %d)",s, m, (int) int_par(output_mode_code));
else
- normal_warning("pdf backend", warn_string, true, true);
+ formatted_warning("pdf backend", "%s not allowed in %s mode (outputmode = %d)",s, m, (int) int_par(output_mode_code));
} else if (strict)
ensure_output_state(pdf, ST_HEADER_WRITTEN);
}
@@ -1681,20 +1586,14 @@ void set_job_id(PDF pdf, int year, int month, int day, int time)
char *name_string, *format_string, *s;
size_t slen;
int i;
-
if (pdf->job_id_string != NULL)
return;
-
name_string = makecstring(job_name);
format_string = makecstring(format_ident);
- slen = SMALL_BUF_SIZE +
- strlen(name_string) + strlen(format_string) + strlen(luatex_banner);
+ slen = SMALL_BUF_SIZE + strlen(name_string) + strlen(format_string) + strlen(luatex_banner);
s = xtalloc(slen, char);
/* The Web2c version string starts with a space. */
- i = snprintf(s, slen,
- "%.4d/%.2d/%.2d %.2d:%.2d %s %s %s",
- year, month, day, time / 60, time % 60,
- name_string, format_string, luatex_banner);
+ i = snprintf(s, slen, "%.4d/%.2d/%.2d %.2d:%.2d %s %s %s", year, month, day, time / 60, time % 60, name_string, format_string, luatex_banner);
check_nprintf(i, slen);
pdf->job_id_string = xstrdup(s);
xfree(s);
@@ -1705,16 +1604,12 @@ void set_job_id(PDF pdf, int year, int month, int day, int time)
@ @c
char *get_resname_prefix(PDF pdf)
{
- static char name_str[] =
- "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
- static char prefix[7]; /* make a tag of 6 chars long */
- unsigned long crc;
+ static char name_str[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ static char prefix[7]; /* make a tag of 6 chars long */
short i;
size_t base = strlen(name_str);
- crc = crc32(0L, Z_NULL, 0);
- crc =
- crc32(crc, (Bytef *) pdf->job_id_string,
- (uInt) strlen(pdf->job_id_string));
+ unsigned long crc = crc32(0L, Z_NULL, 0);
+ crc = crc32(crc, (Bytef *) pdf->job_id_string, (uInt) strlen(pdf->job_id_string));
for (i = 0; i < 6; i++) {
prefix[i] = name_str[crc % base];
crc /= base;
@@ -1730,15 +1625,14 @@ void pdf_begin_page(PDF pdf)
{
pdffloat f;
int xform_attributes;
- scaled form_margin = 0; /* was one_bp until SVN4066 */
+ 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_create_obj(pdf, obj_type_others, 0);
+ pdf->page_resources->last_resources = pdf_create_obj(pdf, obj_type_others, 0);
reset_page_resources(pdf);
if (global_shipping_mode == SHIPPING_PAGE) {
@@ -1748,12 +1642,9 @@ void pdf_begin_page(PDF pdf)
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_obj(pdf, pdf_cur_form, OBJSTM_NEVER);
pdf->last_stream = pdf_cur_form;
-
/* Write out Form stream header */
pdf_begin_dict(pdf);
pdf_dict_add_name(pdf, "Type", "XObject");
@@ -1804,8 +1695,7 @@ void pdf_begin_page(PDF pdf)
pdf_puts(pdf, " 0 0 cm\n");
}
}
- pos_stack_used = 0; /* start with empty stack */
-
+ pos_stack_used = 0; /* start with empty stack */
if (global_shipping_mode == SHIPPING_PAGE) {
colorstackpagestart();
}
@@ -1820,9 +1710,9 @@ void print_pdf_table_string(PDF pdf, const char *s)
const char *ls;
lua_rawgeti(Luas, LUA_REGISTRYINDEX, lua_key_index(pdf_data));
lua_rawget(Luas, LUA_REGISTRYINDEX);
- lua_pushstring(Luas, s); /* s t ... */
- lua_rawget(Luas, -2); /* s? t ... */
- if (lua_type(Luas, -1) == LUA_TSTRING) { /* s t ... */
+ lua_pushstring(Luas, s); /* s t ... */
+ lua_rawget(Luas, -2); /* s? t ... */
+ if (lua_type(Luas, -1) == LUA_TSTRING) { /* s t ... */
ls = lua_tolstring(Luas, -1, &len);
if (len > 0) {
if (pdf->cave == 1)
@@ -1831,7 +1721,7 @@ void print_pdf_table_string(PDF pdf, const char *s)
pdf->cave = 1;
}
}
- lua_pop(Luas, 2); /* ... */
+ lua_pop(Luas, 2);
}
@ @c
@@ -1840,25 +1730,22 @@ const char *get_pdf_table_string(const char *s)
const_lstring ls;
lua_rawgeti(Luas, LUA_REGISTRYINDEX, lua_key_index(pdf_data));
lua_rawget(Luas, LUA_REGISTRYINDEX);
- lua_pushstring(Luas, s); /* s t ... */
- lua_rawget(Luas, -2); /* s? t ... */
- if (lua_type(Luas, -1) == LUA_TSTRING) { /* s t ... */
+ lua_pushstring(Luas, s); /* s t ... */
+ lua_rawget(Luas, -2); /* s? t ... */
+ if (lua_type(Luas, -1) == LUA_TSTRING) { /* s t ... */
ls.s = lua_tolstring(Luas, -1, &ls.l);
/*
s is supposed to be anchored (e.g in the registry)
so it's not garbage collected
*/
- lua_pop(Luas, 2); /* ... */
+ lua_pop(Luas, 2);
return ls.s;
}
- lua_pop(Luas, 2); /* ... */
+ lua_pop(Luas, 2);
return NULL ;
}
@ @c
-// #define pdf_page_attr equiv(pdf_page_attr_loc)
-// #define pdf_page_resources equiv(pdf_page_resources_loc)
-
void pdf_end_page(PDF pdf)
{
char s[64], *p;
@@ -1866,29 +1753,24 @@ void pdf_end_page(PDF pdf)
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 |pdf->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 xform_resources;
int page_resources, page_attributes;
int procset = PROCSET_PDF;
-
/* Finish stream of page/form contents */
pdf_goto_pagemode(pdf);
if (pos_stack_used > 0) {
- luatex_fail("%u unmatched 'save' after %s shipout", (unsigned int) pos_stack_used,
+ formatted_error("pdf backend","%u unmatched 'save' after %s shipout", (unsigned int) pos_stack_used,
((global_shipping_mode == SHIPPING_PAGE) ? "page" : "form"));
}
pdf_end_stream(pdf);
pdf_end_obj(pdf);
- /* hh-ls : new call back finish_pdfpage_callback */
callback_id = callback_defined(finish_pdfpage_callback);
if (callback_id > 0)
run_callback(callback_id, "b->",(global_shipping_mode == SHIPPING_PAGE));
-
if (global_shipping_mode == SHIPPING_PAGE) {
-
pdf->last_pages = pdf_do_page_divert(pdf, pdf->last_page, 0);
-
/* Write out /Page object */
pdf_begin_obj(pdf, pdf->last_page, OBJSTM_ALWAYS);
pdf_begin_dict(pdf);
@@ -1899,8 +1781,8 @@ void pdf_end_page(PDF pdf)
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_add_bp(pdf, pdf->page_size.h);
+ pdf_add_bp(pdf, pdf->page_size.v);
pdf_end_array(pdf);
page_attributes = pdf_page_attr ; /* lookup once */
if (page_attributes != null)
@@ -1908,7 +1790,6 @@ void pdf_end_page(PDF pdf)
print_pdf_table_string(pdf, "pageattributes");
pdf_dict_add_ref(pdf, "Parent", pdf->last_pages);
if (pdf->img_page_group_val != 0) {
- assert(pdf->img_page_group_val > 0);
pdf_dict_add_ref(pdf, "Group", pdf->img_page_group_val);
}
annot_list = get_page_resources_list(pdf, obj_type_annot);
@@ -1924,16 +1805,12 @@ void pdf_end_page(PDF pdf)
}
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, OBJSTM_ALWAYS);
pdf_begin_array(pdf);
while (annot_list != NULL) {
- assert(annot_list->info > 0);
pdf_add_ref(pdf, annot_list->info);
annot_list = annot_list->link;
}
@@ -1955,9 +1832,7 @@ void pdf_end_page(PDF pdf)
pdf_end_obj(pdf);
}
}
-
- /* Write out resource lists */
- /* Write out pending raw objects */
+ /* Write out resource lists and pending raw objects */
ol = get_page_resources_list(pdf, obj_type_obj);
while (ol != NULL) {
if (!is_obj_written(pdf, ol->info))
@@ -1965,11 +1840,11 @@ void pdf_end_page(PDF pdf)
ol = ol->link;
}
- /* 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 |pdf->page_size| is needed for proper
- writing out pending PDF marks. */
+ /*
+ When flushing pending forms we need to save and restore resource lists
+ which are also used by page shipping. 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)) {
@@ -1987,7 +1862,6 @@ void pdf_end_page(PDF pdf)
}
ol = ol->link;
}
-
/* Write out pending images */
ol = get_page_resources_list(pdf, obj_type_ximage);
while (ol != NULL) {
@@ -1995,14 +1869,12 @@ void pdf_end_page(PDF pdf)
pdf_write_image(pdf, ol->info);
ol = ol->link;
}
-
if (global_shipping_mode == SHIPPING_PAGE) {
- /* Write out pending PDF marks */
- /* Write out PDF annotations */
+ /* Write out pending PDF marks and annotations */
ol = get_page_resources_list(pdf, obj_type_annot);
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| */
+ j = obj_annot_ptr(pdf, ol->info); /* |j| points to |pdf_annot_node| */
pdf_begin_obj(pdf, ol->info, OBJSTM_ALWAYS);
pdf_begin_dict(pdf);
pdf_dict_add_name(pdf, "Type", "Annot");
@@ -2013,7 +1885,6 @@ void pdf_end_page(PDF pdf)
}
ol = ol->link;
}
-
/* Write out PDF link annotations */
if ((ol = get_page_resources_list(pdf, obj_type_link)) != NULL) {
while (ol != NULL) {
@@ -2037,19 +1908,19 @@ void pdf_end_page(PDF pdf)
ol = get_page_resources_list(pdf, obj_type_link);
while (ol != NULL) {
j = obj_annot_ptr(pdf, ol->info);
- /* nodes with |subtype = pdf_link_data_node| were created by |append_link| and
- must be flushed here, as they are not linked in any list */
+ /*
+ nodes with |subtype = pdf_link_data_node| were created by |append_link| and
+ must be flushed here, as they are not linked in any list
+ */
if (subtype(j) == pdf_link_data_node)
flush_node(j);
ol = ol->link;
}
}
-
/* Write out PDF mark destinations */
write_out_pdf_mark_destinations(pdf);
/* Write out PDF bead rectangle specifications */
print_bead_rectangles(pdf);
-
}
/* Write out resources dictionary */
pdf_begin_obj(pdf, res_p->last_resources, OBJSTM_ALWAYS);
@@ -2075,13 +1946,11 @@ void pdf_end_page(PDF pdf)
set_obj_xform_resources_str(pdf, pdf_cur_form, null);
}
}
-
/* Generate font resources */
if ((ol = get_page_resources_list(pdf, obj_type_font)) != NULL) {
pdf_add_name(pdf, "Font");
pdf_begin_dict(pdf);
while (ol != NULL) {
- assert(ol->info > 0); /* always base font: an object number */
p = s;
p += snprintf(p, 20, "F%i", obj_info(pdf, ol->info));
if (pdf->resname_prefix != NULL)
@@ -2092,7 +1961,6 @@ void pdf_end_page(PDF pdf)
pdf_end_dict(pdf);
procset |= PROCSET_TEXT;
}
-
/* Generate XObject resources */
ol = get_page_resources_list(pdf, obj_type_xform);
ol1 = get_page_resources_list(pdf, obj_type_ximage);
@@ -2118,7 +1986,6 @@ void pdf_end_page(PDF pdf)
}
pdf_end_dict(pdf);
}
-
/* Generate ProcSet */
pdf_add_name(pdf, "ProcSet");
pdf_begin_array(pdf);
@@ -2140,8 +2007,8 @@ void pdf_end_page(PDF pdf)
@* 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
-PDF browsers, so we need to fix them; they point to the last page.
+|obj_dest_ptr=null|. Leaving them undefined might cause troubles for PDF
+browsers, so we need to fix them; they point to the last page.
@c
static void check_nonexisting_destinations(PDF pdf)
@@ -2149,19 +2016,12 @@ static void check_nonexisting_destinations(PDF pdf)
int k;
for (k = pdf->head_tab[obj_type_dest]; k != 0; k = obj_link(pdf, k)) {
if (obj_dest_ptr(pdf, k) == null) {
- normal_warning("pdf backend", "dest ", false, false);
if (obj_info(pdf, k) < 0) {
- tprint("name{");
- print(-obj_info(pdf, k));
- tprint("}");
+ char *ss = makecstring(-obj_info(pdf, k));
+ formatted_warning("pdf backend", "unreferenced destination with name '%s'",ss);
} else {
- tprint("num");
- print_int(obj_info(pdf, k));
+ formatted_warning("pdf backend", "unreferenced destination with num '%d'",obj_info(pdf,k));
}
- tprint
- (" has been referenced but does not exist, replaced by a fixed one");
- print_ln();
- print_ln();
pdf_begin_obj(pdf, k, OBJSTM_ALWAYS);
pdf_begin_array(pdf);
@@ -2181,20 +2041,15 @@ static void check_nonexisting_pages(PDF pdf)
struct avl_table *page_tree = pdf->obj_tree[obj_type_page];
avl_t_init(&t, page_tree);
/* search from the end backward until the last real page is found */
- for (p = avl_t_last(&t, page_tree);
- p != NULL && obj_aux(pdf, p->objptr) == 0; p = avl_t_prev(&t)) {
- normal_warning("pdf backend", "Page ", false, false);
- print_int(obj_info(pdf, p->objptr));
- tprint(" has been referenced but does not exist!");
- print_ln();
- print_ln();
+ for (p = avl_t_last(&t, page_tree); p != NULL && obj_aux(pdf, p->objptr) == 0; p = avl_t_prev(&t)) {
+ formatted_warning("pdf backend", "page %s has been referenced but does not exist",obj_info(pdf, p->objptr));
}
}
@ If the same keys in a dictionary are given several times, then it is not
-defined which value is choosen by an application. Therefore the keys
-|/Producer| and |/Creator| are only set if the token list
-|pdf_info_toks| converted to a string does not contain these key strings.
+defined which value is choosen by an application. Therefore the keys |/Producer|
+and |/Creator| are only set if the token list |pdf_info_toks| converted to a
+string does not contain these key strings.
@c
static boolean substr_of_str(const char *s, const char *t)
@@ -2207,18 +2062,16 @@ static boolean substr_of_str(const char *s, const char *t)
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;
+ boolean creator_given = false;
+ boolean producer_given = false;
+ boolean creationdate_given = false;
+ boolean moddate_given = false;
+ boolean trapped_given = false;
char *s = NULL;
const char *p = NULL;
int k, len = 0;
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);
@@ -2283,8 +2136,8 @@ static int pdf_print_info(PDF pdf, int luatexversion,
static void build_free_object_list(PDF pdf)
{
- int k, l;
- l = 0;
+ int k;
+ int l = 0;
set_obj_fresh(pdf, l); /* null object at begin of list of free objects */
for (k = 1; k <= pdf->obj_ptr; k++) {
if (!is_obj_written(pdf, k)) {
@@ -2306,53 +2159,35 @@ void finish_pdf_file(PDF pdf, int luatexversion, str_number luatexrevision)
size_t xref_offset_width;
int callback_id = callback_defined(stop_run_callback);
int callback_id1 = callback_defined(finish_pdffile_callback);
-
if (total_pages == 0) {
if (callback_id == 0) {
- tprint_nl("No pages of output.");
- print_ln();
+ normal_warning("pdf backend","no pages of output.");
} else if (callback_id > 0) {
run_callback(callback_id, "->");
}
if (pdf->gone > 0)
- garbage_warning();
+ normal_error("pdf backend","dangling objects discarded, no output file produced.");
} else {
if (pdf->draftmode == 0) {
- pdf_flush(pdf); /* to make sure that the output file name has been already created */
- flush_jbig2_page0_objects(pdf); /* flush page 0 objects from JBIG2 images, if any */
+ 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)
run_callback(callback_id1, "->");
-
check_nonexisting_pages(pdf);
check_nonexisting_destinations(pdf);
-
/* Output fonts definition */
for (k = 1; k <= max_font_id(); k++) {
if (font_used(k) && (pdf_font_num(k) < 0)) {
i = -pdf_font_num(k);
- assert(pdf_font_num(i) > 0);
for (j = font_bc(k); j <= font_ec(k); j++)
if (quick_char_exists(k, j) && pdf_char_marked(k, j))
pdf_mark_char(i, j);
if ((pdf_font_attr(i) == 0) && (pdf_font_attr(k) != 0)) {
set_pdf_font_attr(i, pdf_font_attr(k));
- } else if ((pdf_font_attr(k) == 0)
- && (pdf_font_attr(i) != 0)) {
+ } else if ((pdf_font_attr(k) == 0) && (pdf_font_attr(i) != 0)) {
set_pdf_font_attr(k, pdf_font_attr(i));
- } else if ((pdf_font_attr(i) != 0)
- && (pdf_font_attr(k) != 0)
- &&
- (!str_eq_str
- (pdf_font_attr(i), pdf_font_attr(k)))) {
- normal_warning("pdf backend","fontattr in ", false, false);
- print_font_identifier(i);
- tprint(" and ");
- print_font_identifier(k);
- tprint(" have conflicting attributes; the attributes assigned to ");
- print_font_identifier(i);
- tprint(" are ignored");
- print_ln();
- print_ln();
+ } else if ((pdf_font_attr(i) != 0) && (pdf_font_attr(k) != 0) && (!str_eq_str(pdf_font_attr(i), pdf_font_attr(k)))) {
+ formatted_warning("pdf backend","fontattr of font %d and %d are conflicting, %k is used",i,k,i);
}
}
}
@@ -2360,25 +2195,22 @@ void finish_pdf_file(PDF pdf, int luatexversion, str_number luatexrevision)
k = pdf->head_tab[obj_type_font];
while (k != 0) {
int f = obj_info(pdf, k);
- assert(pdf_font_num(f) > 0);
- assert(pdf_font_num(f) == k);
do_pdf_font(pdf, f);
k = obj_link(pdf, k);
}
write_fontstuff(pdf);
-
pdf->last_pages = output_pages_tree(pdf);
- pdflua_output_pages_tree(pdf);
/* Output outlines */
outlines = print_outlines(pdf);
-
- /* Output name tree */
- /* The name tree is very similiar to Pages tree so its construction should be
- certain from Pages tree construction. For intermediate node |obj_info| will be
- the first name and |obj_link| will be the last name in \.{\\Limits} array.
- Note that |pdf_dest_names_ptr| will be less than |obj_ptr|, so we test if
- |k < pdf_dest_names_ptr| then |k| is index of leaf in |dest_names|; else
- |k| will be index in |obj_tab| of some intermediate node.
+ /*
+ Output name tree. The name tree is very similiar to Pages tree so
+ its construction should be certain from Pages tree construction.
+ For intermediate node |obj_info| will be the first name and
+ |obj_link| will be the last name in \.{\\Limits} array. Note that
+ |pdf_dest_names_ptr| will be less than |obj_ptr|, so we test if
+ |k < pdf_dest_names_ptr| then |k| is index of leaf in
+ |dest_names|; else |k| will be index in |obj_tab| of some
+ intermediate node.
*/
names_tree = output_name_tree(pdf);
@@ -2402,7 +2234,6 @@ void finish_pdf_file(PDF pdf, int luatexversion, str_number luatexrevision)
} else {
threads = 0;
}
-
/* Output the /Catalog object */
root = pdf_create_obj(pdf, obj_type_catalog, 0);
pdf_begin_obj(pdf, root, OBJSTM_ALWAYS);
@@ -2425,10 +2256,9 @@ void finish_pdf_file(PDF pdf, int luatexversion, str_number luatexrevision)
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, luatexversion, luatexrevision); /* 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_buffer_select(pdf, OBJSTM_BUF);
pdf_os_write_objstream(pdf);
@@ -2492,14 +2322,10 @@ void finish_pdf_file(PDF pdf, int luatexversion, str_number luatexrevision)
}
pdf_end_stream(pdf);
pdf_end_obj(pdf);
- /* TODO: generate a debug version of the crossref */
-
pdf_flush(pdf);
} else {
- /* Output the |obj_tab| */
- /* Build a linked list of free objects */
+ /* Output the |obj_tab| and build a linked list of free objects */
build_free_object_list(pdf);
-
pdf_save_offset(pdf);
pdf_puts(pdf, "xref\n");
pdf_puts(pdf, "0 ");
@@ -2515,9 +2341,7 @@ void finish_pdf_file(PDF pdf, int luatexversion, str_number luatexrevision)
pdf_puts(pdf, " 00000 n \n");
}
}
-
}
-
/* Output the trailer */
if (!pdf->os_enable) {
pdf_puts(pdf, "trailer\n");
@@ -2541,9 +2365,7 @@ void finish_pdf_file(PDF pdf, int luatexversion, str_number luatexrevision)
else
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);
@@ -2564,28 +2386,24 @@ void finish_pdf_file(PDF pdf, int luatexversion, str_number luatexrevision)
if (pdf->draftmode == 0)
close_file(pdf->file);
else
- normal_warning("pdf backend","draftmode enabled, not changing output pdf",true, true);
+ normal_warning("pdf backend","draftmode enabled, not changing output pdf");
}
-
if (callback_id == 0) {
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);
+ 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->ostm_ctr > 0) {
- fprintf(log_file,
- " %d compressed objects within %d object stream%s\n",
- (int) pdf->os->o_ctr, (int) pdf->os->ostm_ctr,
- (pdf->os->ostm_ctr > 1 ? "s" : ""));
+ fprintf(log_file, " %d compressed objects within %d object stream%s\n",
+ (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,
- (int) sup_dest_names_size);
- fprintf(log_file,
- " %d words of extra memory for PDF output out of %d (max. %d)\n",
- (int) pdf->mem_ptr, (int) pdf->mem_size,
- (int) sup_pdf_mem_size);
+ (int) pdf->dest_names_ptr, (int) pdf->dest_names_size,
+ (int) sup_dest_names_size);
+ fprintf(log_file, " %d words of extra memory for PDF output out of %d (max. %d)\n",
+ (int) pdf->mem_ptr, (int) pdf->mem_size,
+ (int) sup_pdf_mem_size);
}
}
}
@@ -2594,7 +2412,7 @@ void finish_pdf_file(PDF pdf, int luatexversion, str_number luatexrevision)
void scan_pdfcatalog(PDF pdf)
{
halfword p;
- scan_pdf_ext_toks();
+ scan_toks(false, true);
pdf_catalog_toks = concat_tokens(pdf_catalog_toks, def_ref);
if (scan_keyword("openaction")) {
if (pdf_catalog_openaction != 0) {
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.h b/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.h
index 37766d26c8f..2d04e944c6e 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.h
@@ -15,8 +15,8 @@
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/>.
+*/
#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 1f8319484e2..93096d025e5 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w
@@ -19,24 +19,22 @@
@ @c
-
#include "ptexlib.h"
#include "pdf/pdfpage.h"
#define pdf2double(a) ((double) (a).m / ten_pow[(a).e])
@ eternal constants
+
@c
-#define one_bp ((double) 65536 * (double) 72.27 / 72) /* number of sp per 1bp */
-#define e_tj 3 /* must be 3; movements in []TJ are in fontsize/$10^3$ units */
+#define one_bp ((double) 65536 * (double) 72.27 / 72) /* number of sp per 1bp */
+#define e_tj 3 /* must be 3; movements in []TJ are in fontsize/$10^3$ units */
@ @c
static int64_t pdf_char_width(pdfstructure * p, internal_font_number f, int i)
{
/* use exactly this formula also for calculating the /Width array values */
- return
- i64round((double) char_width(f, i) / font_size(f) *
- ten_pow[e_tj + p->cw.e]);
+ return i64round((double) char_width(f, i) / font_size(f) * ten_pow[e_tj + p->cw.e]);
}
@ @c
@@ -56,9 +54,7 @@ static void setup_fontparameters(PDF pdf, internal_font_number f, int ex_glyph)
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)
+ if ((font_format(f) == opentype_format || (font_format(f) == type1_format && font_encodingbytes(f) == 2)) && font_units_per_em(f) > 0)
u = font_units_per_em(f) / 1000.0;
pdf->f_cur = f;
p->f_pdf = pdf_set_font(pdf, f);
@@ -68,19 +64,14 @@ static void setup_fontparameters(PDF pdf, internal_font_number f, int ex_glyph)
expand = 1.0 + (ex_glyph/1) / 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)
+ 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 = i64round(scale * expand * extend * ten_pow[p->tm[0].e]);
p->tm[2].m = i64round(slant * ten_pow[p->tm[2].e]);
p->tm[3].m = i64round(scale * ten_pow[p->tm[3].e]);
- p->k2 =
- ten_pow[e_tj +
- p->cw.e] * scale / (ten_pow[p->pdf.h.e] * pdf2double(p->fs) *
- pdf2double(p->tm[0]));
+ p->k2 = ten_pow[e_tj + p->cw.e] * scale / (ten_pow[p->pdf.h.e] * pdf2double(p->fs) * pdf2double(p->tm[0]));
p->cur_ex = ex_glyph ; /* we keep track of the state of ex */
-}
+}
@ @c
@@ -95,7 +86,7 @@ static void set_font(PDF pdf)
p->f_pdf_cur = p->f_pdf;
p->fs_cur.m = p->fs.m;
p->need_tf = false;
- p->need_tm = true; /* always follow Tf by Tm */
+ p->need_tm = true; /* always follow Tf by Tm */
}
@ @c
@@ -103,12 +94,13 @@ static void set_textmatrix(PDF pdf, scaledpos pos)
{
boolean move;
pdfstructure *p = pdf->pstruct;
- assert(is_textmode(p));
+ if (!is_textmode(p))
+ normal_error("pdf backend","text mode expected in set_textmatrix");
move = calc_pdfpos(p, pos);
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.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 = false;
}
@@ -118,6 +110,7 @@ static void set_textmatrix(PDF pdf, scaledpos pos)
@ 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)
{
@@ -144,7 +137,8 @@ static void pdf_print_wide_char(PDF pdf, int c)
@ @c
static void begin_charmode(PDF pdf, internal_font_number f, pdfstructure * p)
{
- assert(is_chararraymode(p));
+ if (!is_chararraymode(p))
+ normal_error("pdf backend","char array mode expected in begin_char_mode");
if (font_encodingbytes(f) == 2) {
p->ishex = 1;
pdf_out(pdf, '<');
@@ -159,7 +153,8 @@ static void begin_charmode(PDF pdf, internal_font_number f, pdfstructure * p)
void end_charmode(PDF pdf)
{
pdfstructure *p = pdf->pstruct;
- assert(is_charmode(p));
+ if (!is_charmode(p))
+ normal_error("pdf backend","char mode expected in end_char_mode");
if (p->ishex == 1) {
p->ishex = 0;
pdf_out(pdf, '>');
@@ -173,7 +168,8 @@ void end_charmode(PDF pdf)
static void begin_chararray(PDF pdf)
{
pdfstructure *p = pdf->pstruct;
- assert(is_textmode(p));
+ if (!is_textmode(p))
+ normal_error("pdf backend","text mode expected in begin_char_array");
p->pdf_tj_pos = p->pdf;
p->cw.m = 0;
pdf_out(pdf, '[');
@@ -184,58 +180,28 @@ static void begin_chararray(PDF pdf)
void end_chararray(PDF pdf)
{
pdfstructure *p = pdf->pstruct;
- assert(is_chararraymode(p));
+ if (!is_chararraymode(p))
+ normal_error("pdf backend","char array mode expected in end_char_array");
pdf_puts(pdf, "]TJ\n");
p->pdf = p->pdf_tj_pos;
p->mode = PMODE_TEXT;
}
-@ @c
+@ We need to adapt the tm when a font changes. A change can be a change in id
+(frontend) or pdf reference (backend, as we share font resources). At such a
+change we also need to adapt to the slant and extend. Initially we also need to
+take the exfactor of a glyph into account. When the font is unchanged, we still
+need to check each glyph for a change in exfactor. We store the current one on
+the state record so that we can minimize testing.
+
+@c
void pdf_place_glyph(PDF pdf, internal_font_number f, int c, int ex)
{
boolean move;
pdfstructure *p = pdf->pstruct;
scaledpos pos = pdf->posstruct->pos;
-
if (!char_exists(f, c))
return;
-
-/*
- p->need_tf : okay, set somewhere else
- f != pdf->f_cur : font change
- p->f_pdf != p->f_pdf_cur : font change
- p->fs.m ~= p->fs_cur.m : move
- is_pagemode(p) -> stream change
- p->tm0_cur.m -> p->tm[0].m : also move
-*/
-
- /* fix issue 857 */
- /* /\* ensure to be within BT...ET *\/ */
- /* if (is_pagemode(p)) { */
- /* pdf_goto_textmode(pdf); */
- /* p->need_tf = true; */
- /* } */
- /* /\* all font setup *\/ */
- /* if (true || f != pdf->f_cur || p->need_tf) { */
- /* setup_fontparameters(pdf, f, ex); */
- /* 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); */
- /* } else if (p->tm0_cur.m != p->tm[0].m) { */
- /* /\* catch in-line HZ expand change due to efcode *\/ */
- /* p->need_tm = true; */
- /* } */
- /* } */
-
-
- /* LS/HH: We need to adapt the tm when a font changes. A change can be a change in
- id (frontend) or pdf reference (backend, as we share font resources). At
- such a change we also need to adapt to the slant and extend. Initially
- we also need to take the exfactor of a glyph into account. When the font is
- unchanged, we still need to check each glyph for a change in exfactor. We
- store the current one on the state record so that we can minimize testing. */
-
- /* is the p->need_tf test really needed ? */
if (p->need_tf || f != pdf->f_cur || p->f_pdf != p->f_pdf_cur || p->fs.m != p->fs_cur.m || is_pagemode(p)) {
pdf_goto_textmode(pdf);
setup_fontparameters(pdf, f, ex);
@@ -243,37 +209,30 @@ void pdf_place_glyph(PDF pdf, internal_font_number f, int c, int ex)
} else if (p->tm0_cur.m != p->tm[0].m || p->cur_ex != ex) {
setup_fontparameters(pdf, f, ex);
p->need_tm = true;
- }
-
+ }
/* 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) {
+ 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); /* for fine adjustment */
}
if (move) {
- assert((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));
if (is_charmode(p))
end_charmode(pdf);
- assert(p->tj_delta.m != 0);
print_pdffloat(pdf, p->tj_delta);
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);
+ else if (!is_charmode(p))
+ normal_error("pdf backend","char (array) mode expected in place_glyph");
pdf_mark_char(f, c);
if (font_encodingbytes(f) == 2)
pdf_print_wide_char(pdf, char_index(f, c));
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfimage.h b/Build/source/texk/web2c/luatexdir/pdf/pdfimage.h
index c4f5f53aecb..b5b8718393e 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfimage.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfimage.h
@@ -15,8 +15,9 @@
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/>.
+*/
#ifndef PDFIMAGE_H
# define PDFIMAGE_H
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfimage.w b/Build/source/texk/web2c/luatexdir/pdf/pdfimage.w
index 29795990eab..fd364243804 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfimage.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfimage.w
@@ -19,7 +19,6 @@
@ @c
-
#include "ptexlib.h"
@ @c
@@ -34,8 +33,6 @@ void place_img(PDF pdf, image_dict * idict, scaled_whd dim, int transform)
scaledpos tmppos;
pdffloat cm[6];
int groupref; /* added from web for 1.40.8 */
- assert(idict != 0);
- assert(p != NULL);
a[0] = a[3] = 1.0e6;
a[1] = a[2] = 0;
if (img_type(idict) == IMG_TYPE_PDF || img_type(idict) == IMG_TYPE_PDFMEMSTREAM
@@ -58,7 +55,7 @@ void place_img(PDF pdf, image_dict * idict, scaled_whd dim, int transform)
xoff = yoff = 0;
r = 4;
}
- if ((transform & 7) > 3) { // mirror cases
+ if ((transform & 7) > 3) { /* mirror cases */
a[0] *= -1;
xoff *= -1;
}
@@ -146,7 +143,6 @@ void pdf_place_image(PDF pdf, halfword p)
{
scaled_whd dim;
image_dict *idict = idict_array[rule_index(p)];
- assert(idict != NULL);
dim.wd = width(p);
dim.ht = height(p);
dim.dp = depth(p);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdflink.h b/Build/source/texk/web2c/luatexdir/pdf/pdflink.h
index b7103aec56e..5b3d2042a80 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdflink.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdflink.h
@@ -15,13 +15,13 @@
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/>.
+*/
#ifndef PDFLINK_H
# define PDFLINK_H
-# define set_pdf_link_attr(A,B) pdf_link_attr(A)=B
+# define set_pdf_link_attr(A,B) pdf_link_attr(A)=B
# define set_pdf_link_action(A,B) pdf_link_action(A)=B
# define set_pdf_link_objnum(A,B) pdf_link_objnum(A)=B
@@ -29,9 +29,7 @@ extern void push_link_level(PDF pdf, halfword p);
extern void pop_link_level(PDF pdf);
extern void do_link(PDF pdf, halfword p, halfword parent_box, scaledpos cur);
extern void end_link(PDF pdf, halfword p);
-extern void append_link(PDF pdf, halfword parent_box, scaledpos cur,
- small_number i);
-
+extern void append_link(PDF pdf, halfword parent_box, scaledpos cur, small_number i);
extern void scan_startlink(PDF pdf);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdflink.w b/Build/source/texk/web2c/luatexdir/pdf/pdflink.w
index 89fb1057567..b21d0774ecd 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdflink.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdflink.w
@@ -19,7 +19,6 @@
@ @c
-
#include "ptexlib.h"
@ To implement nested link annotations, we need a stack to hold copy of
@@ -31,7 +30,6 @@ void push_link_level(PDF pdf, halfword p)
{
if (pdf->link_stack_ptr >= pdf_max_link_level)
overflow("pdf link stack size", pdf_max_link_level);
- assert(((type(p) == whatsit_node) && (subtype(p) == pdf_start_link_node)));
pdf->link_stack_ptr++;
pdf->link_stack[pdf->link_stack_ptr].nesting_level = cur_s;
pdf->link_stack[pdf->link_stack_ptr].link_node = copy_node_list(p);
@@ -41,7 +39,6 @@ void push_link_level(PDF pdf, halfword p)
@ @c
void pop_link_level(PDF pdf)
{
- assert(pdf->link_stack_ptr > 0);
flush_node_list(pdf->link_stack[pdf->link_stack_ptr].link_node);
pdf->link_stack_ptr--;
}
@@ -54,8 +51,7 @@ void do_link(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
if (type(p) == vlist_node)
normal_error("pdf backend", "'startlink' ended up in vlist");
if (global_shipping_mode == SHIPPING_FORM)
- normal_error("pdf backend", "link annotations cannot be inside an XForm");
- assert(type(parent_box) == hlist_node);
+ normal_error("pdf backend", "link annotations cannot be inside an xform");
if (is_obj_scheduled(pdf, pdf_link_objnum(p)))
pdf_link_objnum(p) = pdf_create_obj(pdf, obj_type_others, 0);
push_link_level(pdf, p);
@@ -80,32 +76,34 @@ void end_link(PDF pdf, halfword p)
normal_error("pdf backend","pdf link_stack empty, 'endlink' used without 'startlink'");
if (pdf->link_stack[pdf->link_stack_ptr].nesting_level != cur_s)
normal_error("pdf backend","'endlink' ended up in different nesting level than 'startlink'");
-
- /* N.B.: test for running link must be done on |link_node| and not |ref_link_node|,
- as |ref_link_node| can be set by |do_link| or |append_link| already */
-
+ /*
+ NOTA BENE: test for running link must be done on |link_node| and not
+ |ref_link_node|, as |ref_link_node| can be set by |do_link| or
+ |append_link| already
+ */
if (is_running(width(pdf->link_stack[pdf->link_stack_ptr].link_node))) {
q = pdf->link_stack[pdf->link_stack_ptr].ref_link_node;
if (global_shipping_mode == SHIPPING_PAGE && matrixused()) {
- matrixrecalculate(pos.h + pdf_link_margin);
+ matrixrecalculate(pos.h + pdf_link_margin);
pdf_ann_left(q) = getllx() - pdf_link_margin;
pdf_ann_top(q) = getlly() - pdf_link_margin;
pdf_ann_right(q) = geturx() + pdf_link_margin;
pdf_ann_bottom(q) = getury() + pdf_link_margin;
} else {
switch (pdf->posstruct->dir) {
- case dir_TLT:
- pdf_ann_right(q) = pos.h + pdf_link_margin;
- break;
- case dir_TRT:
- pdf_ann_left(q) = pos.h - pdf_link_margin;
- break;
- case dir_LTL:
- case dir_RTT:
- pdf_ann_bottom(q) = pos.v - pdf_link_margin;
- break;
- default:
- assert(0);
+ case dir_TLT:
+ pdf_ann_right(q) = pos.h + pdf_link_margin;
+ break;
+ case dir_TRT:
+ pdf_ann_left(q) = pos.h - pdf_link_margin;
+ break;
+ case dir_LTL:
+ case dir_RTT:
+ pdf_ann_bottom(q) = pos.v - pdf_link_margin;
+ break;
+ default:
+ pdf_ann_right(q) = pos.h + pdf_link_margin;
+ formatted_warning("pdf backend","forcing bad dir %i to TLT in link",pdf->posstruct->dir);
}
}
}
@@ -114,10 +112,9 @@ void end_link(PDF pdf, halfword p)
@ 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
-|info| field is |max_halfword|. We set |info| field just before destroying the
-node, in order to use |flush_node_list| to do the job.
-
+corresponding whatsit node representing the start of annotation, but its |info|
+field is |max_halfword|. We set |info| field just before destroying the node, in
+order to use |flush_node_list| to do the job.
@ Append a new pdf annot to |pdf_link_list|.
@@ -127,7 +124,6 @@ void append_link(PDF pdf, halfword parent_box, scaledpos cur, small_number i)
halfword p;
int k;
scaled_whd alt_rule;
- assert(type(parent_box) == hlist_node);
p = copy_node(pdf->link_stack[(int) i].link_node);
pdf->link_stack[(int) i].ref_link_node = p;
subtype(p) = pdf_link_data_node; /* this node is not a normal link node */
@@ -152,14 +148,17 @@ void scan_startlink(PDF pdf)
new_annot_whatsit(pdf_start_link_node);
set_pdf_link_attr(cur_list.tail_field, null);
if (scan_keyword("attr")) {
- scan_pdf_ext_toks();
+ scan_toks(false, true);
set_pdf_link_attr(cur_list.tail_field, def_ref);
}
r = scan_action(pdf);
set_pdf_link_action(cur_list.tail_field, r);
set_pdf_link_objnum(cur_list.tail_field, k);
pdf_last_link = k;
- /* N.B.: although it is possible to set |obj_annot_ptr(k) := tail| here, it
- is not safe if nodes are later copied/destroyed/moved; a better place
- to do this is inside |do_link|, when the whatsit node is written out */
+ /*
+ NOTA BENE: although it is possible to set |obj_annot_ptr(k) := tail|
+ here, it is not safe if nodes are later copied/destroyed/moved; a better
+ place to do this is inside |do_link|, when the whatsit node is written
+ out
+ */
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdflistout.h b/Build/source/texk/web2c/luatexdir/pdf/pdflistout.h
index 646a26b855a..76c1d552f1a 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdflistout.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdflistout.h
@@ -15,24 +15,23 @@
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/>.
+*/
#ifndef PDFLISTOUT_H
# define PDFLISTOUT_H
-/* a few small helpers */
# define pos_right(A) pdf->posstruct->pos.h = pdf->posstruct->pos.h + (A)
# define pos_left(A) pdf->posstruct->pos.h = pdf->posstruct->pos.h - (A)
# define pos_up(A) pdf->posstruct->pos.v = pdf->posstruct->pos.v + (A)
# define pos_down(A) pdf->posstruct->pos.v = pdf->posstruct->pos.v - (A)
-typedef void (*backend_function) (); /* variadic arguments */
+typedef void (*backend_function) (); /* variadic arguments */
typedef struct {
- char *name; /* name of the backend */
- backend_function *node_fu; /* array of node output functions */
- backend_function *whatsit_fu; /* array of whatsit output functions */
+ char *name; /* name of the backend */
+ backend_function *node_fu; /* array of node output functions */
+ backend_function *whatsit_fu; /* array of whatsit output functions */
} backend_struct;
extern pos_info_structure pos_info;
@@ -42,8 +41,8 @@ extern backend_function *backend_out_whatsit;
extern void init_backend_functionpointers(output_mode o_mode);
-extern void hlist_out(PDF pdf, halfword this_box);
-extern void vlist_out(PDF pdf, halfword this_box);
+extern void hlist_out(PDF pdf, halfword this_box, int rule_callback_id);
+extern void vlist_out(PDF pdf, halfword this_box, int rule_callback_id);
extern void out_what(PDF pdf, halfword p);
#endif
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w b/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w
index bf32cb8c629..2bd15f3cedf 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w
@@ -31,21 +31,11 @@ backend_function *backend_out, *backend_out_whatsit;
@ @c
static void missing_backend_function(PDF pdf, halfword p)
{
- char *b;
- const char *s;
- const char *n;
- char backend_string[15];
- char err_string[60];
- assert(backend != NULL);
+ const char *n = get_node_name(type(p), subtype(p));
if (type(p) == whatsit_node)
- s = "whatsit";
+ formatted_error("pdf backend","no output function for whatsit %s",n);
else
- s = "node";
- n = get_node_name(type(p), subtype(p));
- b = backend[output_mode_used].name;
- snprintf(backend_string, strlen(b) + 10, "%s back-end", b);
- snprintf(err_string, 59, "no output function for \"%s\" %s", n, s);
- normal_error(backend_string, err_string);
+ formatted_error("pdf backend","no output function for node %s",n);
}
@ @c
@@ -89,7 +79,6 @@ static void init_dvi_backend_functions(void)
p->whatsit_fu[late_lua_node] = &late_lua;
}
-
@ @c
void init_backend_functionpointers(output_mode o_mode)
{
@@ -126,22 +115,22 @@ static scaled simple_advance_width(halfword p)
while ((q != null) && (vlink(q) != null)) {
q = vlink(q);
switch (type(q)) {
- case glyph_node:
- w += glyph_width(q);
- break;
- case hlist_node:
- case vlist_node:
- case rule_node:
- case margin_kern_node:
- case kern_node:
- w += width(q);
- break;
- case disc_node:
- /* hh: the frontend should append already */
- if (vlink(no_break(q)) != null)
- w += simple_advance_width(no_break(q));
- default:
- break;
+ case glyph_node:
+ w += glyph_width(q);
+ break;
+ case hlist_node:
+ case vlist_node:
+ case rule_node:
+ case margin_kern_node:
+ case kern_node:
+ w += width(q);
+ break;
+ case disc_node:
+ /* hh: the frontend should append already */
+ if (vlink(no_break(q)) != null)
+ w += simple_advance_width(no_break(q));
+ default:
+ break;
}
}
return w;
@@ -163,60 +152,60 @@ static halfword calculate_width_to_enddir(halfword p, real cur_glue, scaled cur_
w += pack_width(box_dir(this_box), dir_TRT, q, true);
else {
switch (type(q)) {
- case hlist_node:
- case vlist_node:
- w += pack_width(box_dir(this_box), box_dir(q), q, false);
- break;
- case rule_node:
- case margin_kern_node:
- case kern_node:
- w += width(q);
- break;
- case math_node:
- /* begin mathskip code */
- if (glue_ptr(q) == zero_glue) {
- w += surround(q);
+ case hlist_node:
+ case vlist_node:
+ w += pack_width(box_dir(this_box), box_dir(q), q, false);
break;
- } else {
- /* fall through: mathskip */
- }
- /* end mathskip code */
- case glue_node:
- g = glue_ptr(q);
- w += width(g) - cur_g;
- if (g_sign != normal) {
- if (g_sign == stretching) {
- if (stretch_order(g) == g_order) {
- cur_glue = cur_glue + stretch(g);
+ case rule_node:
+ case margin_kern_node:
+ case kern_node:
+ w += width(q);
+ break;
+ case math_node:
+ /* begin mathskip code */
+ if (glue_ptr(q) == zero_glue) {
+ w += surround(q);
+ break;
+ } else {
+ /* fall through: mathskip */
+ }
+ /* end mathskip code */
+ case glue_node:
+ g = glue_ptr(q);
+ w += width(g) - cur_g;
+ if (g_sign != normal) {
+ if (g_sign == stretching) {
+ if (stretch_order(g) == g_order) {
+ cur_glue = cur_glue + stretch(g);
+ vet_glue(float_cast(glue_set(this_box)) * cur_glue);
+ cur_g = float_round(glue_temp);
+ }
+ } else if (shrink_order(g) == g_order) {
+ cur_glue = cur_glue - shrink(g);
vet_glue(float_cast(glue_set(this_box)) * cur_glue);
cur_g = float_round(glue_temp);
}
- } else if (shrink_order(g) == g_order) {
- cur_glue = cur_glue - shrink(g);
- vet_glue(float_cast(glue_set(this_box)) * cur_glue);
- cur_g = float_round(glue_temp);
}
- }
- w += cur_g;
- break;
- case disc_node:
- /* hh: the frontend should append already */
- if (vlink(no_break(q)) != null)
- w += simple_advance_width(no_break(q));
- break;
- case dir_node:
- if (dir_dir(q) >= 0)
- dir_nest++;
- else
- dir_nest--;
- if (dir_nest == 0) {
- enddir_ptr = q;
- dir_cur_h(enddir_ptr) = w;
- q = null;
- }
- break;
- default:
- break;
+ w += cur_g;
+ break;
+ case disc_node:
+ /* hh: the frontend should append already */
+ if (vlink(no_break(q)) != null)
+ w += simple_advance_width(no_break(q));
+ break;
+ case dir_node:
+ if (dir_dir(q) >= 0)
+ dir_nest++;
+ else
+ dir_nest--;
+ if (dir_nest == 0) {
+ enddir_ptr = q;
+ dir_cur_h(enddir_ptr) = w;
+ q = null;
+ }
+ break;
+ default:
+ break;
}
}
}
@@ -237,56 +226,55 @@ implementations, due to machine-dependent rounding in the glue calculations.)
@c
void out_what(PDF pdf, halfword p)
{
- switch (subtype(p)) { /* function(pdf, p) */
- case special_node: /* |pdf_special(pdf, p)|; */
- case late_lua_node: /* |late_lua(pdf, p)|; */
- case pdf_save_node: /* |pdf_out_save(pdf, p)|; */
- case pdf_restore_node: /* |pdf_out_restore(pdf, p)|; */
- case pdf_end_link_node: /* |end_link(pdf, p)|; */
- case pdf_end_thread_node: /* |end_thread(pdf, p)|; */
- case pdf_literal_node: /* |pdf_out_literal(pdf, p)|; */
- case pdf_colorstack_node: /* |pdf_out_colorstack(pdf, p)|; */
- case pdf_setmatrix_node: /* |pdf_out_setmatrix(pdf, p)|; */
- case pdf_refobj_node: /* |pdf_ref_obj(pdf, p)| */
- backend_out_whatsit[subtype(p)] (pdf, p);
- break;
- case open_node:
- case write_node:
- case close_node:
- /* do some work that has been queued up for \.{\\write} */
- if (!doing_leaders) {
- int j = write_stream(p);
- if (subtype(p) == write_node) {
- write_out(p);
- } else if (subtype(p) == close_node) {
- close_write_file(j);
- } else if (valid_write_file(j)) {
- char *fn;
- close_write_file(j);
- cur_name = open_name(p);
- cur_area = open_area(p);
- cur_ext = open_ext(p);
- if (cur_ext == get_nullstr())
- cur_ext = maketexstring(".tex");
- fn = pack_file_name(cur_name, cur_area, cur_ext);
- while (! open_write_file(j,fn)) {
- fn = prompt_file_name("output file name", ".tex");
+ switch (subtype(p)) {
+ case special_node: /* |pdf_special(pdf, p)|; */
+ case late_lua_node: /* |late_lua(pdf, p)|; */
+ case pdf_save_node: /* |pdf_out_save(pdf, p)|; */
+ case pdf_restore_node: /* |pdf_out_restore(pdf, p)|; */
+ case pdf_end_link_node: /* |end_link(pdf, p)|; */
+ case pdf_end_thread_node: /* |end_thread(pdf, p)|; */
+ case pdf_literal_node: /* |pdf_out_literal(pdf, p)|; */
+ case pdf_colorstack_node: /* |pdf_out_colorstack(pdf, p)|; */
+ case pdf_setmatrix_node: /* |pdf_out_setmatrix(pdf, p)|; */
+ case pdf_refobj_node: /* |pdf_ref_obj(pdf, p)| */
+ backend_out_whatsit[subtype(p)] (pdf, p);
+ break;
+ case open_node:
+ case write_node:
+ case close_node:
+ /* do some work that has been queued up for \.{\\write} */
+ if (!doing_leaders) {
+ int j = write_stream(p);
+ if (subtype(p) == write_node) {
+ write_out(p);
+ } else if (subtype(p) == close_node) {
+ close_write_file(j);
+ } else if (valid_write_file(j)) {
+ char *fn;
+ close_write_file(j);
+ cur_name = open_name(p);
+ cur_area = open_area(p);
+ cur_ext = open_ext(p);
+ if (cur_ext == get_nullstr())
+ cur_ext = maketexstring(".tex");
+ fn = pack_file_name(cur_name, cur_area, cur_ext);
+ while (! open_write_file(j,fn)) {
+ fn = prompt_file_name("output file name", ".tex");
+ }
}
}
- }
- break;
- case user_defined_node:
- break;
- default:
- /* this should give an error about missing whatsit backend function */
- backend_out_whatsit[subtype(p)] (pdf, p);
+ break;
+ case user_defined_node:
+ break;
+ default:
+ /* this should give an error about missing whatsit backend function */
+ backend_out_whatsit[subtype(p)] (pdf, p);
}
}
@ @c
-void hlist_out(PDF pdf, halfword this_box)
+void hlist_out(PDF pdf, halfword this_box, int rule_callback_id)
{
-
posstructure localpos; /* the position structure local within this function */
posstructure *refpos; /* the list origin pos. on the page, provided by the caller */
scaledpos cur = { 0, 0 }, tmpcur, basepoint;
@@ -333,7 +321,6 @@ void hlist_out(PDF pdf, halfword this_box)
}
for (i = 1; i <= pdf->link_stack_ptr; i++) {
- assert(is_running(width(pdf->link_stack[i].link_node)));
if (pdf->link_stack[i].nesting_level == cur_s)
append_link(pdf, this_box, cur, (small_number) i);
}
@@ -362,302 +349,305 @@ void hlist_out(PDF pdf, halfword this_box)
} else {
/* output the non-|char_node| |p| for |hlist_out| and move to the next node */
switch (type(p)) {
- case hlist_node:
- case vlist_node:
- if (textdir_parallel(box_dir(p), localpos.dir)) {
- effective_horizontal = width(p);
- basepoint.v = 0;
- if (textdir_opposite(box_dir(p), localpos.dir))
- basepoint.h = width(p);
- else
- basepoint.h = 0;
- } else {
- effective_horizontal = height(p) + depth(p);
- if (!is_mirrored(box_dir(p))) {
- if (partextdir_eq(box_dir(p), localpos.dir))
- basepoint.h = height(p);
+ case hlist_node:
+ case vlist_node:
+ if (textdir_parallel(box_dir(p), localpos.dir)) {
+ effective_horizontal = width(p);
+ basepoint.v = 0;
+ if (textdir_opposite(box_dir(p), localpos.dir))
+ basepoint.h = width(p);
else
- basepoint.h = depth(p);
+ basepoint.h = 0;
} else {
- if (partextdir_eq(box_dir(p), localpos.dir))
- basepoint.h = depth(p);
- else
- basepoint.h = height(p);
+ effective_horizontal = height(p) + depth(p);
+ if (!is_mirrored(box_dir(p))) {
+ if (partextdir_eq(box_dir(p), localpos.dir))
+ basepoint.h = height(p);
+ else
+ basepoint.h = depth(p);
+ } else {
+ if (partextdir_eq(box_dir(p), localpos.dir))
+ basepoint.h = depth(p);
+ else
+ basepoint.h = height(p);
+ }
+ if (is_rotated(localpos.dir)) {
+ if (partextdir_eq(localpos.dir, box_dir(p)))
+ basepoint.v = -width(p) / 2; /* up */
+ else
+ basepoint.v = width(p) / 2; /* down */
+ } else if (is_mirrored(localpos.dir)) {
+ if (partextdir_eq(localpos.dir, box_dir(p)))
+ basepoint.v = 0;
+ else
+ basepoint.v = width(p); /* down */
+ } else {
+ if (partextdir_eq(localpos.dir, box_dir(p)))
+ basepoint.v = -width(p); /* up */
+ else
+ basepoint.v = 0;
+ }
}
- if (is_rotated(localpos.dir)) {
- if (partextdir_eq(localpos.dir, box_dir(p)))
- basepoint.v = -width(p) / 2; /* up */
- else
- basepoint.v = width(p) / 2; /* down */
- } else if (is_mirrored(localpos.dir)) {
- if (partextdir_eq(localpos.dir, box_dir(p)))
- basepoint.v = 0;
- else
- basepoint.v = width(p); /* down */
+ if (!is_mirrored(localpos.dir))
+ basepoint.v = basepoint.v + shift_amount(p); /* shift the box down */
+ else
+ basepoint.v = basepoint.v - shift_amount(p); /* shift the box up */
+ if (list_ptr(p) == null) {
+ if (synctex) {
+ if (type(p) == vlist_node)
+ synctexvoidvlist(p, this_box);
+ else
+ synctexvoidhlist(p, this_box);
+ }
} else {
- if (partextdir_eq(localpos.dir, box_dir(p)))
- basepoint.v = -width(p); /* up */
- else
- basepoint.v = 0;
- }
- }
- if (!is_mirrored(localpos.dir))
- basepoint.v = basepoint.v + shift_amount(p); /* shift the box down */
- else
- basepoint.v = basepoint.v - shift_amount(p); /* shift the box up */
- if (list_ptr(p) == null) {
- if (synctex) {
+ tmpcur.h = cur.h + basepoint.h;
+ tmpcur.v = basepoint.v;
+ synch_pos_with_cur(pdf->posstruct, refpos, tmpcur);
if (type(p) == vlist_node)
- synctexvoidvlist(p, this_box);
+ vlist_out(pdf, p, rule_callback_id);
else
- synctexvoidhlist(p, this_box);
+ hlist_out(pdf, p, rule_callback_id);
}
- } else {
- assert(cur.v == 0);
- tmpcur.h = cur.h + basepoint.h;
- tmpcur.v = basepoint.v;
- synch_pos_with_cur(pdf->posstruct, refpos, tmpcur);
- if (type(p) == vlist_node)
- vlist_out(pdf, p);
- else
- hlist_out(pdf, p);
- }
- cur.h += effective_horizontal;
- break;
- case disc_node:
- /* hh: the frontend should append already */
- if (vlink(no_break(p)) != null) {
- if (subtype(p) != select_disc) {
- q = tail_of_list(vlink(no_break(p))); /* this could be a tlink */
- vlink(q) = vlink(p);
- q = vlink(no_break(p));
- vlink(no_break(p)) = null;
- vlink(p) = q;
- }
- }
- break;
- case rule_node:
- if (rule_dir(p) < 0)
- rule_dir(p) = localpos.dir;
- if (pardir_parallel(rule_dir(p), localpos.dir)) {
- rule.ht = height(p);
- rule.dp = depth(p);
- rule.wd = width(p);
- } else {
- rule.ht = width(p) / 2;
- rule.dp = width(p) / 2;
- rule.wd = height(p) + depth(p);
- }
- goto FIN_RULE;
- break;
- case dir_node:
- /* output a reflection instruction if the direction has changed */
- if (dir_dir(p) >= 0) {
- /*
- Calculate the needed width to the matching |enddir|, return the
- |enddir| node, with width info
- */
- enddir_ptr = calculate_width_to_enddir(p, cur_glue, cur_g, this_box);
- if (textdir_parallel(dir_dir(p), localpos.dir)) {
- dir_cur_h(enddir_ptr) += cur.h;
- if (textdir_opposite(dir_dir(p), localpos.dir))
- cur.h = dir_cur_h(enddir_ptr);
- } else
- dir_cur_h(enddir_ptr) = cur.h;
- if (enddir_ptr != p) {
- /* only if it is an enddir */
- dir_cur_v(enddir_ptr) = cur.v;
- dir_refpos_h(enddir_ptr) = refpos->pos.h;
- dir_refpos_v(enddir_ptr) = refpos->pos.v;
- /* negative: mark it as |enddir| */
- dir_dir(enddir_ptr) = localpos.dir - dir_swap;
- }
- /* fake a nested |hlist_out| */
- synch_pos_with_cur(pdf->posstruct, refpos, cur);
- refpos->pos = pdf->posstruct->pos;
- localpos.dir = dir_dir(p);
- cur.h = 0;
- cur.v = 0;
- } else {
- refpos->pos.h = dir_refpos_h(p);
- refpos->pos.v = dir_refpos_v(p);
- localpos.dir = dir_dir(p) + dir_swap;
- cur.h = dir_cur_h(p);
- cur.v = dir_cur_v(p);
- }
- break;
- case whatsit_node:
- /* output the whatsit node |p| in |hlist_out| */
- switch (subtype(p)) {
- case save_pos_node:
- last_position = pdf->posstruct->pos;
- pos_info.curpos = pdf->posstruct->pos;
- pos_info.boxpos.pos = refpos->pos;
- pos_info.boxpos.dir = localpos.dir;
- pos_info.boxdim.wd = width(this_box);
- pos_info.boxdim.ht = height(this_box);
- pos_info.boxdim.dp = depth(this_box);
- break;
- case pdf_annot_node:
- case pdf_start_link_node:
- case pdf_dest_node:
- case pdf_start_thread_node:
- case pdf_thread_node:
- backend_out_whatsit[subtype(p)] (pdf, p, this_box, cur);
+ cur.h += effective_horizontal;
break;
- default:
- out_what(pdf, p);
- }
- break;
- case math_node:
- if (synctex) {
- synctexmath(p, this_box);
- }
- /* begin mathskip code */
- if (glue_ptr(p) == zero_glue) {
- cur.h += surround(p);
+ case disc_node:
+ /* hh: the frontend should append already */
+ if (vlink(no_break(p)) != null) {
+ if (subtype(p) != select_disc) {
+ q = tail_of_list(vlink(no_break(p))); /* this could be a tlink */
+ vlink(q) = vlink(p);
+ q = vlink(no_break(p));
+ vlink(no_break(p)) = null;
+ vlink(p) = q;
+ }
+ }
break;
- } else {
- /* fall through: mathskip */
- }
- /* end mathskip code */
- case glue_node:
- {
- /* move right or output leaders, we use real multiplication */
- halfword g = glue_ptr(p);
- rule.wd = width(g) - cur_g;
- if (g_sign != normal) {
- if (g_sign == stretching) {
- if (stretch_order(g) == g_order) {
- cur_glue = cur_glue + stretch(g);
+ case glue_node:
+ {
+ /* move right or output leaders, we use real multiplication */
+ halfword g = glue_ptr(p);
+ rule.wd = width(g) - cur_g;
+ if (g_sign != normal) {
+ if (g_sign == stretching) {
+ if (stretch_order(g) == g_order) {
+ cur_glue = cur_glue + stretch(g);
+ vet_glue(float_cast(glue_set(this_box)) * cur_glue);
+ cur_g = float_round(glue_temp);
+ }
+ } else if (shrink_order(g) == g_order) {
+ cur_glue = cur_glue - shrink(g);
vet_glue(float_cast(glue_set(this_box)) * cur_glue);
cur_g = float_round(glue_temp);
}
- } else if (shrink_order(g) == g_order) {
- cur_glue = cur_glue - shrink(g);
- vet_glue(float_cast(glue_set(this_box)) * cur_glue);
- cur_g = float_round(glue_temp);
- }
- }
- rule.wd = rule.wd + cur_g;
- if (subtype(p) >= a_leaders) {
- /* output leaders in an hlist, |goto fin_rule| if a rule or to |next_p| if done */
- leader_box = leader_ptr(p);
- if (type(leader_box) == rule_node) {
- rule.ht = height(leader_box);
- rule.dp = depth(leader_box);
- goto FIN_RULE;
}
- if (textdir_parallel(box_dir(leader_box), localpos.dir))
- leader_wd = width(leader_box);
- else
- leader_wd = height(leader_box) + depth(leader_box);
- if ((leader_wd > 0) && (rule.wd > 0)) {
- rule.wd = rule.wd + 10; /* compensate for floating-point rounding */
- edge = cur.h + rule.wd;
- lx = 0;
- /*
- let |cur.h| be the position of the first box, and set |leader_wd+lx|
- to the spacing between corresponding parts of boxes
- */
- if (subtype(p) == g_leaders) {
- save_h = cur.h;
- switch (localpos.dir) {
- case dir_TLT:
- cur.h += refpos->pos.h - shipbox_refpos.h;
- cur.h = leader_wd * (cur.h / leader_wd);
- cur.h -= refpos->pos.h - shipbox_refpos.h;
- break;
- case dir_TRT:
- cur.h = refpos->pos.h - shipbox_refpos.h - cur.h;
- cur.h = leader_wd * (cur.h / leader_wd);
- cur.h = refpos->pos.h - shipbox_refpos.h - cur.h;
- break;
- case dir_LTL:
- case dir_RTT:
- cur.h = refpos->pos.v - shipbox_refpos.v - cur.h;
+ rule.wd = rule.wd + cur_g;
+ if (subtype(p) >= a_leaders) {
+ /* output leaders in an hlist, |goto fin_rule| if a rule or to |next_p| if done */
+ leader_box = leader_ptr(p);
+ if (type(leader_box) == rule_node) {
+ rule.ht = height(leader_box);
+ rule.dp = depth(leader_box);
+ goto FIN_RULE;
+ }
+ if (textdir_parallel(box_dir(leader_box), localpos.dir))
+ leader_wd = width(leader_box);
+ else
+ leader_wd = height(leader_box) + depth(leader_box);
+ if ((leader_wd > 0) && (rule.wd > 0)) {
+ rule.wd = rule.wd + 10; /* compensate for floating-point rounding */
+ edge = cur.h + rule.wd;
+ lx = 0;
+ /*
+ let |cur.h| be the position of the first box, and set |leader_wd+lx|
+ to the spacing between corresponding parts of boxes
+ */
+ if (subtype(p) == g_leaders) {
+ save_h = cur.h;
+ switch (localpos.dir) {
+ case dir_TLT:
+ cur.h += refpos->pos.h - shipbox_refpos.h;
+ cur.h = leader_wd * (cur.h / leader_wd);
+ cur.h -= refpos->pos.h - shipbox_refpos.h;
+ break;
+ case dir_TRT:
+ cur.h = refpos->pos.h - shipbox_refpos.h - cur.h;
+ cur.h = leader_wd * (cur.h / leader_wd);
+ cur.h = refpos->pos.h - shipbox_refpos.h - cur.h;
+ break;
+ case dir_LTL:
+ case dir_RTT:
+ cur.h = refpos->pos.v - shipbox_refpos.v - cur.h;
+ cur.h = leader_wd * (cur.h / leader_wd);
+ cur.h = refpos->pos.v - shipbox_refpos.v - cur.h;
+ break;
+ default:
+ formatted_warning("pdf backend","forcing bad dir %i to TLT in hlist case 1",localpos.dir);
+ localpos.dir = dir_TLT;
+ cur.h += refpos->pos.h - shipbox_refpos.h;
+ cur.h = leader_wd * (cur.h / leader_wd);
+ cur.h -= refpos->pos.h - shipbox_refpos.h;
+ break;
+ }
+ if (cur.h < save_h)
+ cur.h += leader_wd;
+ } else if (subtype(p) == a_leaders) {
+ save_h = cur.h;
cur.h = leader_wd * (cur.h / leader_wd);
- cur.h = refpos->pos.v - shipbox_refpos.v - cur.h;
- break;
- default:
- assert(0);
- }
- if (cur.h < save_h)
- cur.h += leader_wd;
- } else if (subtype(p) == a_leaders) {
- save_h = cur.h;
- cur.h = leader_wd * (cur.h / leader_wd);
- if (cur.h < save_h)
- cur.h += leader_wd;
- } else {
- lq = rule.wd / leader_wd; /* the number of box copies */
- lr = rule.wd % leader_wd; /* the remaining space */
- if (subtype(p) == c_leaders) {
- cur.h += lr / 2;
+ if (cur.h < save_h)
+ cur.h += leader_wd;
} else {
- lx = lr / (lq + 1);
- cur.h += (lr - (lq - 1) * lx) / 2;
+ lq = rule.wd / leader_wd; /* the number of box copies */
+ lr = rule.wd % leader_wd; /* the remaining space */
+ if (subtype(p) == c_leaders) {
+ cur.h += lr / 2;
+ } else {
+ lx = lr / (lq + 1);
+ cur.h += (lr - (lq - 1) * lx) / 2;
+ }
}
- }
- while (cur.h + leader_wd <= edge) {
- /* output a leader box at |cur.h|, then advance |cur.h| by |leader_wd+lx| */
- if (pardir_parallel(box_dir(leader_box), localpos.dir)) {
- basepoint.v = 0;
- if (textdir_opposite(box_dir(leader_box), localpos.dir))
- basepoint.h = width(leader_box);
- else
- basepoint.h = 0;
- } else {
- if (!is_mirrored(box_dir(leader_box))) {
- if (partextdir_eq(box_dir(leader_box), localpos.dir))
- basepoint.h = height(leader_box);
+ while (cur.h + leader_wd <= edge) {
+ /* output a leader box at |cur.h|, then advance |cur.h| by |leader_wd+lx| */
+ if (pardir_parallel(box_dir(leader_box), localpos.dir)) {
+ basepoint.v = 0;
+ if (textdir_opposite(box_dir(leader_box), localpos.dir))
+ basepoint.h = width(leader_box);
else
- basepoint.h = depth(leader_box);
+ basepoint.h = 0;
} else {
- if (partextdir_eq(box_dir(leader_box), localpos.dir))
- basepoint.h = depth(leader_box);
+ if (!is_mirrored(box_dir(leader_box))) {
+ if (partextdir_eq(box_dir(leader_box), localpos.dir))
+ basepoint.h = height(leader_box);
+ else
+ basepoint.h = depth(leader_box);
+ } else {
+ if (partextdir_eq(box_dir(leader_box), localpos.dir))
+ basepoint.h = depth(leader_box);
+ else
+ basepoint.h = height(leader_box);
+ }
+ if (partextdir_eq(localpos.dir, box_dir(leader_box)))
+ basepoint.v = -(width(leader_box) / 2);
else
- basepoint.h = height(leader_box);
+ basepoint.v = (width(leader_box) / 2);
}
- if (partextdir_eq(localpos.dir, box_dir(leader_box)))
- basepoint.v = -(width(leader_box) / 2);
+ if (!is_mirrored(localpos.dir))
+ basepoint.v = basepoint.v + shift_amount(leader_box); /* shift the box down */
+ else
+ basepoint.v = basepoint.v - shift_amount(leader_box); /* shift the box up */
+ tmpcur.h = cur.h + basepoint.h;
+ tmpcur.v = basepoint.v;
+ synch_pos_with_cur(pdf->posstruct, refpos, tmpcur);
+ outer_doing_leaders = doing_leaders;
+ doing_leaders = true;
+ if (type(leader_box) == vlist_node)
+ vlist_out(pdf, leader_box, rule_callback_id);
else
- basepoint.v = (width(leader_box) / 2);
+ hlist_out(pdf, leader_box, rule_callback_id);
+ doing_leaders = outer_doing_leaders;
+ cur.h += leader_wd + lx;
}
- if (!is_mirrored(localpos.dir))
- basepoint.v = basepoint.v + shift_amount(leader_box); /* shift the box down */
- else
- basepoint.v = basepoint.v - shift_amount(leader_box); /* shift the box up */
- assert(cur.v == 0);
- tmpcur.h = cur.h + basepoint.h;
- tmpcur.v = basepoint.v;
- synch_pos_with_cur(pdf->posstruct, refpos, tmpcur);
- outer_doing_leaders = doing_leaders;
- doing_leaders = true;
- if (type(leader_box) == vlist_node)
- vlist_out(pdf, leader_box);
- else
- hlist_out(pdf, leader_box);
- doing_leaders = outer_doing_leaders;
- cur.h += leader_wd + lx;
+ cur.h = edge - 10;
+ goto NEXTP;
}
- cur.h = edge - 10;
- goto NEXTP;
}
- }
- }
- goto MOVE_PAST;
- break;
- case margin_kern_node:
- cur.h += width(p);
- break;
- case kern_node:
- if (synctex)
- synctexkern(p, this_box);
- cur.h += width(p);
- break;
- default:
- break;
+ }
+ goto MOVE_PAST;
+ break;
+ case kern_node:
+ if (synctex)
+ synctexkern(p, this_box);
+ cur.h += width(p);
+ break;
+ case rule_node:
+ if (rule_dir(p) < 0)
+ rule_dir(p) = localpos.dir;
+ if (pardir_parallel(rule_dir(p), localpos.dir)) {
+ rule.ht = height(p);
+ rule.dp = depth(p);
+ rule.wd = width(p);
+ } else {
+ rule.ht = width(p) / 2;
+ rule.dp = width(p) / 2;
+ rule.wd = height(p) + depth(p);
+ }
+ goto FIN_RULE;
+ break;
+ case dir_node:
+ /* output a reflection instruction if the direction has changed */
+ if (dir_dir(p) >= 0) {
+ /*
+ Calculate the needed width to the matching |enddir|, return the
+ |enddir| node, with width info
+ */
+ enddir_ptr = calculate_width_to_enddir(p, cur_glue, cur_g, this_box);
+ if (textdir_parallel(dir_dir(p), localpos.dir)) {
+ dir_cur_h(enddir_ptr) += cur.h;
+ if (textdir_opposite(dir_dir(p), localpos.dir))
+ cur.h = dir_cur_h(enddir_ptr);
+ } else
+ dir_cur_h(enddir_ptr) = cur.h;
+ if (enddir_ptr != p) {
+ /* only if it is an enddir */
+ dir_cur_v(enddir_ptr) = cur.v;
+ dir_refpos_h(enddir_ptr) = refpos->pos.h;
+ dir_refpos_v(enddir_ptr) = refpos->pos.v;
+ /* negative: mark it as |enddir| */
+ dir_dir(enddir_ptr) = localpos.dir - dir_swap;
+ }
+ /* fake a nested |hlist_out| */
+ synch_pos_with_cur(pdf->posstruct, refpos, cur);
+ refpos->pos = pdf->posstruct->pos;
+ localpos.dir = dir_dir(p);
+ cur.h = 0;
+ cur.v = 0;
+ } else {
+ refpos->pos.h = dir_refpos_h(p);
+ refpos->pos.v = dir_refpos_v(p);
+ localpos.dir = dir_dir(p) + dir_swap;
+ cur.h = dir_cur_h(p);
+ cur.v = dir_cur_v(p);
+ }
+ break;
+ case whatsit_node:
+ /* output the whatsit node |p| in |hlist_out| */
+ switch (subtype(p)) {
+ case save_pos_node:
+ last_position = pdf->posstruct->pos;
+ pos_info.curpos = pdf->posstruct->pos;
+ pos_info.boxpos.pos = refpos->pos;
+ pos_info.boxpos.dir = localpos.dir;
+ pos_info.boxdim.wd = width(this_box);
+ pos_info.boxdim.ht = height(this_box);
+ pos_info.boxdim.dp = depth(this_box);
+ break;
+ case pdf_annot_node:
+ case pdf_start_link_node:
+ case pdf_dest_node:
+ case pdf_start_thread_node:
+ case pdf_thread_node:
+ backend_out_whatsit[subtype(p)] (pdf, p, this_box, cur);
+ break;
+ default:
+ out_what(pdf, p);
+ }
+ break;
+ case math_node:
+ if (synctex) {
+ synctexmath(p, this_box);
+ }
+ /* begin mathskip code */
+ if (glue_ptr(p) == zero_glue) {
+ cur.h += surround(p);
+ break;
+ } else {
+ /* fall through: mathskip */
+ }
+ /* end mathskip code */
+ case margin_kern_node:
+ cur.h += width(p);
+ break;
+ default:
+ break;
}
goto NEXTP;
FIN_RULE:
@@ -669,39 +659,44 @@ void hlist_out(PDF pdf, halfword this_box)
/* we don't output empty rules */
if ((rule.ht + rule.dp) > 0 && rule.wd > 0) {
switch (localpos.dir) {
- case dir_TLT:
- size.h = rule.wd;
- size.v = rule.ht + rule.dp;
- pos_down(rule.dp);
- break;
- case dir_TRT:
- size.h = rule.wd;
- size.v = rule.ht + rule.dp;
- pos_left(size.h);
- pos_down(rule.dp);
- break;
- case dir_LTL:
- size.h = rule.ht + rule.dp;
- size.v = rule.wd;
- pos_left(rule.ht);
- pos_down(size.v);
- break;
- case dir_RTT:
- size.h = rule.ht + rule.dp;
- size.v = rule.wd;
- pos_left(rule.dp);
- pos_down(size.v);
- break;
- default:
- assert(0);
+ case dir_TLT:
+ size.h = rule.wd;
+ size.v = rule.ht + rule.dp;
+ pos_down(rule.dp);
+ break;
+ case dir_TRT:
+ size.h = rule.wd;
+ size.v = rule.ht + rule.dp;
+ pos_left(size.h);
+ pos_down(rule.dp);
+ break;
+ case dir_LTL:
+ size.h = rule.ht + rule.dp;
+ size.v = rule.wd;
+ pos_left(rule.ht);
+ pos_down(size.v);
+ break;
+ case dir_RTT:
+ size.h = rule.ht + rule.dp;
+ size.v = rule.wd;
+ pos_left(rule.dp);
+ pos_down(size.v);
+ break;
+ default:
+ formatted_warning("pdf backend","forcing bad dir %i to TLT in hlist case 2",localpos.dir);
+ localpos.dir = dir_TLT;
+ size.h = rule.wd;
+ size.v = rule.ht + rule.dp;
+ pos_down(rule.dp);
+ break;
}
if (type(p) == glue_node) {
q = leader_ptr(p);
if ((q) && (type(q) == rule_node)) {
- backend_out[rule_node] (pdf, q, size);
+ backend_out[rule_node] (pdf, q, size, rule_callback_id);
}
} else {
- backend_out[rule_node] (pdf, p, size);
+ backend_out[rule_node] (pdf, p, size, rule_callback_id);
}
}
MOVE_PAST:
@@ -715,10 +710,8 @@ void hlist_out(PDF pdf, halfword this_box)
synch_pos_with_cur(pdf->posstruct, refpos, cur);
}
}
-
if (synctex)
synctextsilh(this_box);
-
if (output_mode_used == OMODE_DVI) {
prune_movements(save_loc);
if (cur_s > 0) {
@@ -731,7 +724,7 @@ void hlist_out(PDF pdf, halfword this_box)
}
@ @c
-void vlist_out(PDF pdf, halfword this_box)
+void vlist_out(PDF pdf, halfword this_box, int rule_callback_id)
{
posstructure localpos; /* the position structure local within this function */
posstructure *refpos; /* the list origin pos. on the page, provided by the caller */
@@ -790,11 +783,7 @@ void vlist_out(PDF pdf, halfword this_box)
check_running_thread(pdf, this_box, cur);
while (p != null) {
- if (is_char_node(p)) {
- confusion("vlistout"); /* this can't happen */
- } else {
- /* output the non-|char_node| |p| for |vlist_out| */
- switch (type(p)) {
+ switch (type(p)) {
case hlist_node:
case vlist_node:
/*
@@ -846,14 +835,13 @@ void vlist_out(PDF pdf, halfword this_box)
synctexvoidhlist(p, this_box);
}
} else {
- assert(cur.h == 0);
tmpcur.h = basepoint.h;
tmpcur.v = cur.v + basepoint.v;
synch_pos_with_cur(pdf->posstruct, refpos, tmpcur);
if (type(p) == vlist_node)
- vlist_out(pdf, p);
+ vlist_out(pdf, p, rule_callback_id);
else
- hlist_out(pdf, p);
+ hlist_out(pdf, p, rule_callback_id);
cur.v += effective_vertical;
}
break;
@@ -871,29 +859,6 @@ void vlist_out(PDF pdf, halfword this_box)
}
goto FIN_RULE;
break;
- case whatsit_node:
- /* output the whatsit node |p| in |vlist_out| */
- switch (subtype(p)) {
- case save_pos_node:
- last_position = pdf->posstruct->pos;
- pos_info.curpos = pdf->posstruct->pos;
- pos_info.boxpos.pos = refpos->pos;
- pos_info.boxpos.dir = localpos.dir;
- pos_info.boxdim.wd = width(this_box);
- pos_info.boxdim.ht = height(this_box);
- pos_info.boxdim.dp = depth(this_box);
- break;
- case pdf_annot_node:
- case pdf_start_link_node:
- case pdf_dest_node:
- case pdf_start_thread_node:
- case pdf_thread_node:
- backend_out_whatsit[subtype(p)] (pdf, p, this_box, cur);
- break;
- default:
- out_what(pdf, p);
- }
- break;
case glue_node:
{
/* move down or output leaders, we use real multiplication */
@@ -933,24 +898,29 @@ void vlist_out(PDF pdf, halfword this_box)
if (subtype(p) == g_leaders) {
save_v = cur.v;
switch (localpos.dir) {
- case dir_LTL:
- cur.v += refpos->pos.h - shipbox_refpos.h;
- cur.v = leader_ht * (cur.v / leader_ht);
- cur.v -= refpos->pos.h - shipbox_refpos.h;
- break;
- case dir_RTT:
- cur.v = refpos->pos.h - shipbox_refpos.h - cur.v;
- cur.v = leader_ht * (cur.v / leader_ht);
- cur.v = refpos->pos.h - shipbox_refpos.h - cur.v;
- break;
- case dir_TLT:
- case dir_TRT:
- cur.v = refpos->pos.v - shipbox_refpos.v - cur.v;
- cur.v = leader_ht * (cur.v / leader_ht);
- cur.v = refpos->pos.v - shipbox_refpos.v - cur.v;
- break;
- default:
- assert(0);
+ case dir_LTL:
+ cur.v += refpos->pos.h - shipbox_refpos.h;
+ cur.v = leader_ht * (cur.v / leader_ht);
+ cur.v -= refpos->pos.h - shipbox_refpos.h;
+ break;
+ case dir_RTT:
+ cur.v = refpos->pos.h - shipbox_refpos.h - cur.v;
+ cur.v = leader_ht * (cur.v / leader_ht);
+ cur.v = refpos->pos.h - shipbox_refpos.h - cur.v;
+ break;
+ case dir_TLT:
+ case dir_TRT:
+ cur.v = refpos->pos.v - shipbox_refpos.v - cur.v;
+ cur.v = leader_ht * (cur.v / leader_ht);
+ cur.v = refpos->pos.v - shipbox_refpos.v - cur.v;
+ break;
+ default:
+ formatted_warning("pdf backend","forcing bad dir %i to TLT in vlist case 1",localpos.dir);
+ localpos.dir = dir_TLT;
+ cur.v += refpos->pos.h - shipbox_refpos.h;
+ cur.v = leader_ht * (cur.v / leader_ht);
+ cur.v -= refpos->pos.h - shipbox_refpos.h;
+ break;
}
if (cur.v < save_v)
cur.v += leader_ht;
@@ -972,16 +942,15 @@ void vlist_out(PDF pdf, halfword this_box)
while (cur.v + leader_ht <= edge) {
/* output a leader box at |cur.v|, then advance |cur.v| by |leader_ht+lx| */
- assert(cur.h == 0);
tmpcur.h = shift_amount(leader_box);
tmpcur.v = cur.v + height(leader_box);
synch_pos_with_cur(pdf->posstruct, refpos, tmpcur);
outer_doing_leaders = doing_leaders;
doing_leaders = true;
if (type(leader_box) == vlist_node)
- vlist_out(pdf, leader_box);
+ vlist_out(pdf, leader_box, rule_callback_id);
else
- hlist_out(pdf, leader_box);
+ hlist_out(pdf, leader_box, rule_callback_id);
doing_leaders = outer_doing_leaders;
cur.v += leader_ht + lx;
}
@@ -995,17 +964,44 @@ void vlist_out(PDF pdf, halfword this_box)
case kern_node:
cur.v += width(p);
break;
+ case whatsit_node:
+ /* output the whatsit node |p| in |vlist_out| */
+ switch (subtype(p)) {
+ case save_pos_node:
+ last_position = pdf->posstruct->pos;
+ pos_info.curpos = pdf->posstruct->pos;
+ pos_info.boxpos.pos = refpos->pos;
+ pos_info.boxpos.dir = localpos.dir;
+ pos_info.boxdim.wd = width(this_box);
+ pos_info.boxdim.ht = height(this_box);
+ pos_info.boxdim.dp = depth(this_box);
+ break;
+ case pdf_annot_node:
+ case pdf_start_link_node:
+ case pdf_dest_node:
+ case pdf_start_thread_node:
+ case pdf_thread_node:
+ backend_out_whatsit[subtype(p)] (pdf, p, this_box, cur);
+ break;
+ default:
+ out_what(pdf, p);
+ }
+ break;
+ case glyph_node:
+ case disc_node:
+ confusion("vlistout"); /* this can't happen */
+ break;
default:
break;
- }
- goto NEXTP;
- FIN_RULE:
- /* output a rule in a vlist, |goto next_p| */
- if (is_running(rule.wd))
- rule.wd = width(this_box);
- /* we don't output empty rules */
- if ((rule.ht + rule.dp) > 0 && rule.wd > 0) {
- switch (localpos.dir) {
+ }
+ goto NEXTP;
+ FIN_RULE:
+ /* output a rule in a vlist, |goto next_p| */
+ if (is_running(rule.wd))
+ rule.wd = width(this_box);
+ /* we don't output empty rules */
+ if ((rule.ht + rule.dp) > 0 && rule.wd > 0) {
+ switch (localpos.dir) {
case dir_TLT:
size.h = rule.wd;
size.v = rule.ht + rule.dp;
@@ -1029,24 +1025,28 @@ void vlist_out(PDF pdf, halfword this_box)
pos_down(size.v);
break;
default:
- assert(0);
- }
- if (type(p) == glue_node) {
- q = leader_ptr(p);
- if ((q) && (type(q) == rule_node)) {
- backend_out[rule_node] (pdf, q, size);
- }
- } else {
- backend_out[rule_node] (pdf, p, size);
+ formatted_warning("pdf backend","forcing bad dir %i to TLT in vlist case 2",localpos.dir);
+ localpos.dir = dir_TLT;
+ size.h = rule.wd;
+ size.v = rule.ht + rule.dp;
+ pos_down(size.v);
+ break;
+ }
+ if (type(p) == glue_node) {
+ q = leader_ptr(p);
+ if ((q) && (type(q) == rule_node)) {
+ backend_out[rule_node] (pdf, q, size, rule_callback_id);
}
+ } else {
+ backend_out[rule_node] (pdf, p, size, rule_callback_id);
}
- cur.v += rule.ht + rule.dp;
- goto NEXTP;
- MOVE_PAST:
- cur.v += rule.ht;
- NEXTP:
- p = vlink(p);
}
+ cur.v += rule.ht + rule.dp;
+ goto NEXTP;
+ MOVE_PAST:
+ cur.v += rule.ht;
+ NEXTP:
+ p = vlink(p);
synch_pos_with_cur(pdf->posstruct, refpos, cur);
}
if (synctex)
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.h b/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.h
index 134bca44a24..14c197d0f72 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.h
@@ -15,13 +15,13 @@
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/>.
+*/
#ifndef PDFLITERAL_H
# define PDFLITERAL_H
-
# define set_pdf_literal_mode(A,B) pdf_literal_mode(A)=B
# define set_pdf_literal_type(A,B) pdf_literal_type(A)=B
# define set_pdf_literal_data(A,B) pdf_literal_data(A)=B
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w b/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w
index dae67234a51..3c6b6f6efbf 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w
@@ -19,15 +19,13 @@
@ @c
-
#include "ptexlib.h"
@ @c
void pdf_special(PDF pdf, halfword p)
{
- int old_setting; /* holds print |selector| */
+ int old_setting = selector;
str_number s;
- old_setting = selector;
selector = new_string;
show_token_list(token_link(write_tokens(p)), null, -1);
selector = old_setting;
@@ -36,11 +34,10 @@ void pdf_special(PDF pdf, halfword p)
flush_str(s);
}
-
@ To ship out a \TeX\ box to PDF page description we need to implement
-|hlist_out|, |vlist_out| and |ship_out|, which are equivalent to
-the \TeX' original |hlist_out|, |vlist_out| and |ship_out| resp. But first we
-need to declare some procedures needed in |hlist_out| and |vlist_out|.
+|hlist_out|, |vlist_out| and |ship_out|, which are equivalent to the \TeX'
+original |hlist_out|, |vlist_out| and |ship_out| resp. But first we need to
+declare some procedures needed in |hlist_out| and |vlist_out|.
@c
void pdf_out_literal(PDF pdf, halfword p)
@@ -57,22 +54,21 @@ void pdf_out_literal(PDF pdf, halfword p)
pdf_literal(pdf, s, pdf_literal_mode(p), false);
flush_str(s);
} else {
- assert(pdf_literal_mode(p) != scan_special);
switch (pdf_literal_mode(p)) {
- case set_origin:
- pdf_goto_pagemode(pdf);
- pdf_set_pos(pdf, pdf->posstruct->pos);
- break;
- case direct_page:
- pdf_goto_pagemode(pdf);
- break;
- case direct_always:
- pdf_end_string_nl(pdf);
- ps->need_tm = true;
- break;
- default:
- confusion("literal1");
- break;
+ case set_origin:
+ pdf_goto_pagemode(pdf);
+ pdf_set_pos(pdf, pdf->posstruct->pos);
+ break;
+ case direct_page:
+ pdf_goto_pagemode(pdf);
+ break;
+ case direct_always:
+ pdf_end_string_nl(pdf);
+ ps->need_tm = true;
+ break;
+ default:
+ normal_error("pdf backend","bad literal mode");
+ break;
}
lua_pdf_literal(pdf, pdf_literal_data(p));
}
@@ -101,7 +97,8 @@ void pdf_literal(PDF pdf, str_number s, int literal_mode, boolean warn)
size_t l;
pool_pointer j = 0; /* current character code position, initialized to make the compiler happy */
pdfstructure *p = pdf->pstruct;
- if (s >= STRING_OFFSET) { /* needed for |out_save| */
+ if (s >= STRING_OFFSET) {
+ /* needed for |out_save| */
j = 0;
/* the next is obsolete, in fact, specials are obsolete in pdf mode */
if (literal_mode == scan_special) {
@@ -123,27 +120,26 @@ void pdf_literal(PDF pdf, str_number s, int literal_mode, boolean warn)
}
}
switch (literal_mode) {
- case set_origin:
- pdf_goto_pagemode(pdf);
- pdf_set_pos(pdf, pdf->posstruct->pos);
- break;
- case direct_page:
- pdf_goto_pagemode(pdf);
- break;
- case direct_always:
- pdf_end_string_nl(pdf);
- p->need_tm = true;
- break;
- default:
- confusion("literal1");
- break;
+ case set_origin:
+ pdf_goto_pagemode(pdf);
+ pdf_set_pos(pdf, pdf->posstruct->pos);
+ break;
+ case direct_page:
+ pdf_goto_pagemode(pdf);
+ break;
+ case direct_always:
+ pdf_end_string_nl(pdf);
+ p->need_tm = true;
+ break;
+ default:
+ normal_error("pdf backend","bad literal mode");
+ break;
}
if (s >= STRING_OFFSET) {
ss = str_string(s);
l = str_length(s) - (size_t) j;
pdf_out_block(pdf, (const char *) (ss + j), l);
} else {
- assert(s < 256);
pdf_out(pdf, s);
}
pdf_out(pdf, '\n');
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.h b/Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.h
deleted file mode 100644
index 3d8652ecc67..00000000000
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* pdfluaapi.h
-
- Copyright 2009 Taco Hoekwater <taco@luatex.org>
-
- This file is part of LuaTeX.
-
- LuaTeX is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- LuaTeX is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- License for more details.
-
- You should have received a copy of the GNU General Public License along
- with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
-
-
-#ifndef PDFLUAAPI_H
-# define PDFLUAAPI_H
-
-extern int new_pdflua(void);
-extern void pdflua_begin_page(PDF pdf);
-extern void pdflua_end_page(PDF pdf, int annots, int beads);
-extern void pdflua_output_pages_tree(PDF pdf);
-
-#endif /* PDFLUAAPI_H */
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.w b/Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.w
deleted file mode 100644
index ebd20d6e20d..00000000000
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfluaapi.w
+++ /dev/null
@@ -1,113 +0,0 @@
-% 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
-
-
-#include "ptexlib.h"
-
-@ @c
-int new_pdflua(void)
-{
- int i, err;
- Byte *uncompr;
- const zlib_struct *zp = pdflua_zlib_struct_ptr;
- uLong uncomprLen = zp->uncomprLen;
- if ((uncompr = xtalloc(zp->uncomprLen, Byte)) == NULL)
- luatex_fail("new_pdflua(): xtalloc()");
- err = uncompress(uncompr, &uncomprLen, zp->compr, zp->comprLen);
- if (err != Z_OK)
- luatex_fail("new_pdflua(): uncompress()");
- assert(uncomprLen == zp->uncomprLen);
- if (luaL_loadbuffer(Luas, (const char *) uncompr, uncomprLen, "pdflua")
- || lua_pcall(Luas, 0, 1, 0))
- luatex_fail("new_pdflua(): lua_pcall()");
- luaL_checktype(Luas, -1, LUA_TTABLE); /* t */
- i = luaL_ref(Luas, LUA_REGISTRYINDEX); /* - */
- xfree(uncompr);
- return i;
-}
-
-@ @c
-void pdflua_begin_page(PDF pdf)
-{
- int err; /* ... */
- 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 ... */
- lua_pushnumber(Luas, total_pages + 1); /* i t f t ... */
- lua_setfield(Luas, -2, "pagenum"); /* t f t ... */
- lua_pushnumber(Luas, pdf->last_page); /* i t f t ... */
- lua_setfield(Luas, -2, "page_objnum"); /* t f t ... */
- lua_pushnumber(Luas, pdf->last_stream); /* i t f t ... */
- lua_setfield(Luas, -2, "stream_objnum"); /* t f t ... */
- lua_pushnumber(Luas, pdf->page_resources->last_resources); /* i t f t ... */
- lua_setfield(Luas, -2, "resources_objnum"); /* t f t ... */
- err = lua_pcall(Luas, 1, 0, 0); /* (e) t ... */
- if (err != 0)
- luatex_fail("pdflua.lua: beginpage()");
- /* t ... */
- lua_pop(Luas, 1); /* ... */
-}
-
-@ @c
-void pdflua_end_page(PDF pdf, int annots, int beads)
-{
- int err; /* ... */
- lua_rawgeti(Luas, LUA_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, pdf->page_size.h); /* i t f t ... */
- lua_setfield(Luas, -2, "hsize"); /* 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 ... */
- lua_setfield(Luas, -2, "annots"); /* t f t ... */
- }
- if (beads != 0) {
- lua_pushnumber(Luas, beads); /* i t f t ... */
- lua_setfield(Luas, -2, "beads"); /* t f t ... */
- }
- if (pdf->img_page_group_val != 0) {
- lua_pushnumber(Luas, pdf->img_page_group_val); /* i t f t ... */
- lua_setfield(Luas, -2, "imggroup"); /* t f t ... */
- }
- err = lua_pcall(Luas, 1, 0, 0); /* (e) t ... */
- if (err != 0)
- luatex_fail("pdflua.lua: endpage()");
- /* t ... */
- lua_pop(Luas, 1); /* ... */
-}
-
-@ @c
-void pdflua_output_pages_tree(PDF pdf)
-{
- int err;
- 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); /* - */
- if (err != 0)
- luatex_fail("pdflua.lua: outputpagestree()");
-}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h
index ad392338509..f8fac35eea7 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h
@@ -15,8 +15,8 @@
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/>.
+*/
#ifndef PDFOBJ_H
# define PDFOBJ_H
@@ -25,21 +25,13 @@
# define set_pdf_obj_objnum(A, B) pdf_obj_objnum(A) = (B)
-# define pdfmem_obj_size 5 /* size of memory in |mem| which |obj_data_ptr| holds */
-
-# define obj_obj_data(pdf, A) pdf->mem[obj_data_ptr((pdf), (A)) + 0] /* object data */
-# 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_objstm_threshold(pdf, A) pdf->mem[obj_data_ptr((pdf), (A)) + 4] /* for object stream compression */
+# define pdfmem_obj_size 5 /* size of memory in |mem| which |obj_data_ptr| holds */
-/* 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_objstm_threshold(pdf, A, B) obj_obj_objstm_threshold((pdf), (A)) = (B) */
-
-/**********************************************************************/
+# define obj_obj_data(pdf, A) pdf->mem[obj_data_ptr((pdf), (A)) + 0] /* object data */
+# 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_objstm_threshold(pdf, A) pdf->mem[obj_data_ptr((pdf), (A)) + 4] /* for object stream compression */
# define OBJ_FLAG_ISSTREAM (1 << 0)
# define OBJ_FLAG_ISFILE (1 << 1)
@@ -52,8 +44,6 @@
# define set_obj_obj_is_file(pdf,A) ((obj_obj_flags((pdf), (A)) |= OBJ_FLAG_ISFILE))
# define unset_obj_obj_is_file(pdf,A) ((obj_obj_flags((pdf), (A)) &= ~OBJ_FLAG_ISFILE))
-/**********************************************************************/
-
extern void init_obj_obj(PDF pdf, int k);
extern void pdf_write_obj(PDF pdf, int n);
extern void scan_obj(PDF pdf);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w
index a3aa09f3860..7dd51061595 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w
@@ -67,8 +67,8 @@ void pdf_write_obj(PDF pdf, int k)
st.l = li;
lua_pop(Luas, 1);
if (obj_obj_is_file(pdf, k)) {
- boolean res = false; /* callback status value */
- const char *fnam = NULL; /* callback found filename */
+ boolean res = false; /* callback status value */
+ const char *fnam = NULL; /* callback found filename */
int callback_id;
/* st.s is also |\0|-terminated, even as lstring */
fnam = luatex_find_file(st.s, find_data_file_callback);
@@ -96,18 +96,10 @@ void pdf_write_obj(PDF pdf, int k)
tprint("<<");
tprint(st.s);
pdf_out_block(pdf, (const char *) data.s, data.l);
- /* already happens in pdf_end_obj:
- if (!obj_obj_is_stream(pdf, k) && data.s[data.l - 1] != '\n')
- pdf_out(pdf, '\n');
- */
xfree(data.s);
tprint(">>");
} else {
pdf_out_block(pdf, st.s, st.l);
- /* already happens in pdf_end_obj:
- if (!obj_obj_is_stream(pdf, k) && st.s[st.l - 1] != '\n')
- pdf_out(pdf, '\n');
- */
}
if (obj_obj_is_stream(pdf, k)) {
pdf_end_stream(pdf);
@@ -126,16 +118,16 @@ void init_obj_obj(PDF pdf, int k)
obj_obj_data(pdf, k) = LUA_NOREF;
unset_obj_obj_is_stream(pdf, k);
unset_obj_obj_is_file(pdf, k);
- obj_obj_pdfcompresslevel(pdf, k) = -1; /* unset */
- obj_obj_objstm_threshold(pdf, k) = OBJSTM_UNSET; /* unset */
+ obj_obj_pdfcompresslevel(pdf, k) = -1; /* unset */
+ obj_obj_objstm_threshold(pdf, k) = OBJSTM_UNSET; /* unset */
}
-@ The \.{\\pdfextension obj} primitive is used to create a ``raw'' object in the PDF
- output file. The object contents will be hold in memory and will be written
- out only when the object is referenced by \.{\\pdfextension refobj}. When
- \.{\\pdfextension obj} is used with \.{\\immediate}, the object contents will be
- written out immediately. Objects referenced in the current page are appended into
- |pdf_obj_list|.
+@ The \.{\\pdfextension obj} primitive is used to create a ``raw'' object in the
+PDF output file. The object contents will be hold in memory and will be written
+out only when the object is referenced by \.{\\pdfextension refobj}. When
+\.{\\pdfextension obj} is used with \.{\\immediate}, the object contents will be
+written out immediately. Objects referenced in the current page are appended into
+|pdf_obj_list|.
@c
void scan_obj(PDF pdf)
@@ -143,7 +135,6 @@ void scan_obj(PDF pdf)
int k;
lstring *st = NULL;
if (scan_keyword("reserveobjnum")) {
- /* Scan an optional space */
get_x_token();
if (cur_cmd != spacer_cmd)
back_input();
@@ -163,13 +154,13 @@ void scan_obj(PDF pdf)
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_pdfcompresslevel(pdf, k) = 0;
obj_obj_objstm_threshold(pdf, k) = OBJSTM_NEVER;
}
if (scan_keyword("stream")) {
set_obj_obj_is_stream(pdf, k);
if (scan_keyword("attr")) {
- scan_pdf_ext_toks();
+ scan_toks(false, true);
st = tokenlist_to_lstring(def_ref, true);
flush_list(def_ref);
lua_pushlstring(Luas, (char *) st->s, st->l);
@@ -180,7 +171,7 @@ void scan_obj(PDF pdf)
}
if (scan_keyword("file"))
set_obj_obj_is_file(pdf, k);
- scan_pdf_ext_toks();
+ scan_toks(false, true);
st = tokenlist_to_lstring(def_ref, true);
flush_list(def_ref);
lua_pushlstring(Luas, (char *) st->s, st->l);
@@ -192,7 +183,7 @@ void scan_obj(PDF pdf)
}
@ @c
-#define tail cur_list.tail_field
+#define tail cur_list.tail_field
void scan_refobj(PDF pdf)
{
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.h b/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.h
index 79002329953..a1c42df936e 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.h
@@ -15,7 +15,8 @@
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/>.
+*/
#ifndef PDFOUTLINE_H
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w b/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w
index 922428da951..6c0a30a88d9 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w
@@ -19,46 +19,44 @@
@ @c
-
#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
-entries can't not be deallocated and will stay in memory. For this reason we
-will store data of outline entries in |pdf->mem| instead of |mem|
+@ Data structure of outlines; it's not able to write out outline entries before
+all outline entries are defined, so memory allocated for outline entries can't
+not be deallocated and will stay in memory. For this reason we will store data of
+outline entries in |pdf->mem| instead of |mem|
@c
-#define pdfmem_outline_size 8 /* size of memory in |pdf->mem| which |obj_outline_ptr| points to */
-
-#define obj_outline_count obj_info /* count of all opened children */
-#define set_obj_outline_count(pdf,A,B) obj_outline_count(pdf,A)=B
-#define obj_outline_ptr obj_aux /* pointer to |pdf->mem| */
-#define set_obj_outline_ptr(pdf,A,B) obj_outline_ptr(pdf,A)=B
-
-#define obj_outline_title(pdf,A) pdf->mem[obj_outline_ptr(pdf,A)]
-#define obj_outline_parent(pdf,A) pdf->mem[obj_outline_ptr(pdf,A) + 1]
-#define obj_outline_prev(pdf,A) pdf->mem[obj_outline_ptr(pdf,A) + 2]
-#define obj_outline_next(pdf,A) pdf->mem[obj_outline_ptr(pdf,A) + 3]
-#define obj_outline_first(pdf,A) pdf->mem[obj_outline_ptr(pdf,A) + 4]
-#define obj_outline_last(pdf,A) pdf->mem[obj_outline_ptr(pdf,A) + 5]
-#define obj_outline_action_objnum(pdf,A) pdf->mem[obj_outline_ptr(pdf,A) + 6] /* object number of action */
-#define obj_outline_attr(pdf,A) pdf->mem[obj_outline_ptr(pdf,A) + 7]
-
+#define pdfmem_outline_size 8 /* size of memory in |pdf->mem| which |obj_outline_ptr| points to */
+
+#define obj_outline_count obj_info /* count of all opened children */
+#define obj_outline_ptr obj_aux /* pointer to |pdf->mem| */
+
+#define obj_outline_title(pdf,A) pdf->mem[obj_outline_ptr(pdf,A)]
+#define obj_outline_parent(pdf,A) pdf->mem[obj_outline_ptr(pdf,A) + 1]
+#define obj_outline_prev(pdf,A) pdf->mem[obj_outline_ptr(pdf,A) + 2]
+#define obj_outline_next(pdf,A) pdf->mem[obj_outline_ptr(pdf,A) + 3]
+#define obj_outline_first(pdf,A) pdf->mem[obj_outline_ptr(pdf,A) + 4]
+#define obj_outline_last(pdf,A) pdf->mem[obj_outline_ptr(pdf,A) + 5]
+#define obj_outline_action_objnum(pdf,A) pdf->mem[obj_outline_ptr(pdf,A) + 6] /* object number of action */
+#define obj_outline_attr(pdf,A) pdf->mem[obj_outline_ptr(pdf,A) + 7]
+
+#define set_obj_outline_count(pdf,A,B) obj_outline_count(pdf,A)=B
+#define set_obj_outline_ptr(pdf,A,B) obj_outline_ptr(pdf,A)=B
#define set_obj_outline_action_objnum(pdf,A,B) obj_outline_action_objnum(pdf,A)=B
-#define set_obj_outline_title(pdf,A,B) obj_outline_title(pdf,A)=B
-#define set_obj_outline_prev(pdf,A,B) obj_outline_prev(pdf,A)=B
-#define set_obj_outline_next(pdf,A,B) obj_outline_next(pdf,A)=B
-#define set_obj_outline_first(pdf,A,B) obj_outline_first(pdf,A)=B
-#define set_obj_outline_last(pdf,A,B) obj_outline_last(pdf,A)=B
-#define set_obj_outline_parent(pdf,A,B) obj_outline_parent(pdf,A)=B
-#define set_obj_outline_attr(pdf,A,B) obj_outline_attr(pdf,A)=B
+#define set_obj_outline_title(pdf,A,B) obj_outline_title(pdf,A)=B
+#define set_obj_outline_prev(pdf,A,B) obj_outline_prev(pdf,A)=B
+#define set_obj_outline_next(pdf,A,B) obj_outline_next(pdf,A)=B
+#define set_obj_outline_first(pdf,A,B) obj_outline_first(pdf,A)=B
+#define set_obj_outline_last(pdf,A,B) obj_outline_last(pdf,A)=B
+#define set_obj_outline_parent(pdf,A,B) obj_outline_parent(pdf,A)=B
+#define set_obj_outline_attr(pdf,A,B) obj_outline_attr(pdf,A)=B
@ @c
static int open_subentries(PDF pdf, halfword p)
{
- int k, c;
- int l, r;
- k = 0;
+ int c, l, r;
+ int k = 0;
if (obj_outline_first(pdf, p) != 0) {
l = obj_outline_first(pdf, p);
do {
@@ -101,7 +99,7 @@ void scan_pdfoutline(PDF pdf)
int j = 0;
halfword p = null;
if (scan_keyword("attr")) {
- scan_pdf_ext_toks();
+ scan_toks(false, true);
r = def_ref;
} else {
r = 0;
@@ -118,7 +116,7 @@ void scan_pdfoutline(PDF pdf)
} else {
i = 0;
}
- scan_pdf_ext_toks();
+ scan_toks(false, true);
q = def_ref;
if (j == 0) {
j = pdf_create_obj(pdf, obj_type_others, 0);
@@ -180,8 +178,8 @@ void scan_pdfoutline(PDF pdf)
}
}
-@ In the end we must flush PDF objects that cannot be written out
-immediately after shipping out pages.
+@ In the end we must flush PDF objects that cannot be written out immediately
+after shipping out pages.
@c
int print_outlines(PDF pdf)
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfpage.h b/Build/source/texk/web2c/luatexdir/pdf/pdfpage.h
index 6d9fcc0e0b1..175fbcc6c7e 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfpage.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfpage.h
@@ -15,8 +15,8 @@
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/>.
+*/
#ifndef PDFPAGE_H
# define PDFPAGE_H
@@ -33,11 +33,7 @@
# undef hz
# endif
-/**********************************************************************/
-
-void synch_pos_with_cur(posstructure * pos, posstructure * refpos,
- scaledpos cur);
-
+void synch_pos_with_cur(posstructure * pos, posstructure * refpos, scaledpos cur);
boolean calc_pdfpos(pdfstructure * p, scaledpos pos);
void pdf_end_string_nl(PDF pdf);
void pdf_goto_pagemode(PDF pdf);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w b/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w
index 3fc698a9ec7..73c83c64234 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w
@@ -19,7 +19,6 @@
@ @c
-
#include "ptexlib.h"
#include <stdlib.h>
@@ -27,16 +26,16 @@
#include <assert.h>
#include <math.h>
-@ eternal constants
+@ eternal constant: number of sp per 1bp
+
@c
-#define one_bp ((double) 65536 * (double) 72.27 / 72) /* number of sp per 1bp */
+#define one_bp ((double) 65536 * (double) 72.27 / 72)
@ @c
void init_pdf_pagecalculations(PDF pdf)
{
pdfstructure *p;
int decimal_digits = pdf->decimal_digits;
- assert(pdf != NULL);
if (pdf->pstruct == NULL)
pdf->pstruct = xmalloc(sizeof(pdfstructure));
p = pdf->pstruct;
@@ -52,10 +51,10 @@ 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->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[2], 0, 3); /* mantissa holds SlantFont, 0 = default */
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| */
@@ -71,28 +70,31 @@ void init_pdf_pagecalculations(PDF pdf)
}
@ @c
-void synch_pos_with_cur(posstructure * pos, posstructure * refpos,
- scaledpos cur)
+void synch_pos_with_cur(posstructure * pos, posstructure * refpos, scaledpos cur)
{
switch (pos->dir) {
- case dir_TLT:
- pos->pos.h = refpos->pos.h + cur.h;
- pos->pos.v = refpos->pos.v - cur.v;
- break;
- case dir_TRT:
- pos->pos.h = refpos->pos.h - cur.h;
- pos->pos.v = refpos->pos.v - cur.v;
- break;
- case dir_LTL:
- pos->pos.h = refpos->pos.h + cur.v;
- pos->pos.v = refpos->pos.v - cur.h;
- break;
- case dir_RTT:
- pos->pos.h = refpos->pos.h - cur.v;
- pos->pos.v = refpos->pos.v - cur.h;
- break;
- default:
- assert(0);
+ case dir_TLT:
+ pos->pos.h = refpos->pos.h + cur.h;
+ pos->pos.v = refpos->pos.v - cur.v;
+ break;
+ case dir_TRT:
+ pos->pos.h = refpos->pos.h - cur.h;
+ pos->pos.v = refpos->pos.v - cur.v;
+ break;
+ case dir_LTL:
+ pos->pos.h = refpos->pos.h + cur.v;
+ pos->pos.v = refpos->pos.v - cur.h;
+ break;
+ case dir_RTT:
+ pos->pos.h = refpos->pos.h - cur.v;
+ pos->pos.v = refpos->pos.v - cur.h;
+ break;
+ default:
+ formatted_warning("pdf backend","forcing bad dir %i to TLT in synch_pos_with_cur",pos->dir);
+ pos->dir = dir_TLT;
+ pos->pos.h = refpos->pos.h + cur.h;
+ pos->pos.v = refpos->pos.v - cur.v;
+ break;
}
}
@@ -102,55 +104,48 @@ boolean calc_pdfpos(pdfstructure * p, scaledpos pos)
scaledpos new;
boolean move_pdfpos = false;
switch (p->mode) {
- case PMODE_PAGE:
- new.h = i32round(pos.h * p->k1);
- new.v = i32round(pos.v * p->k1);
- p->cm[4].m = new.h - p->pdf.h.m; /* cm is concatenated */
- p->cm[5].m = new.v - p->pdf.v.m;
- if (new.h != p->pdf.h.m || new.v != p->pdf.v.m)
- move_pdfpos = true;
- break;
- case PMODE_TEXT:
- new.h = i32round(pos.h * p->k1);
- new.v = i32round(pos.v * p->k1);
- p->tm[4].m = new.h - p->pdf_bt_pos.h.m; /* Tm replaces */
- p->tm[5].m = new.v - p->pdf_bt_pos.v.m;
- if (new.h != p->pdf.h.m || new.v != p->pdf.v.m)
- move_pdfpos = true;
- break;
- case PMODE_CHAR:
- case PMODE_CHARARRAY:
- switch (p->wmode) {
- case WMODE_H:
- new.h =
- i32round((pos.h * p->k1 - (double) p->pdf_tj_pos.h.m) * p->k2);
+ case PMODE_PAGE:
+ new.h = i32round(pos.h * p->k1);
new.v = i32round(pos.v * p->k1);
- p->tj_delta.m = -i64round((double)
- ((new.h - p->cw.m) / ten_pow[p->cw.e -
- p->tj_delta.
- e]));
- p->tm[5].m = new.v - p->pdf_bt_pos.v.m; /* p->tm[4] is meaningless */
- if (p->tj_delta.m != 0 || new.v != p->pdf.v.m)
+ p->cm[4].m = new.h - p->pdf.h.m; /* cm is concatenated */
+ p->cm[5].m = new.v - p->pdf.v.m;
+ if (new.h != p->pdf.h.m || new.v != p->pdf.v.m)
move_pdfpos = true;
break;
- case WMODE_V:
+ case PMODE_TEXT:
new.h = i32round(pos.h * p->k1);
- new.v =
- i32round(((double) p->pdf_tj_pos.v.m - pos.v * p->k1) * p->k2);
- p->tm[4].m = new.h - p->pdf_bt_pos.h.m; /* p->tm[5] is meaningless */
- p->tj_delta.m = -i64round((double)
- ((new.v - p->cw.m) / ten_pow[p->cw.e -
- p->tj_delta.
- e]));
- if (p->tj_delta.m != 0 || new.h != p->pdf.h.m)
+ new.v = i32round(pos.v * p->k1);
+ p->tm[4].m = new.h - p->pdf_bt_pos.h.m; /* Tm replaces */
+ p->tm[5].m = new.v - p->pdf_bt_pos.v.m;
+ if (new.h != p->pdf.h.m || new.v != p->pdf.v.m)
move_pdfpos = true;
break;
+ case PMODE_CHAR:
+ case PMODE_CHARARRAY:
+ switch (p->wmode) {
+ case WMODE_H:
+ new.h = i32round((pos.h * p->k1 - (double) p->pdf_tj_pos.h.m) * p->k2);
+ new.v = i32round(pos.v * p->k1);
+ p->tj_delta.m = -i64round((double) ((new.h - p->cw.m) / ten_pow[p->cw.e - p->tj_delta.e]));
+ p->tm[5].m = new.v - p->pdf_bt_pos.v.m; /* p->tm[4] is meaningless */
+ if (p->tj_delta.m != 0 || new.v != p->pdf.v.m)
+ move_pdfpos = true;
+ break;
+ case WMODE_V:
+ new.h = i32round(pos.h * p->k1);
+ new.v = i32round(((double) p->pdf_tj_pos.v.m - pos.v * p->k1) * p->k2);
+ p->tm[4].m = new.h - p->pdf_bt_pos.h.m; /* p->tm[5] is meaningless */
+ p->tj_delta.m = -i64round((double) ((new.v - p->cw.m) / ten_pow[p->cw.e - p->tj_delta.e]));
+ if (p->tj_delta.m != 0 || new.h != p->pdf.h.m)
+ move_pdfpos = true;
+ break;
+ default:
+ normal_error("pdf backend","unknown mode in char array in calc_pos");
+ break;
+ }
+ break;
default:
- assert(0);
- }
- break;
- default:
- assert(0);
+ normal_error("pdf backend","unknown mode in calc_pos");
}
return move_pdfpos;
}
@@ -178,7 +173,8 @@ void pdf_set_pos(PDF pdf, scaledpos pos)
{
boolean move;
pdfstructure *p = pdf->pstruct;
- assert(is_pagemode(p));
+ if (!is_pagemode(p))
+ normal_error("pdf backend","page mode expected in set_pos");
move = calc_pdfpos(p, pos);
if (move) {
pdf_print_cm(pdf, p->cm);
@@ -192,17 +188,20 @@ void pdf_set_pos_temp(PDF pdf, scaledpos pos)
{
boolean move;
pdfstructure *p = pdf->pstruct;
- assert(is_pagemode(p));
+ if (!is_pagemode(p))
+ normal_error("pdf backend","page mode expected in set_pos_temp");
move = calc_pdfpos(p, pos);
- if (move)
+ if (move) {
pdf_print_cm(pdf, p->cm);
+ }
}
@ @c
static void begin_text(PDF pdf)
{
pdfstructure *p = pdf->pstruct;
- assert(is_pagemode(p));
+ if (!is_pagemode(p))
+ normal_error("pdf backend","page mode expected in begin_text");
p->pdf_bt_pos = p->pdf;
pdf_puts(pdf, "BT\n");
p->mode = PMODE_TEXT;
@@ -212,7 +211,8 @@ static void begin_text(PDF pdf)
static void end_text(PDF pdf)
{
pdfstructure *p = pdf->pstruct;
- assert(is_textmode(p));
+ if (!is_textmode(p))
+ normal_error("pdf backend","text mode expected in end_text");
pdf_puts(pdf, "ET\n");
p->pdf = p->pdf_bt_pos;
p->mode = PMODE_PAGE;
@@ -231,7 +231,6 @@ void pdf_end_string_nl(PDF pdf)
void pdf_goto_pagemode(PDF pdf)
{
pdfstructure *p = pdf->pstruct;
- assert(p != NULL);
if (!is_pagemode(p)) {
if (is_charmode(p))
end_charmode(pdf);
@@ -239,8 +238,9 @@ void pdf_goto_pagemode(PDF pdf)
end_chararray(pdf);
if (is_textmode(p))
end_text(pdf);
+ if (!is_pagemode(p))
+ normal_error("pdf backend","page mode expected in goto_page_mode");
}
- assert(is_pagemode(p));
}
void pdf_goto_textmode(PDF pdf)
@@ -249,16 +249,16 @@ void pdf_goto_textmode(PDF pdf)
const scaledpos origin = {
0, 0
};
- if (!is_textmode(p)) {
- if (is_pagemode(p)) {
- pdf_set_pos(pdf, origin); /* reset to page origin */
- begin_text(pdf);
- } else {
- if (is_charmode(p))
- end_charmode(pdf);
- if (is_chararraymode(p))
- end_chararray(pdf);
- }
+ if (is_pagemode(p)) {
+ /* reset to page origin */
+ pdf_set_pos(pdf, origin);
+ begin_text(pdf);
+ } else if (!is_textmode(p)) {
+ if (is_charmode(p))
+ end_charmode(pdf);
+ if (is_chararraymode(p))
+ end_chararray(pdf);
+ if (!is_textmode(p))
+ normal_error("pdf backend","text mode expected in goto_text_mode");
}
- assert(is_textmode(p));
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.h b/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.h
index b00fc0476a1..9fdb0ac83d3 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.h
@@ -15,8 +15,8 @@
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/>.
+*/
#ifndef PAGETREE_H
# define PAGETREE_H
@@ -25,4 +25,4 @@ int output_pages_tree(PDF);
int pdf_do_page_divert(PDF, int, int);
void pdf_do_page_undivert(int, int);
-#endif /* PAGETREE_H */
+#endif
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.w b/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.w
index 4470e53cbfb..76d008c4359 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.w
@@ -19,25 +19,20 @@
@ @c
-
#include "ptexlib.h"
@* Page diversions.
@ @c
-#ifdef DEBUG
-# define PAGES_TREE_KIDSMAX 3
-#else
-# define PAGES_TREE_KIDSMAX 10
-#endif
+# define PAGES_TREE_KIDSMAX 10
static struct avl_table *divert_list_tree = NULL;
typedef struct pages_entry_ {
- int objnum; /* object number of this /Pages object */
- int number_of_pages; /* total number of all pages below */
- int number_of_kids; /* number of direct kid objects */
- int kids[PAGES_TREE_KIDSMAX]; /* array of kid object numbers */
+ int objnum; /* object number of this /Pages object */
+ int number_of_pages; /* total number of all pages below */
+ int number_of_kids; /* number of direct kid objects */
+ int kids[PAGES_TREE_KIDSMAX]; /* array of kid object numbers */
struct pages_entry_ *next;
} pages_entry;
@@ -50,11 +45,9 @@ typedef struct divert_list_entry_ {
static int comp_divert_list_entry(const void *pa, const void *pb, void *p)
{
(void) p;
- if (((const divert_list_entry *) pa)->divnum >
- ((const divert_list_entry *) pb)->divnum)
+ if (((const divert_list_entry *) pa)->divnum > ((const divert_list_entry *) pb)->divnum)
return 1;
- if (((const divert_list_entry *) pa)->divnum <
- ((const divert_list_entry *) pb)->divnum)
+ if (((const divert_list_entry *) pa)->divnum < ((const divert_list_entry *) pb)->divnum)
return -1;
return 0;
}
@@ -62,9 +55,8 @@ static int comp_divert_list_entry(const void *pa, const void *pb, void *p)
@ @c
static pages_entry *new_pages_entry(PDF pdf)
{
- pages_entry *p;
int i;
- p = xtalloc(1, pages_entry);
+ pages_entry *p = xtalloc(1, pages_entry);
p->number_of_pages = p->number_of_kids = 0;
for (i = 0; i < PAGES_TREE_KIDSMAX; i++)
p->kids[i] = 0;
@@ -86,9 +78,7 @@ static divert_list_entry *new_divert_list_entry(void)
static void ensure_list_tree(void)
{
if (divert_list_tree == NULL) {
- divert_list_tree =
- avl_create(comp_divert_list_entry, NULL, &avl_xallocator);
- assert(divert_list_tree != NULL);
+ divert_list_tree = avl_create(comp_divert_list_entry, NULL, &avl_xallocator);
}
}
@@ -102,8 +92,11 @@ static divert_list_entry *get_divert_list(int divnum)
if (d == NULL) {
d = new_divert_list_entry();
d->divnum = divnum;
+ /* the next bit of code can actually be removed */
aa = avl_probe(divert_list_tree, d);
- assert(aa != NULL);
+ if (aa==NULL) {
+ normal_error("pdf backend","page list lookup error");
+ }
}
return d;
}
@@ -114,11 +107,6 @@ int pdf_do_page_divert(PDF pdf, int objnum, int divnum)
{
divert_list_entry *d;
pages_entry *p;
-#ifdef DEBUG
- pages_entry *q;
- struct avl_traverser t;
- int i;
-#endif
/* initialize the tree */
ensure_list_tree();
/* make sure we have a list for this diversion */
@@ -135,34 +123,21 @@ int pdf_do_page_divert(PDF pdf, int objnum, int divnum)
p = d->last;
p->kids[p->number_of_kids++] = objnum;
p->number_of_pages++;
-#ifdef DEBUG
- printf("\n");
- avl_t_init(&t, divert_list_tree);
- for (d = avl_t_first(&t, divert_list_tree); d != NULL; d = avl_t_next(&t)) {
- printf("===== D-LIST %d: ", d->divnum);
- for (q = d->first; q != NULL; q = q->next) {
- printf("P=%d NK=%d (", q->objnum, q->number_of_kids);
- for (i = 0; i < q->number_of_kids; i++)
- printf("%d ", q->kids[i]);
- printf(") ");
- }
- printf("\n");
- }
- printf("\n");
-#endif
return p->objnum;
}
@ @c
static void movelist(divert_list_entry * d, divert_list_entry * dto)
{
- if (d != NULL && d->first != NULL && d->divnum != dto->divnum) { /* no undivert of empty list or into self */
+ if (d != NULL && d->first != NULL && d->divnum != dto->divnum) {
+ /* no undivert of empty list or into self */
if (dto->first == NULL)
dto->first = d->first;
else
dto->last->next = d->first;
dto->last = d->last;
- d->first = d->last = NULL; /* one could as well remove this |divert_list_entry| */
+ /* one could as well remove this |divert_list_entry| */
+ d->first = d->last = NULL;
}
}
@@ -172,15 +147,12 @@ void pdf_do_page_undivert(int divnum, int curdivnum)
{
divert_list_entry *d, *dto, tmp;
struct avl_traverser t;
-#ifdef DEBUG
- pages_entry *p;
- int i;
-#endif
/* initialize the tree */
ensure_list_tree();
/* find the diversion |curdivnum| list where diversion |divnum| should go */
dto = get_divert_list(curdivnum);
- if (divnum == 0) { /* 0 = special case: undivert {\it all\/} lists */
+ if (divnum == 0) {
+ /* 0 = special case: undivert {\it all\/} lists */
avl_t_init(&t, divert_list_tree);
for (d = avl_t_first(&t, divert_list_tree); d != NULL;
d = avl_t_next(&t))
@@ -190,21 +162,6 @@ void pdf_do_page_undivert(int divnum, int curdivnum)
d = (divert_list_entry *) avl_find(divert_list_tree, &tmp);
movelist(d, dto);
}
-#ifdef DEBUG
- printf("\n");
- avl_t_init(&t, divert_list_tree);
- for (d = avl_t_first(&t, divert_list_tree); d != NULL; d = avl_t_next(&t)) {
- printf("===== U-LIST %d: ", d->divnum);
- for (p = d->first; p != NULL; p = p->next) {
- printf("P=%d NK=%d (", p->objnum, p->number_of_kids);
- for (i = 0; i < p->number_of_kids; i++)
- printf("%d ", p->kids[i]);
- printf(") ");
- }
- printf("\n");
- }
- printf("\n");
-#endif
}
@ write a /Pages object
@@ -214,11 +171,11 @@ static void write_pages(PDF pdf, pages_entry * p, int parent)
{
int i;
int pages_attributes ;
- assert(p != NULL);
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 (parent == 0) {
+ /* it's root */
pages_attributes = pdf_pages_attr; /* lookup once */
if (pages_attributes != null) {
pdf_print_toks(pdf, pages_attributes);
@@ -240,16 +197,17 @@ static void write_pages(PDF pdf, pages_entry * p, int parent)
@ loop over all /Pages objects, output them, create their parents,
recursing bottom up, return the /Pages root object number
+
@c
static int output_pages_list(PDF pdf, pages_entry * pe)
{
pages_entry *p, *q, *r;
- assert(pe != NULL);
- if (pe->next == NULL) { /* everything fits into one |pages_entry| */
- write_pages(pdf, pe, 0); /* --> /Pages root found */
+ if (pe->next == NULL) {
+ /* everything fits into one |pages_entry| */
+ write_pages(pdf, pe, 0); /* /Pages root found */
return pe->objnum;
}
- q = r = new_pages_entry(pdf); /* one level higher needed */
+ q = r = new_pages_entry(pdf); /* one level higher needed */
for (p = pe; p != NULL; p = p->next) {
if (q->number_of_kids == PAGES_TREE_KIDSMAX) {
q->next = new_pages_entry(pdf);
@@ -259,7 +217,7 @@ static int output_pages_list(PDF pdf, pages_entry * pe)
q->number_of_pages += p->number_of_pages;
write_pages(pdf, p, q->objnum);
}
- return output_pages_list(pdf, r); /* recurse through next higher level */
+ return output_pages_list(pdf, r); /* recurse through next higher level */
}
@ @c
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfrule.h b/Build/source/texk/web2c/luatexdir/pdf/pdfrule.h
index 3770b2cbbe5..c0d68fd44b0 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfrule.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfrule.h
@@ -15,12 +15,13 @@
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/>.
+*/
#ifndef PDFRULE_H
# define PDFRULE_H
-void pdf_place_rule(PDF pdf, halfword p, scaledpos size);
+void pdf_place_rule(PDF pdf, halfword p, scaledpos size, int callback_id);
#endif
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w b/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w
index a9d670c1154..e4897dfb04b 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w
@@ -18,13 +18,14 @@
% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
-
-
#include "ptexlib.h"
#include "pdf/pdfpage.h"
@ @c
-void pdf_place_rule(PDF pdf, halfword q, scaledpos size)
+
+/* maybe we should have an extra callback on normal rules or on any rule in 2.0+ */
+
+void pdf_place_rule(PDF pdf, halfword q, scaledpos size, int callback_id)
{
pdfpos dim;
pdfstructure *p = pdf->pstruct;
@@ -36,6 +37,14 @@ void pdf_place_rule(PDF pdf, halfword q, scaledpos size)
pdf_place_image(pdf,q);
} else if (subtype(q) == empty_rule) {
/* place nothing, only take space */
+ } else if (subtype(q) == user_rule) {
+ if (callback_id != 0) {
+ pdf_goto_pagemode(pdf);
+ pdf_puts(pdf, "q\n");
+ pdf_set_pos_temp(pdf, pos);
+ run_callback(callback_id, "Ndd->",q,size.h,size.v);
+ pdf_puts(pdf, "\nQ\n");
+ }
} else {
/* normal_rule or >= 100 being a leader rule */
pdf_goto_pagemode(pdf);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.h b/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.h
index e45902328c8..3e1e1ef061e 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.h
@@ -15,20 +15,22 @@
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/>.
+*/
#ifndef PDFSAVERESTORE_H
# define PDFSAVERESTORE_H
/* stack for positions of \pdfsave */
+
typedef struct {
scaledpos pos;
int matrix_stack;
} pos_entry;
-extern pos_entry *pos_stack; /* the stack */
-extern int pos_stack_size; /* initially empty */
-extern int pos_stack_used; /* used entries */
+
+extern pos_entry *pos_stack; /* the stack */
+extern int pos_stack_size; /* initially empty */
+extern int pos_stack_used; /* used entries */
extern void pdf_out_save(PDF pdf, halfword p);
extern void pdf_out_restore(PDF pdf, halfword p);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w b/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w
index 4c88dec6182..0d91de54496 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w
@@ -19,24 +19,21 @@
@ @c
-
#include "ptexlib.h"
@ @c
-pos_entry *pos_stack = 0; /* the stack */
-int pos_stack_size = 0; /* initially empty */
-int pos_stack_used = 0; /* used entries */
+pos_entry *pos_stack = 0; /* the stack */
+int pos_stack_size = 0; /* initially empty */
+int pos_stack_used = 0; /* used entries */
@ @c
static void checkpdfsave(scaledpos pos)
{
pos_entry *new_stack;
-
if (pos_stack_used >= pos_stack_size) {
pos_stack_size += STACK_INCREMENT;
new_stack = xtalloc((unsigned) pos_stack_size, pos_entry);
- memcpy((void *) new_stack, (void *) pos_stack,
- (unsigned) pos_stack_used * sizeof(pos_entry));
+ memcpy((void *) new_stack, (void *) pos_stack, (unsigned) pos_stack_used * sizeof(pos_entry));
xfree(pos_stack);
pos_stack = new_stack;
}
@@ -53,21 +50,20 @@ static void checkpdfrestore(scaledpos pos)
{
scaledpos diff;
if (pos_stack_used == 0) {
- luatex_warn("%s", "'restore' is missing a 'save'");
+ normal_warning("pdf backend", "'restore' is missing a 'save'");
return;
}
pos_stack_used--;
diff.h = pos.h - pos_stack[pos_stack_used].pos.h;
diff.v = pos.v - pos_stack[pos_stack_used].pos.v;
if (diff.h != 0 || diff.v != 0) {
- luatex_warn("misplaced 'restore' by (%dsp, %dsp)", (int) diff.h, (int) diff.v);
+ formatted_warning("pdf backend","misplaced 'restore' by (%dsp, %dsp)", (int) diff.h, (int) diff.v);
}
if (global_shipping_mode == SHIPPING_PAGE) {
matrix_stack_used = pos_stack[pos_stack_used].matrix_stack;
}
}
-
@ @c
void pdf_out_save(PDF pdf, halfword p)
{
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.h b/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.h
index c65e0ea8b8a..59fd1f69cdc 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.h
@@ -15,8 +15,8 @@
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/>.
+*/
#ifndef PDFSETMATRIX_H
# define PDFSETMATRIX_H
@@ -36,7 +36,6 @@ extern matrix_entry *matrix_stack;
extern int matrix_stack_size;
extern int matrix_stack_used;
-
scaled getllx(void);
scaled getlly(void);
scaled geturx(void);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w b/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w
index ba9317e776d..b107033b984 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w
@@ -19,7 +19,6 @@
@ @c
-
#include "ptexlib.h"
@ stack for \.{\\pdfextension setmatrix}
@@ -38,34 +37,28 @@ boolean matrixused(void)
static void matrix_stack_room(void)
{
matrix_entry *new_stack;
-
if (matrix_stack_used >= matrix_stack_size) {
matrix_stack_size += STACK_INCREMENT;
new_stack = xtalloc((unsigned) matrix_stack_size, matrix_entry);
- memcpy((void *) new_stack, (void *) matrix_stack,
- (unsigned) matrix_stack_used * sizeof(matrix_entry));
+ memcpy((void *) new_stack, (void *) matrix_stack, (unsigned) matrix_stack_used * sizeof(matrix_entry));
xfree(matrix_stack);
matrix_stack = new_stack;
}
}
-@ \.{\\pdfextension setmatrix{a b c d}}
+@ \.{\\pdfextension setmatrix{a b c d}}
- |e| := pos.h
+|e| := pos.h
- |f| := pos.v
+|f| := pos.v
- |M_top|: current active matrix at the top of
- the matrix stack
+|M_top|: current active matrix at the top of the matrix stack
- The origin of \.{\\pdfextension setmatrix} is the current point.
- The annotation coordinate system is the original
- page coordinate system. When pdfTeX calculates
- annotation rectangles it does not take into
- account this transformations, it uses the original
- coordinate system. To get the corrected values,
- first we go back to the origin, perform the
- transformation and go back:
+The origin of \.{\\pdfextension setmatrix} is the current point. The annotation
+coordinate system is the original page coordinate system. When pdfTeX calculates
+annotation rectangles it does not take into account this transformations, it uses
+the original coordinate system. To get the corrected values, first we go back to
+the origin, perform the transformation and go back:
{\obeylines\obeyspaces\tt
( 1 0 0 ) ( a b 0 ) ( 1 0 0 )
@@ -84,15 +77,14 @@ static void matrix_stack_room(void)
@c
static void pdfsetmatrix(const char *in, scaledpos pos)
{
- /* Argument of \.{\\pdfextension setmatrix} starts with |str_pool[in]| and ends
- before |str_pool[pool_ptr]|. */
-
+ /*
+ Argument of \.{\\pdfextension setmatrix} starts with |str_pool[in]| and ends
+ before |str_pool[pool_ptr]|.
+ */
matrix_entry x, *y, *z;
-
if (global_shipping_mode == SHIPPING_PAGE) {
- if (sscanf((const char *) in, " %lf %lf %lf %lf ",
- &x.a, &x.b, &x.c, &x.d) != 4) {
- luatex_warn("unrecognized format of setmatrix: {%s}", in);
+ if (sscanf((const char *) in, " %lf %lf %lf %lf ", &x.a, &x.b, &x.c, &x.d) != 4) {
+ formatted_warning("pdf backend","unrecognized format of setmatrix: %s", in);
return;
}
/* calculate this transformation matrix */
@@ -130,8 +122,9 @@ static void pdfsetmatrix(const char *in, scaledpos pos)
If \.{\\pdfextension setmatrix} wasn't used, then return the value unchanged.
+@ Return values for matrix tranform functions:
+
@c
-/* Return values for matrix tranform functions */
static scaled ret_llx;
static scaled ret_lly;
static scaled ret_urx;
@@ -181,7 +174,6 @@ static void do_matrixtransform(scaled x, scaled y, scaled * retx, scaled * rety)
void matrixtransformrect(scaled llx, scaled lly, scaled urx, scaled ury)
{
scaled x1, x2, x3, x4, y1, y2, y3, y4;
-
if (global_shipping_mode == SHIPPING_PAGE && matrix_stack_used > 0) {
last_llx = llx;
last_lly = lly;
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.h b/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.h
index b341f818099..8fb073da4c2 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.h
@@ -15,14 +15,15 @@
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/>.
+*/
#ifndef PDFSHIPOUT_H
# define PDFSHIPOUT_H
-extern shipping_mode_e global_shipping_mode; /* set to |shipping_mode| when |ship_out| starts */
-extern scaledpos shipbox_refpos; /* for \gleaders */
+extern shipping_mode_e global_shipping_mode; /* set to |shipping_mode| when |ship_out| starts */
+extern scaledpos shipbox_refpos; /* for \gleaders */
extern void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w b/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w
index b75cb339c13..d60b4a0dc75 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w
@@ -23,48 +23,46 @@
@ @c
#define count(A) eqtb[count_base+(A)].cint
-#define h_offset dimen_par(h_offset_code)
-#define mag int_par(mag_code)
+
+#define mag int_par(mag_code)
+#define h_offset dimen_par(h_offset_code)
#define page_bottom_offset dimen_par(page_bottom_offset_code)
-#define page_direction int_par(page_direction_code)
-#define page_height dimen_par(page_height_code)
-#define page_left_offset dimen_par(page_left_offset_code)
-#define page_right_offset dimen_par(page_right_offset_code)
-#define page_top_offset dimen_par(page_top_offset_code)
-#define page_width dimen_par(page_width_code)
-#define tracing_output int_par(tracing_output_code)
-#define tracing_stats int_par(tracing_stats_code)
-#define v_offset dimen_par(v_offset_code)
+#define page_height dimen_par(page_height_code)
+#define page_left_offset dimen_par(page_left_offset_code)
+#define page_right_offset dimen_par(page_right_offset_code)
+#define page_top_offset dimen_par(page_top_offset_code)
+#define page_width dimen_par(page_width_code)
+#define tracing_output int_par(tracing_output_code)
+#define tracing_stats int_par(tracing_stats_code)
+#define v_offset dimen_par(v_offset_code)
scaledpos shipbox_refpos;
-@ |ship_out| is used to shipout a box to PDF or DVI mode.
-If |shipping_mode| is set to |SHIPPING_FORM| then the output will be a Form object
-(only PDF), and if it is set to |SHIPPING_PAGE| it will be a Page object.
+@ |ship_out| is used to shipout a box to PDF or DVI mode. If |shipping_mode| is
+set to |SHIPPING_FORM| then the output will be a Form object (only PDF), and if
+it is set to |SHIPPING_PAGE| it will be a Page object.
@c
void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
{
- /* output the box |p| */
- int j, k; /* indices to first ten count registers */
+ int j, k; /* indices to first ten count registers */
int post_callback_id;
int pre_callback_id;
- posstructure refpoint; /* the origin pos. on the page */
+ posstructure refpoint; /* the origin pos. on the page */
+ int rule_callback_id = 0;
scaledpos cur = { 0, 0 };
refpoint.pos.h = 0;
refpoint.pos.v = 0;
-
ensure_output_state(pdf, ST_HEADER_WRITTEN);
- fix_o_mode(); /* this is only for complaining if \.{\\outputmode} has changed */
+ fix_o_mode(); /* this is only for complaining if \.{\\outputmode} has changed */
init_backend_functionpointers(output_mode_used);
-
pdf->f_cur = null_font;
-
- /* Start sheet {\sl Sync\TeX} information record */
- /* {\sl Sync\TeX}: we assume that |pdf_output| is properly set up */
+ /*
+ Start sheet {\sl Sync\TeX} information record; we assume that |pdf_output| is
+ properly set up.
+ */
if (int_par(synctex_code))
synctexsheet(mag);
-
pre_callback_id = callback_defined(start_page_number_callback);
post_callback_id = callback_defined(stop_page_number_callback);
if ((tracing_output > 0) && (pre_callback_id == 0)) {
@@ -99,20 +97,18 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
show_box(p);
end_diagnostic(true);
}
-
/* Ship box |p| out */
if (shipping_mode == SHIPPING_PAGE && box_dir(p) != page_direction)
- normal_warning("backend","pagedir differs from bodydir, the output may be placed wrongly on the page", true, true);
- /* Update the values of |max_h| and |max_v|; but if the page is too large, |goto done| */
- /* Sometimes the user will generate a huge page because other error messages
- are being ignored. Such pages are not output to the \.{dvi} file, since they
- may confuse the printing software. */
-
- if ((height(p) > max_dimen) || (depth(p) > max_dimen)
- || (height(p) + depth(p) + v_offset > max_dimen)
- || (width(p) + h_offset > max_dimen)) {
- const char *hlp[] =
- { "The page just created is more than 18 feet tall or",
+ normal_warning("backend","pagedir differs from bodydir, the output may be placed wrongly on the page");
+ /*
+ Update the values of |max_h| and |max_v|; but if the page is too large,
+ |goto done|. Sometimes the user will generate a huge page because other
+ error messages are being ignored. Such pages are not output to the
+ \.{dvi} file, since they may confuse the printing software.
+ */
+ if ((height(p) > max_dimen) || (depth(p) > max_dimen) || (height(p) + depth(p) + v_offset > max_dimen) || (width(p) + h_offset > max_dimen)) {
+ const char *hlp[] = {
+ "The page just created is more than 18 feet tall or",
"more than 18 feet wide, so I suspect something went wrong.",
NULL
};
@@ -129,136 +125,139 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
max_v = height(p) + depth(p) + v_offset;
if (width(p) + h_offset > max_h)
max_h = width(p) + h_offset;
-
/* Calculate page dimensions and margins */
if (global_shipping_mode == SHIPPING_PAGE) {
if (page_width > 0)
pdf->page_size.h = page_width;
else {
switch (page_direction) {
- case dir_TLT:
- pdf->page_size.h = width(p) + 2 * page_left_offset;
- break;
- case dir_TRT:
- pdf->page_size.h = width(p) + 2 * page_right_offset;
- break;
- case dir_LTL:
- pdf->page_size.h = height(p) + depth(p) + 2 * page_left_offset;
- break;
- case dir_RTT:
- pdf->page_size.h = height(p) + depth(p) + 2 * page_right_offset;
- break;
- default:
- assert(0);
+ case dir_TLT:
+ pdf->page_size.h = width(p) + 2 * page_left_offset;
+ break;
+ case dir_TRT:
+ pdf->page_size.h = width(p) + 2 * page_right_offset;
+ break;
+ case dir_LTL:
+ pdf->page_size.h = height(p) + depth(p) + 2 * page_left_offset;
+ break;
+ case dir_RTT:
+ pdf->page_size.h = height(p) + depth(p) + 2 * page_right_offset;
+ break;
+ default:
+ pdf->page_size.h = width(p) + 2 * page_left_offset;
+ normal_warning("pdf backend","bad page direction, assuming TLT, case 1");
}
}
if (page_height > 0)
pdf->page_size.v = page_height;
else {
switch (page_direction) {
- case dir_TLT:
- case dir_TRT:
- pdf->page_size.v = height(p) + depth(p) + 2 * page_top_offset;
+ case dir_TLT:
+ case dir_TRT:
+ pdf->page_size.v = height(p) + depth(p) + 2 * page_top_offset;
+ break;
+ case dir_LTL:
+ case dir_RTT:
+ pdf->page_size.v = width(p) + 2 * page_top_offset;
+ break;
+ default:
+ pdf->page_size.v = height(p) + depth(p) + 2 * page_top_offset;
+ normal_warning("pdf backend","bad page direction, assuming TLT, case 2");
+ }
+ }
+ /*
+ Think in upright page/paper coordinates (page origin = lower left edge).
+ First preset |refpoint.pos| to the DVI origin (near upper left page edge).
+ */
+ switch (output_mode_used) {
+ case OMODE_DVI:
+ /* hh: how can we end up here? */
+ refpoint.pos.h = one_true_inch;
+ refpoint.pos.v = pdf->page_size.v - one_true_inch;
+ dvi = refpoint.pos;
break;
- case dir_LTL:
- case dir_RTT:
- pdf->page_size.v = width(p) + 2 * page_top_offset;
+ case OMODE_PDF:
+ refpoint.pos.h = pdf_h_origin;
+ refpoint.pos.v = pdf->page_size.v - pdf_v_origin;
break;
default:
- assert(0);
- }
- }
-
- /* Think in upright page/paper coordinates (page origin = lower left edge).
- First preset |refpoint.pos| to the DVI origin (near upper left page edge). */
-
- switch (output_mode_used) {
- case OMODE_DVI:
- /* hh: how can we end up here? */
- refpoint.pos.h = one_true_inch;
- refpoint.pos.v = pdf->page_size.v - one_true_inch;
- dvi = refpoint.pos;
- break;
- case OMODE_PDF:
- refpoint.pos.h = pdf_h_origin;
- refpoint.pos.v = pdf->page_size.v - pdf_v_origin;
- break;
- default:
- assert(0);
+ normal_error("pdf backend", "unknown output mode");
}
- /* Then shift |refpoint.pos| of the DVI origin depending on the
- |page_direction| within the upright (TLT) page coordinate system */
-
+ /*
+ Then shift |refpoint.pos| of the DVI origin depending on the
+ |page_direction| within the upright (TLT) page coordinate system
+ */
switch (page_direction) {
- case dir_TLT:
- case dir_LTL:
- refpoint.pos.h += h_offset;
- refpoint.pos.v -= v_offset;
- break;
- case dir_TRT:
- case dir_RTT:
- refpoint.pos.h +=
- pdf->page_size.h - page_right_offset - one_true_inch;
- refpoint.pos.v -= v_offset;
- break;
- default:
- assert(0);
+ case dir_TLT:
+ case dir_LTL:
+ refpoint.pos.h += h_offset;
+ refpoint.pos.v -= v_offset;
+ break;
+ case dir_TRT:
+ case dir_RTT:
+ refpoint.pos.h += pdf->page_size.h - page_right_offset - one_true_inch;
+ refpoint.pos.v -= v_offset;
+ break;
+ default:
+ refpoint.pos.h += h_offset;
+ refpoint.pos.v -= v_offset;
+ normal_warning("pdf backend","bad page direction, assuming TLT, case 3");
}
-
- /* Then switch to page box coordinate system; do |height(p)| movement,
- to get the location of the box origin. */
-
+ /*
+ Then switch to page box coordinate system; do |height(p)| movement,
+ to get the location of the box origin.
+ */
pdf->posstruct->dir = page_direction;
cur.h = 0;
cur.v = height(p);
synch_pos_with_cur(pdf->posstruct, &refpoint, cur);
- } else { /* shipping a /Form */
- assert(output_mode_used == OMODE_PDF);
+ } else {
+ /* shipping a /Form */
pdf->posstruct->dir = box_dir(p);
switch (pdf->posstruct->dir) {
- case dir_TLT:
- case dir_TRT:
- pdf->page_size.h = width(p);
- pdf->page_size.v = height(p) + depth(p);
- break;
- case dir_LTL:
- case dir_RTT:
- pdf->page_size.h = height(p) + depth(p);
- pdf->page_size.v = width(p);
- break;
- default:
- assert(0);
- }
+ case dir_TLT:
+ case dir_TRT:
+ pdf->page_size.h = width(p);
+ pdf->page_size.v = height(p) + depth(p);
+ break;
+ case dir_LTL:
+ case dir_RTT:
+ pdf->page_size.h = height(p) + depth(p);
+ pdf->page_size.v = width(p);
+ break;
+ default:
+ pdf->page_size.h = width(p);
+ pdf->page_size.v = height(p) + depth(p);
+ normal_warning("pdf backend","bad page direction, assuming TLT, case 4");
+ }
switch (pdf->posstruct->dir) {
- case dir_TLT:
- pdf->posstruct->pos.h = 0;
- pdf->posstruct->pos.v = depth(p);
- break;
- case dir_TRT:
- pdf->posstruct->pos.h = width(p);
- pdf->posstruct->pos.v = depth(p);
- break;
- case dir_LTL:
- pdf->posstruct->pos.h = height(p);
- pdf->posstruct->pos.v = width(p);
- break;
- case dir_RTT:
- pdf->posstruct->pos.h = depth(p);
- pdf->posstruct->pos.v = width(p);
- break;
- default:
- assert(0);
+ case dir_TLT:
+ pdf->posstruct->pos.h = 0;
+ pdf->posstruct->pos.v = depth(p);
+ break;
+ case dir_TRT:
+ pdf->posstruct->pos.h = width(p);
+ pdf->posstruct->pos.v = depth(p);
+ break;
+ case dir_LTL:
+ pdf->posstruct->pos.h = height(p);
+ pdf->posstruct->pos.v = width(p);
+ break;
+ case dir_RTT:
+ pdf->posstruct->pos.h = depth(p);
+ pdf->posstruct->pos.v = width(p);
+ break;
+ default:
+ pdf->posstruct->pos.h = 0;
+ pdf->posstruct->pos.v = depth(p);
+ normal_warning("pdf backend","bad page direction, assuming TLT, case 5");
}
}
-
/* Now we are at the point on the page where the origin of the page box should go. */
-
- shipbox_refpos = pdf->posstruct->pos; /* for \.{\\gleaders} */
-
+ shipbox_refpos = pdf->posstruct->pos; /* for \.{\\gleaders} */
switch (output_mode_used) {
case OMODE_DVI:
- assert(shipping_mode == SHIPPING_PAGE);
dvi_begin_page(pdf);
break;
case OMODE_PDF:
@@ -267,24 +266,21 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
default:
normal_error("pdf backend", "unknown output mode");
}
-
+ rule_callback_id = callback_defined(process_rule_callback);
switch (type(p)) {
case vlist_node:
- vlist_out(pdf, p);
+ vlist_out(pdf, p, rule_callback_id);
break;
case hlist_node:
- hlist_out(pdf, p);
+ hlist_out(pdf, p, rule_callback_id);
break;
default:
normal_error("pdf backend", "no vlist or hlist in (xform) shipout");
}
-
if (shipping_mode == SHIPPING_PAGE)
total_pages++;
cur_s = -1;
-
/* Finish shipping */
-
switch (output_mode_used) {
case OMODE_DVI:
dvi_end_page(pdf);
@@ -295,10 +291,8 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
default:
normal_error("pdf backend", "unknown output mode");
}
-
DONE:
- if ((tracing_output <= 0) && (post_callback_id == 0)
- && shipping_mode == SHIPPING_PAGE) {
+ if ((tracing_output <= 0) && (post_callback_id == 0) && shipping_mode == SHIPPING_PAGE) {
print_char(']');
update_terminal();
}
@@ -321,10 +315,8 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
}
if (shipping_mode == SHIPPING_PAGE && (post_callback_id > 0))
(void) run_callback(post_callback_id, "->");
-
/* Finish sheet {\sl Sync\TeX} information record */
if (int_par(synctex_code))
synctexteehs();
-
global_shipping_mode = NOT_SHIPPING;
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftables.h b/Build/source/texk/web2c/luatexdir/pdf/pdftables.h
index adcff69964c..f08195b4e04 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdftables.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdftables.h
@@ -15,8 +15,8 @@
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/>.
+*/
#ifndef PDFTABLES_H
# define PDFTABLES_H
@@ -33,52 +33,49 @@ typedef struct {
int int0;
char *str0;
} u;
- union_type u_type; /* integer or char * in union above */
+ union_type u_type; /* integer or char * in union above */
int objptr;
} oentry;
/*
-The cross-reference table |obj_tab| is an array of |obj_tab_size| of
-|obj_entry|. Each entry contains five integer fields and represents an object
-in PDF file whose object number is the index of this entry in |obj_tab|.
-Objects in |obj_tab| maybe linked into list; objects in such a linked list have
-the same type.
-*/
-/*
-The first field contains information representing identifier of this object.
-It is usally a number for most of object types, but it may be a string number
-for named destination or named thread.
+The cross-reference table |obj_tab| is an array of |obj_tab_size| of |obj_entry|.
+Each entry contains five integer fields and represents an object in PDF file
+whose object number is the index of this entry in |obj_tab|. Objects in |obj_tab|
+maybe linked into list; objects in such a linked list have the same type.
-The second field of |obj_entry| contains link to the next
-object in |obj_tab| if this object is linked in a list.
+The first field contains information representing identifier of this object. It
+is usally a number for most of object types, but it may be a string number for
+named destination or named thread.
-The third field holds the byte offset of the object in the output PDF file,
-or its byte offset within an object stream. As long as the object is not
-written, this field is used for flags about the write status of the object;
-then it has a negative value.
+The second field of |obj_entry| contains link to the next object in |obj_tab| if
+this object is linked in a list.
-The fourth field holds the object number of the object stream, into which
-the object is included.
+The third field holds the byte offset of the object in the output PDF file, or
+its byte offset within an object stream. As long as the object is not written,
+this field is used for flags about the write status of the object; then it has a
+negative value.
+
+The fourth field holds the object number of the object stream, into which the
+object is included.
+
+The last field usually represents the pointer to some auxiliary data structure
+depending on the object type; however it may be used as a counter as well.
-The last field usually represents the pointer to some auxiliary data
-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_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_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 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)
@@ -94,30 +91,25 @@ well.
# 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| */
+/*
+ NOTE: The data structure definitions for the nodes on the typesetting side are
+ inside |nodes.h|
+*/
-/* Some constants */
-# define inf_pk_dpi 72 /* min PK pixel density value from \.{texmf.cnf} */
-# define sup_pk_dpi 8000 /* max PK pixel density value from \.{texmf.cnf} */
+# define inf_pk_dpi 72 /* min PK pixel density value from \.{texmf.cnf} */
+# define sup_pk_dpi 8000 /* max PK pixel density value from \.{texmf.cnf} */
extern int find_obj(PDF pdf, int t, int i, boolean byname);
extern void check_obj_exists(PDF pdf, int objnum);
extern void check_obj_type(PDF pdf, int t, int objnum);
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 void set_rect_dimens(PDF pdf, halfword p, halfword parent_box,
- scaledpos cur, scaled_whd alt_rule, scaled margin);
-
+extern void set_rect_dimens(PDF pdf, halfword p, halfword parent_box, scaledpos cur, scaled_whd alt_rule, scaled margin);
extern void libpdffinish(PDF);
-extern void dump_pdftex_data(PDF pdf);
-extern void undump_pdftex_data(PDF pdf);
-
-# define set_width(A, B) width(A) = (B)
-# define set_height(A, B) height(A) = (B)
-# define set_depth(A, B) depth(A) = (B)
+# define set_width(A,B) width(A)=(B)
+# define set_height(A,B) height(A)=(B)
+# define set_depth(A,B) depth(A)=(B)
/* pdf backend definitions */
@@ -138,7 +130,6 @@ typedef enum {
c_pdf_objcompresslevel,
c_pdf_inclusion_copy_font,
c_pdf_gen_tounicode,
- c_pdf_replace_font,
} pdf_backend_counters ;
typedef enum {
@@ -158,6 +149,11 @@ typedef enum {
t_pdf_pk_mode,
} pdf_backend_tokenlists ;
+extern int pdf_last_annot;
+extern int pdf_last_link;
+extern int pdf_last_obj;
+extern int pdf_retval;
+
# define pdf_compress_level get_tex_extension_count_register(c_pdf_compress_level)
# define pdf_decimal_digits get_tex_extension_count_register(c_pdf_decimal_digits)
# define pdf_image_resolution get_tex_extension_count_register(c_pdf_image_resolution)
@@ -174,7 +170,6 @@ typedef enum {
# define pdf_objcompresslevel get_tex_extension_count_register(c_pdf_objcompresslevel)
# define pdf_inclusion_copy_font get_tex_extension_count_register(c_pdf_inclusion_copy_font)
# define pdf_gen_tounicode get_tex_extension_count_register(c_pdf_gen_tounicode)
-# define pdf_replace_font get_tex_extension_count_register(c_pdf_replace_font)
# define pdf_h_origin get_tex_extension_dimen_register(d_pdf_h_origin)
# define pdf_v_origin get_tex_extension_dimen_register(d_pdf_v_origin)
@@ -193,4 +188,6 @@ typedef enum {
# define set_pdf_compress_level(i) set_tex_extension_count_register(c_pdf_compress_level,i)
# define set_pdf_objcompresslevel(i) set_tex_extension_count_register(c_pdf_objcompresslevel,i)
-#endif /* PDFTABLES_H */
+# define set_pdf_decimal_digits(i) set_tex_extension_count_register(c_pdf_decimal_digits,i)
+
+#endif
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftables.w b/Build/source/texk/web2c/luatexdir/pdf/pdftables.w
index 72f0474e922..d8b5cf10321 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdftables.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdftables.w
@@ -19,54 +19,55 @@
@ @c
-
#include "ptexlib.h"
@ @c
-const char *pdf_obj_typenames[PDF_OBJ_TYPE_MAX + 1] =
- { "font", "outline", "dest", "obj", "xform", "ximage", "thread",
+const char *pdf_obj_typenames[PDF_OBJ_TYPE_MAX + 1] = {
+ "font", "outline", "dest", "obj", "xform", "ximage", "thread",
"pagestream", "page", "pages", "catalog", "info", "link", "annot", "annots",
"bead", "beads", "objstm", "others"
};
+int pdf_last_annot;
+int pdf_last_link;
+int pdf_last_obj;
+int pdf_retval; /* global multi-purpose return value */
+
@ AVL sort entry into |avl_table[]|
@c
static int compare_info(const void *pa, const void *pb, void *param)
{
- const oentry *a, *b;
+ const oentry *a = (const oentry *) pa;
+ const oentry *b = (const oentry *) pb;
(void) param;
- a = (const oentry *) pa;
- b = (const oentry *) pb;
if (a->u_type == b->u_type) {
if (a->u_type == union_type_int)
- return ((a->u.int0 <
- b->u.int0 ? -1 : (a->u.int0 > b->u.int0 ? 1 : 0)));
- else /* string type */
+ return ((a->u.int0 < b->u.int0 ? -1 : (a->u.int0 > b->u.int0 ? 1 : 0)));
+ else /* string type */
return strcmp(a->u.str0, b->u.str0);
- } else if (a->u_type == union_type_int)
+ } else if (a->u_type == union_type_int) {
return -1;
- else
+ } else {
return 1;
+ }
}
static void avl_put_obj(PDF pdf, int t, oentry * oe)
{
void **pp;
- assert(t >= 0 && t <= PDF_OBJ_TYPE_MAX);
if (pdf->obj_tree[t] == NULL) {
pdf->obj_tree[t] = avl_create(compare_info, NULL, &avl_xallocator);
if (pdf->obj_tree[t] == NULL)
- luatex_fail("avlstuff.c: avl_create() pdf->obj_tree failed");
+ formatted_error("pdf backend","avl_create() pdf->obj_tree failed");
}
pp = avl_probe(pdf->obj_tree[t], oe);
if (pp == NULL)
- luatex_fail("avlstuff.c: avl_probe() out of memory in insertion");
+ formatted_error("pdf backend","avl_probe() out of memory in insertion");
}
static void avl_put_int_obj(PDF pdf, int int0, int objptr, int t)
{
- oentry *oe;
- oe = xtalloc(1, oentry);
+ oentry *oe = xtalloc(1, oentry);
oe->u.int0 = int0;
oe->u_type = union_type_int;
oe->objptr = objptr;
@@ -75,8 +76,7 @@ static void avl_put_int_obj(PDF pdf, int int0, int objptr, int t)
static void avl_put_str_obj(PDF pdf, char *str0, int objptr, int t)
{
- oentry *oe;
- oe = xtalloc(1, oentry);
+ oentry *oe = xtalloc(1, oentry);
oe->u.str0 = str0; /* no xstrdup() here */
oe->u_type = union_type_cstring;
oe->objptr = objptr;
@@ -87,7 +87,6 @@ static int avl_find_int_obj(PDF pdf, int t, int i)
{
oentry *p;
oentry tmp;
- assert(t >= 0 && t <= PDF_OBJ_TYPE_MAX);
tmp.u.int0 = i;
tmp.u_type = union_type_int;
if (pdf->obj_tree[t] == NULL)
@@ -102,7 +101,6 @@ static int avl_find_str_obj(PDF pdf, int t, char *s)
{
oentry *p;
oentry tmp;
- assert(t >= 0 && t <= PDF_OBJ_TYPE_MAX);
tmp.u.str0 = s;
tmp.u_type = union_type_cstring;
if (pdf->obj_tree[t] == NULL)
@@ -128,9 +126,7 @@ int pdf_create_obj(PDF pdf, int t, int i)
pdf->obj_tab_size = pdf->obj_tab_size + a;
else
pdf->obj_tab_size = sup_obj_tab_size;
- pdf->obj_tab =
- xreallocarray(pdf->obj_tab, obj_entry,
- (unsigned) pdf->obj_tab_size);
+ pdf->obj_tab = xreallocarray(pdf->obj_tab, obj_entry, (unsigned) pdf->obj_tab_size);
}
pdf->obj_ptr++;
obj_info(pdf, pdf->obj_ptr) = i;
@@ -146,8 +142,7 @@ int pdf_create_obj(PDF pdf, int t, int i)
obj_link(pdf, pdf->obj_ptr) = pdf->head_tab[t];
pdf->head_tab[t] = pdf->obj_ptr;
if ((t == obj_type_dest) && (i < 0))
- append_dest_name(pdf, makecstring(-obj_info(pdf, pdf->obj_ptr)),
- pdf->obj_ptr);
+ append_dest_name(pdf, makecstring(-obj_info(pdf, pdf->obj_ptr)), pdf->obj_ptr); /* why not just -i */
}
return pdf->obj_ptr;
}
@@ -157,7 +152,6 @@ int find_obj(PDF pdf, int t, int i, boolean byname)
{
char *ss = NULL;
int ret;
- assert(i >= 0); /* no tricks */
if (byname) {
ss = makecstring(i);
ret = avl_find_str_obj(pdf, t, ss);
@@ -169,19 +163,17 @@ int find_obj(PDF pdf, int t, int i, boolean byname)
}
@ The following function finds an object with identifier |i| and type |t|.
- Identifier |i| is either an integer or a token list index. If no
- such object exists then it will be created. This function is used mainly to
- find destination for link annotations and outlines; however it is also used
- in |ship_out| (to check whether a Page object already exists) so we need
- to declare it together with subroutines needed in |hlist_out| and
- |vlist_out|.
+Identifier |i| is either an integer or a token list index. If no such object
+exists then it will be created. This function is used mainly to find destination
+for link annotations and outlines; however it is also used in |ship_out| (to
+check whether a Page object already exists) so we need to declare it together
+with subroutines needed in |hlist_out| and |vlist_out|.
@c
int pdf_get_obj(PDF pdf, int t, int i, boolean byname)
{
int r;
str_number s;
- assert(i >= 0);
if (byname > 0) {
s = tokens_to_string(i);
r = find_obj(pdf, t, s, true);
@@ -215,28 +207,22 @@ void check_obj_exists(PDF pdf, int objnum)
void check_obj_type(PDF pdf, int t, int objnum)
{
int u;
- char *s;
check_obj_exists(pdf, objnum);
u = obj_type(pdf, objnum);
if (t != u) {
- assert(t >= 0 && t <= PDF_OBJ_TYPE_MAX);
- assert(u >= 0 && u <= PDF_OBJ_TYPE_MAX);
- s = (char *) xtalloc(128, char);
- snprintf(s, 127, "referenced object has wrong type %s; should be %s",
- pdf_obj_typenames[u], pdf_obj_typenames[t]);
- normal_error("pdf backend", s);
+ formatted_error("pdf backend", "referenced object has wrong type %s; should be %s",
+ pdf_obj_typenames[u], pdf_obj_typenames[t]);
}
}
@ @c
-void set_rect_dimens(PDF pdf, halfword p, halfword parent_box, scaledpos cur,
- scaled_whd alt_rule, scaled margin)
+void set_rect_dimens(PDF pdf, halfword p, halfword parent_box, scaledpos cur, scaled_whd alt_rule, scaled margin)
{
- scaledpos ll, ur; /* positions relative to cur */
+ scaledpos ll, ur; /* positions relative to cur */
scaledpos pos_ll, pos_ur, tmp;
posstructure localpos;
localpos.dir = pdf->posstruct->dir;
- ll.h = 0; /* pdf contains current point on page */
+ ll.h = 0; /* pdf contains current point on page */
if (is_running(alt_rule.dp))
ll.v = depth(parent_box) - cur.v;
else
@@ -249,12 +235,10 @@ void set_rect_dimens(PDF pdf, halfword p, halfword parent_box, scaledpos cur,
ur.v = -height(parent_box) - cur.v;
else
ur.v = -alt_rule.ht;
-
synch_pos_with_cur(&localpos, pdf->posstruct, ll);
pos_ll = localpos.pos;
synch_pos_with_cur(&localpos, pdf->posstruct, ur);
pos_ur = localpos.pos;
-
if (pos_ll.h > pos_ur.h) {
tmp.h = pos_ll.h;
pos_ll.h = pos_ur.h;
@@ -292,148 +276,3 @@ void libpdffinish(PDF pdf)
glyph_unicode_free();
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
-of |pdf->mem| and |obj_tab| are retained, in the present implementation. We also
-retain three of the linked lists that start from |head_tab|, so that it is
-possible to, say, load an image in the \.{INITEX} run and then reference it in a
-\.{VIRTEX} run that uses the dumped format.
-
-@c
-void dump_pdftex_data(PDF pdf)
-{
- int k, x;
- pdf_object_list *l;
- dumpimagemeta(); /* the image information array */
- dump_int(pdf->mem_size);
- dump_int(pdf->mem_ptr);
- for (k = 1; k <= pdf->mem_ptr - 1; k++) {
- x = pdf->mem[k];
- dump_int(x);
- }
- print_ln();
- print_int(pdf->mem_ptr - 1);
- tprint(" words of pdf memory");
- x = pdf->obj_tab_size;
- dump_int(x);
- x = pdf->obj_ptr;
- dump_int(x);
- for (k = 1; k <= pdf->obj_ptr; k++) {
- x = obj_info(pdf, k);
- dump_int(x);
- x = obj_link(pdf, k);
- dump_int(x);
- x = obj_os_idx(pdf, k);
- dump_int(x);
- x = obj_aux(pdf, k);
- dump_int(x);
- x = obj_type(pdf, k);
- dump_int(x);
- }
- print_ln();
- print_int(pdf->obj_ptr);
- tprint(" indirect objects");
- dump_int(pdf->obj_count);
- dump_int(pdf->xform_count);
- dump_int(pdf->ximage_count);
- if ((l = get_page_resources_list(pdf, obj_type_obj)) != NULL) {
- while (l != NULL) {
- dump_int(l->info);
- l = l->link;
- }
- }
- dump_int(0); /* signal end of |obj_list| */
- if ((l = get_page_resources_list(pdf, obj_type_xform)) != NULL) {
- while (l != NULL) {
- dump_int(l->info);
- l = l->link;
- }
- }
- dump_int(0); /* signal end of |xform_list| */
- if ((l = get_page_resources_list(pdf, obj_type_ximage)) != NULL) {
- while (l != NULL) {
- dump_int(l->info);
- l = l->link;
- }
- }
- dump_int(0); /* signal end of |ximage_list| */
- x = pdf->head_tab[obj_type_obj];
- dump_int(x);
- x = pdf->head_tab[obj_type_xform];
- dump_int(x);
- x = pdf->head_tab[obj_type_ximage];
- dump_int(x);
- dump_int(pdf_last_obj);
- dump_int(last_saved_box_index);
- dump_int(last_saved_image_index);
-}
-
-@ And restoring the pdftex data structures from the format. The
-two function arguments to |undumpimagemeta| have been restored
-already in an earlier module.
-
-@c
-void undump_pdftex_data(PDF pdf)
-{
- int k, x;
- undumpimagemeta(pdf, pdf_minor_version, pdf_inclusion_errorlevel); /* the image information array */
- undump_int(pdf->mem_size);
- pdf->mem = xreallocarray(pdf->mem, int, (unsigned) pdf->mem_size);
- undump_int(pdf->mem_ptr);
- for (k = 1; k <= pdf->mem_ptr - 1; k++) {
- undump_int(x);
- pdf->mem[k] = (int) x;
- }
- undump_int(x);
- pdf->obj_tab_size = x;
- undump_int(x);
- pdf->obj_ptr = x;
- for (k = 1; k <= pdf->obj_ptr; k++) {
- undump_int(x);
- obj_info(pdf, k) = x;
- undump_int(x);
- obj_link(pdf, k) = x;
- set_obj_offset(pdf, k, -1);
- undump_int(x);
- obj_os_idx(pdf, k) = x;
- undump_int(x);
- obj_aux(pdf, k) = x;
- undump_int(x);
- obj_type(pdf, k) = x;
- }
-
- undump_int(x);
- pdf->obj_count = x;
- undump_int(x);
- pdf->xform_count = x;
- undump_int(x);
- pdf->ximage_count = x;
- /* todo : the next 3 loops can be done much more efficiently */
- undump_int(x);
- while (x != 0) {
- addto_page_resources(pdf, obj_type_obj, x);
- undump_int(x);
- }
- undump_int(x);
- while (x != 0) {
- addto_page_resources(pdf, obj_type_xform, x);
- undump_int(x);
- }
- undump_int(x);
- while (x != 0) {
- addto_page_resources(pdf, obj_type_ximage, x);
- undump_int(x);
- }
-
- undump_int(x);
- pdf->head_tab[obj_type_obj] = x;
- undump_int(x);
- pdf->head_tab[obj_type_xform] = x;
- undump_int(x);
- pdf->head_tab[obj_type_ximage] = x;
- undump_int(pdf_last_obj);
- undump_int(last_saved_box_index);
- undump_int(last_saved_image_index);
-}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfthread.h b/Build/source/texk/web2c/luatexdir/pdf/pdfthread.h
index 5719803b86f..dd9078444fc 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfthread.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfthread.h
@@ -15,7 +15,8 @@
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/>.
+*/
#ifndef PDFTHREAD_H
@@ -23,34 +24,36 @@
/* data structure of threads; words 1..4 represent the coordinates of the corners */
-# define obj_thread_first obj_aux /* pointer to the first bead */
+# define obj_thread_first obj_aux /* pointer to the first bead */
/* data structure of beads */
-# define pdfmem_bead_size 5 /* size of memory in |pdf->mem| which |obj_bead_ptr| points to */
+# define pdfmem_bead_size 5 /* size of memory in |pdf->mem| which |obj_bead_ptr| points to */
-# define set_pdf_thread_attr(A,B) pdf_thread_attr(A)=B
-# define set_pdf_thread_id(A,B) pdf_thread_id(A)=B
-# define set_pdf_thread_named_id(A,B) pdf_thread_named_id(A)=B
+# define set_pdf_thread_attr(A,B) pdf_thread_attr(A)=B
+# define set_pdf_thread_id(A,B) pdf_thread_id(A)=B
+# define set_pdf_thread_named_id(A,B) pdf_thread_named_id(A)=B
-# define obj_bead_ptr obj_aux /* pointer to |pdf->mem| */
+# define obj_bead_ptr obj_aux /* pointer to |pdf->mem| */
# define obj_bead_rect(pdf,A) pdf->mem[obj_bead_ptr(pdf,A)]
# define obj_bead_page(pdf,A) pdf->mem[obj_bead_ptr(pdf,A) + 1]
# define obj_bead_next(pdf,A) pdf->mem[obj_bead_ptr(pdf,A) + 2]
# define obj_bead_prev(pdf,A) pdf->mem[obj_bead_ptr(pdf,A) + 3]
# define obj_bead_attr(pdf,A) pdf->mem[obj_bead_ptr(pdf,A) + 4]
+# define obj_bead_data obj_bead_rect
+# define set_obj_bead_data set_obj_bead_rect
-# define set_obj_bead_rect(pdf,A,B) obj_bead_rect(pdf,A)=B
-# define set_obj_bead_page(pdf,A,B) obj_bead_page(pdf,A)=B
-# define set_obj_bead_next(pdf,A,B) obj_bead_next(pdf,A)=B
-# define set_obj_bead_prev(pdf,A,B) obj_bead_prev(pdf,A)=B
-# define set_obj_bead_attr(pdf,A,B) obj_bead_attr(pdf,A)=B
+# define set_obj_bead_rect(pdf,A,B) obj_bead_rect(pdf,A)=B
+# define set_obj_bead_page(pdf,A,B) obj_bead_page(pdf,A)=B
+# define set_obj_bead_next(pdf,A,B) obj_bead_next(pdf,A)=B
+# define set_obj_bead_prev(pdf,A,B) obj_bead_prev(pdf,A)=B
+# define set_obj_bead_attr(pdf,A,B) obj_bead_attr(pdf,A)=B
-/* pointer to the corresponding whatsit node; |obj_bead_rect| is needed only when the bead
- rectangle has been written out and after that |obj_bead_data| is not needed any more
- so we can use this field for both */
-# define obj_bead_data obj_bead_rect
-# define set_obj_bead_data set_obj_bead_rect
+/*
+ pointer to the corresponding whatsit node; |obj_bead_rect| is needed only when the bead
+ rectangle has been written out and after that |obj_bead_data| is not needed any more
+ so we can use this field for both
+*/
extern void append_bead(PDF pdf, halfword p);
extern void do_thread(PDF pdf, halfword parent_box, halfword p, scaledpos cur);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w b/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w
index 85f7007aa67..b11e48c5fc0 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w
@@ -19,7 +19,6 @@
@ @c
-
#include "ptexlib.h"
@ @c
@@ -32,9 +31,8 @@ void append_bead(PDF pdf, halfword p)
{
int a, b, c, t;
if (global_shipping_mode == SHIPPING_FORM)
- normal_error("pdf backend", "threads cannot be inside an XForm");
- t = pdf_get_obj(pdf, obj_type_thread, pdf_thread_id(p),
- pdf_thread_named_id(p));
+ normal_error("pdf backend", "threads cannot be inside an xform");
+ 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);
@@ -87,9 +85,8 @@ void do_thread(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
@ @c
void append_thread(PDF pdf, halfword parent_box, scaledpos cur)
{
- halfword p;
scaled_whd alt_rule;
- p = new_node(whatsit_node, pdf_thread_data_node);
+ halfword p = new_node(whatsit_node, pdf_thread_data_node);
width(p) = pdf->thread.wd;
height(p) = pdf->thread.ht;
depth(p) = pdf->thread.dp;
@@ -119,18 +116,18 @@ void end_thread(PDF pdf, halfword p)
normal_error("pdf backend", "'endthread' ended up in different nesting level than 'startthread'");
if (is_running(pdf->thread.dp) && (pdf->last_thread != null)) {
switch (pdf->posstruct->dir) {
- case dir_TLT:
- case dir_TRT:
- pdf_ann_bottom(pdf->last_thread) = pos.v - pdf_thread_margin;
- break;
- case dir_LTL:
- pdf_ann_right(pdf->last_thread) = pos.h + pdf_thread_margin;
- break;
- case dir_RTT:
- pdf_ann_left(pdf->last_thread) = pos.h - pdf_thread_margin;
- break;
- default:
- assert(0);
+ case dir_TLT:
+ case dir_TRT:
+ pdf_ann_bottom(pdf->last_thread) = pos.v - pdf_thread_margin;
+ break;
+ case dir_LTL:
+ pdf_ann_right(pdf->last_thread) = pos.h + pdf_thread_margin;
+ break;
+ case dir_RTT:
+ pdf_ann_left(pdf->last_thread) = pos.h - pdf_thread_margin;
+ break;
+ default:
+ formatted_warning("pdf backend","forcing bad dir %i to TLT in end tread",pdf->posstruct->dir);
}
}
if (pdf->last_thread_named_id)
@@ -154,18 +151,12 @@ void thread_title(PDF pdf, int t)
void pdf_fix_thread(PDF pdf, int t)
{
halfword a;
- normal_warning("pdf backend", "thread destination", false, false);
if (obj_info(pdf, t) < 0) {
- tprint("name{");
- print(-obj_info(pdf, t));
- tprint("}");
+ char *ss = makecstring(-obj_info(pdf, t));
+ formatted_warning("pdf backend", "unknown thread destination name '%s'",ss);
} else {
- tprint("num");
- print_int(obj_info(pdf, t));
+ formatted_warning("pdf backend", "unknown thread destination num '%d'",obj_info(pdf, t));
}
- tprint(" has been referenced but does not exist, replaced by a fixed one");
- print_ln();
- print_ln();
a = pdf_create_obj(pdf, obj_type_others, 0);
pdf_begin_obj(pdf, a, OBJSTM_ALWAYS);
pdf_begin_dict(pdf);
@@ -182,7 +173,6 @@ void pdf_fix_thread(PDF pdf, int t)
pdf_end_array(pdf);
pdf_end_dict(pdf);
pdf_end_obj(pdf);
-
pdf_begin_obj(pdf, t, OBJSTM_ALWAYS);
pdf_begin_dict(pdf);
pdf_add_name(pdf, "I");
@@ -250,7 +240,7 @@ void scan_thread_id(void)
set_pdf_thread_id(cur_list.tail_field, cur_val);
set_pdf_thread_named_id(cur_list.tail_field, 0);
} else if (scan_keyword("name")) {
- scan_pdf_ext_toks();
+ scan_toks(false, true);
set_pdf_thread_id(cur_list.tail_field, def_ref);
set_pdf_thread_named_id(cur_list.tail_field, 1);
} else {
@@ -276,9 +266,9 @@ void print_bead_rectangles(PDF 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 */
+ i = obj_bead_data(pdf, k->info); /* pointer to a whatsit or whatsit-like node */
pdf_add_rect_spec(pdf, i);
- if (subtype(i) == pdf_thread_data_node) /* thanh says it mis be destroyed here */
+ if (subtype(i) == pdf_thread_data_node)
flush_node(i);
pdf_end_array(pdf);
pdf_end_obj(pdf);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h b/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h
index b25d74d1cc9..f3dafb0ce35 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h
@@ -15,7 +15,9 @@
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/>.
+
+*/
#ifndef PDFTYPES_H
# define PDFTYPES_H
@@ -26,26 +28,27 @@
# 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. */
+/*
+ The prefix "PTEX" for the PDF keys is special to pdfTeX and has been registered with
+ Adobe by Hans Hagen.
+*/
# define pdfkeyprefix "PTEX"
# define i32round(a) (int) floor((a) + 0.5)
# define i64round(a) (int64_t) 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 */
+# 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 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 */
+ NO_ZIP, /* no \.{ZIP} compression */
+ ZIP_WRITING, /* \.{ZIP} compression being used */
+ ZIP_FINISH /* finish \.{ZIP} compression */
} zip_write_state_e;
typedef enum {
@@ -53,19 +56,21 @@ typedef enum {
OBJSTM_BUF,
} buffer_e;
-/* This stucture holds everything that is needed for the actual pdf generation.
+/*
+ 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|
+ here (C++ has a boolean type built-in that is not compatible). Also, I have
+ plans to convert the backend code into a C library for use with e.g. standalone
+ lua. Together, this means that it is best only to use the standard C types and
+ 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.
-Because this structure interfaces with C++, it is not wise to use |boolean|
-here (C++ has a boolean type built-in that is not compatible). Also, I have
-plans to convert the backend code into a C library for use with e.g. standalone
-lua. Together, this means that it is best only to use the standard C types and
-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 {
- int64_t m; /* mantissa (significand) */
- int e; /* exponent * -1 */
+ int64_t m; /* mantissa (significand) */
+ int e; /* exponent * -1 */
} pdffloat;
typedef struct {
@@ -81,26 +86,35 @@ typedef struct scaledpos_ {
} scaledpos;
typedef struct scaled_whd_ {
- scaled wd; /* TeX width */
- scaled ht; /* TeX height */
- scaled dp; /* TeX depth */
+ scaled wd; /* TeX width */
+ scaled ht; /* TeX height */
+ scaled dp; /* TeX depth */
} scaled_whd;
typedef struct posstructure_ {
- scaledpos pos; /* position on the page */
- int dir; /* direction of stuff to be put onto the page */
+ scaledpos pos; /* position on the page */
+ int dir; /* direction of stuff to be put onto the page */
} posstructure;
typedef struct {
- scaledpos curpos; /* \pdflastpos position */
- posstructure boxpos; /* box dir and position of the box origin on the page */
- scaled_whd boxdim; /* box dimensions (in hlist/vlist coordinate system) */
+ scaledpos curpos; /* \pdflastpos position */
+ posstructure boxpos; /* box dir and position of the box origin on the page */
+ scaled_whd boxdim; /* box dimensions (in hlist/vlist coordinate system) */
} pos_info_structure;
-typedef enum { PMODE_NONE, PMODE_PAGE, PMODE_TEXT, PMODE_CHARARRAY, PMODE_CHAR
+typedef enum {
+ PMODE_NONE,
+ PMODE_PAGE,
+ PMODE_TEXT,
+ PMODE_CHARARRAY,
+ PMODE_CHAR
} pos_mode;
-typedef enum { ST_INITIAL, ST_OMODE_FIX, ST_FILE_OPEN, ST_HEADER_WRITTEN,
+typedef enum {
+ ST_INITIAL,
+ ST_OMODE_FIX,
+ ST_FILE_OPEN,
+ ST_HEADER_WRITTEN,
ST_FILE_CLOSED
} output_state;
@@ -109,14 +123,16 @@ typedef struct pdf_object_list_ {
struct pdf_object_list_ *link;
} pdf_object_list;
-typedef enum { WMODE_H, WMODE_V } writing_mode; /* []TJ runs horizontal or vertical */
+typedef enum { /* []TJ runs horizontal or vertical */
+ WMODE_H,
+ WMODE_V
+} writing_mode;
typedef struct {
pdfpos pdf; /* pos. on page (PDF page raster) */
pdfpos pdf_bt_pos; /* pos. at begin of BT-ET group (PDF page raster) */
pdfpos pdf_tj_pos; /* pos. at begin of TJ array (PDF page raster) */
- pdffloat cw; /* pos. within [(..)..]TJ array (glyph raster);
- cw.e = fractional digits in /Widths array */
+ pdffloat cw; /* pos. within [(..)..]TJ array (glyph raster); cw.e = fractional digits in /Widths array */
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 */
@@ -155,7 +171,7 @@ typedef struct dest_name_entry_ {
int objnum; /* destination object number */
} dest_name_entry;
-# define pdf_max_link_level 10/* maximum depth of link nesting */
+# define pdf_max_link_level 10 /* maximum depth of link nesting */
typedef struct pdf_link_stack_record {
int nesting_level;
@@ -166,6 +182,12 @@ typedef struct pdf_link_stack_record {
} pdf_link_stack_record;
/* types of objects */
+
+/*
+ NB: |obj_type_thread| is the highest entry in |head_tab|, but there are a few
+ more linked lists that are handy.
+*/
+
typedef enum {
obj_type_font = 0, /* index of linked list of Fonts objects */
obj_type_outline = 1, /* index of linked list of outline objects */
@@ -174,8 +196,6 @@ typedef enum {
obj_type_xform = 4, /* index of linked list of XObject forms */
obj_type_ximage = 5, /* index of linked list of XObject images */
obj_type_thread = 6, /* index of linked list of num article threads */
- /* |obj_type_thread| is the highest entry in |head_tab|, but there are a few
- more linked lists that are handy: */
obj_type_pagestream = 7, /* Page stream objects */
obj_type_page = 8, /* /Page objects */
obj_type_pages = 9, /* /Pages objects */
@@ -198,7 +218,6 @@ 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;
@@ -222,10 +241,9 @@ typedef struct os_struct_ {
unsigned int o_ctr; /* statistics: counter for objects within object streams */
} os_struct;
-/**********************************************************************/
-# define packet_max_recursion 100 /* see |packet_cur_s| */
-# define packet_stack_size 100
+# define packet_max_recursion 100 /* see |packet_cur_s| */
+# define packet_stack_size 100
typedef struct packet_stack_record_ {
float c0;
@@ -247,8 +265,6 @@ typedef struct vf_struct_ {
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 */
@@ -265,7 +281,6 @@ typedef struct pdf_output_file_ {
int decimal_digits;
int gen_tounicode;
int inclusion_copy_font;
- int replace_font;
int minor_version; /* fixed minor part of the PDF version */
int compress_level; /* level for zlib object stream compression */
int objcompresslevel; /* fixed level for activating PDF object streams */
@@ -292,8 +307,7 @@ typedef struct pdf_output_file_ {
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| */
+ int pk_scale_factor; /* this is just a preprocessed value that depends on |pk_resolution| and |decimal_digits| */
int img_page_group_val; /* page group information pointer from included pdf or png images */
char *resname_prefix; /* global prefix of resources name */
@@ -320,10 +334,6 @@ typedef struct pdf_output_file_ {
int seek_write_length; /* flag whether to seek back and write \.{/Length} */
int last_byte; /* byte most recently written to PDF file; for \.{endstream} in new line */
- /* integer last_resources; halfword to most recently generated Resources object.
- TH: this used to be a local in pdf_shipout, but I would like to
- be able to split that function into a pre- and post part */
-
int obj_count;
int xform_count;
int ximage_count;
@@ -351,7 +361,6 @@ typedef struct pdf_output_file_ {
int thread_level; /* depth of nesting of box containing the last thread */
int f_cur; /* TeX font number */
- int pdflua_ref;
int cave; /* stay away from previous PDF object */
vf_struct *vfstruct;
@@ -359,4 +368,4 @@ typedef struct pdf_output_file_ {
typedef pdf_output_file *PDF;
-#endif /* PDFTYPES_H */
+#endif
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.h b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.h
index 9c62f71c0a2..f7f6e54d68f 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.h
@@ -15,44 +15,37 @@
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/>.
+*/
#ifndef PDFXFORM_H
# define PDFXFORM_H
-/* data structure for box resources */
-
-# define pdfmem_xform_size 8 /* size of memory in |pdf->mem| which |obj_data_ptr| holds */
-
-# define set_pdf_xform_objnum(A,B) pdf_xform_objnum(A)=B
-
-# define obj_xform_width(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 0]
-# define obj_xform_height(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 1]
-# define obj_xform_depth(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 2]
-# define obj_xform_box(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 3] /* this field holds
- pointer to the corresponding box */
-# define obj_xform_attr(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 4] /* additional xform
- attributes */
-# define obj_xform_resources(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 5] /* additional xform
- Resources */
-# define obj_xform_attr_str(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 6]
-# define obj_xform_resources_str(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 7]
-
-
-# define set_obj_xform_width(pdf,A,B) obj_xform_width(pdf,A)=B
-# define set_obj_xform_height(pdf,A,B) obj_xform_height(pdf,A)=B
-# define set_obj_xform_depth(pdf,A,B) obj_xform_depth(pdf,A)=B
-# define set_obj_xform_box(pdf,A,B) obj_xform_box(pdf,A)=B
-# define set_obj_xform_attr(pdf,A,B) obj_xform_attr(pdf,A)=B
-# define set_obj_xform_resources(pdf,A,B) obj_xform_resources(pdf,A)=B
-# define set_obj_xform_attr_str(pdf,A,B) obj_xform_attr_str(pdf,A)=B
+# define pdfmem_xform_size 8 /* size of memory in |pdf->mem| which |obj_data_ptr| holds */
+
+# define obj_xform_width(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 0]
+# define obj_xform_height(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 1]
+# define obj_xform_depth(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 2]
+# define obj_xform_box(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 3] /* this field holds pointer to the corresponding box */
+# define obj_xform_attr(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 4] /* additional xform attributes */
+# define obj_xform_resources(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 5] /* additional xform Resources */
+# define obj_xform_attr_str(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 6]
+# define obj_xform_resources_str(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 7]
+
+# define set_pdf_xform_objnum(A,B) pdf_xform_objnum(A)=B
+# define set_obj_xform_width(pdf,A,B) obj_xform_width(pdf,A)=B
+# define set_obj_xform_height(pdf,A,B) obj_xform_height(pdf,A)=B
+# define set_obj_xform_depth(pdf,A,B) obj_xform_depth(pdf,A)=B
+# define set_obj_xform_box(pdf,A,B) obj_xform_box(pdf,A)=B
+# define set_obj_xform_attr(pdf,A,B) obj_xform_attr(pdf,A)=B
+# define set_obj_xform_resources(pdf,A,B) obj_xform_resources(pdf,A)=B
+# define set_obj_xform_attr_str(pdf,A,B) obj_xform_attr_str(pdf,A)=B
# define set_obj_xform_resources_str(pdf,A,B) obj_xform_resources_str(pdf,A)=B
-extern int pdf_cur_form; /* the form being output */
+extern int pdf_cur_form; /* the form being output */
void pdf_place_form(PDF pdf, halfword p);
-
void scan_pdfxform(PDF pdf);
void scan_pdfrefxform(PDF pdf);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w
index 46a0910f6f7..962acb0f031 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w
@@ -73,14 +73,14 @@ void scan_pdfxform(PDF pdf)
k = pdf_create_obj(pdf, obj_type_xform, pdf->xform_count);
set_obj_data_ptr(pdf, k, pdf_get_mem(pdf, pdfmem_xform_size));
if (scan_keyword("attr")) {
- scan_pdf_ext_toks();
+ scan_toks(false, true);
set_obj_xform_attr(pdf, k, def_ref);
} else {
set_obj_xform_attr(pdf, k, null);
}
set_obj_xform_attr_str(pdf, k, null);
if (scan_keyword("resources")) {
- scan_pdf_ext_toks();
+ scan_toks(false, true);
set_obj_xform_resources(pdf, k, def_ref);
} else {
set_obj_xform_resources(pdf, k, null);