diff --git a/manual/luatex-callbacks.tex b/manual/luatex-callbacks.tex index 9be3e363547d2f14561f08f875917536eca410ba..965fba806293cdc6d770b864cffa96acd1e951c6 100644 --- a/manual/luatex-callbacks.tex +++ b/manual/luatex-callbacks.tex @@ -1038,7 +1038,7 @@ end This callback is called after the \PDF\ page stream has been assembled and before the page object gets finalized. -\subsection{\cbk {page_objnum_provider}} +\subsection{\cbk {page_order_index}} \topicindex{callbacks+\PDF\ file} @@ -1046,28 +1046,27 @@ This is one that experts can use to juggle the page tree, a data structure that determines the order in a \PDF\ file: \startfunctioncall -function(objnum) - return objnum +function(pagenumber) + return pagenumber end \stopfunctioncall -We can for instance swap the first and last page: +Say that we have 12 pages, then we can do this: \starttyping -local n = 0 -callback.register("page_objnum_provider",function(objnum) - n = n + 1 - if n == 1 then - return pdf.getpageref(tex.count[0]) - elseif n == tex.count[0] then - return pdf.getpageref(1) - else - return objnum +callback.register("page_order_index",function(page) + if page == 1 then return 12 + elseif page == 2 then return 11 + elseif page == 11 then return 2 + elseif page == 12 then return 1 + else return page end end) \stoptyping -When you mess things up \unknown\ don't complain. +This will swap the first two and last two pages. You need to know the number of +pages which is a side effect of the implementation. When you mess things up +\unknown\ don't complain. \subsection{\cbk {process_pdf_image_content}} diff --git a/manual/luatex.pdf b/manual/luatex.pdf index 023d11189da24a0207586d869c29d0814241e69a..f84677d0c27c3caafbc8ecf30fb1a4c14c61b99e 100644 Binary files a/manual/luatex.pdf and b/manual/luatex.pdf differ diff --git a/source/texk/web2c/luatexdir/ChangeLog b/source/texk/web2c/luatexdir/ChangeLog index 105d8d80e503110594fb42a411eb312644126e18..25ba382c85606d148eee372abbb3a6f220b36450 100644 --- a/source/texk/web2c/luatexdir/ChangeLog +++ b/source/texk/web2c/luatexdir/ChangeLog @@ -1,3 +1,7 @@ +2019-10-22 Luigi Scarso <luigi.scarso@gmail.com> + * *** DROPPED "page_objnum_provider" callback , replaced with "page_order_index" *** + + 2019-10-18 Luigi Scarso <luigi.scarso@gmail.com> * following https://tug.org/pipermail/tlbuild/2019q3/004553.html we have now define(__sparc) diff --git a/source/texk/web2c/luatexdir/NEWS b/source/texk/web2c/luatexdir/NEWS index 8c7f2cae84ff1ae613252cb794b9593bb0fb067f..ba63f727ae403b2ce9ea990584635540f0f183bb 100644 --- a/source/texk/web2c/luatexdir/NEWS +++ b/source/texk/web2c/luatexdir/NEWS @@ -1,12 +1,14 @@ ============================================================== -LuaTeX 1.11.1 2019-10-18 +LuaTeX 1.11.1 2019-10-22 ============================================================== First release of luahbtex / luajithbtex, luatex / luajittex with harfbuzz. Small bug fixes, code clean up and a couple of new primitives -to match eTeX. See ChangeLog and the manual. +to match eTeX. +*** DROPPED the "page_objnum_provider" callback, replaced with "page_order_index". *** +See ChangeLog and the manual. diff --git a/source/texk/web2c/luatexdir/lua/lcallbacklib.c b/source/texk/web2c/luatexdir/lua/lcallbacklib.c index 163906eedf532d1691adc1b62e6f425071c19852..5654bc71410afc3b00907e465f4b3eb8099b5c9b 100644 --- a/source/texk/web2c/luatexdir/lua/lcallbacklib.c +++ b/source/texk/web2c/luatexdir/lua/lcallbacklib.c @@ -81,7 +81,7 @@ static const char *const callbacknames[] = { "finish_synctex", "wrapup_run", "new_graf", - "page_objnum_provider", + "page_order_index", "make_extensible", "process_pdf_image_content", NULL diff --git a/source/texk/web2c/luatexdir/luatex_svnversion.h b/source/texk/web2c/luatexdir/luatex_svnversion.h index 7abf493fe9b56cbd94e71320150849e53d0da832..18305fd208aafcf1c54f6b62b92aa0a0199e1c0b 100644 --- a/source/texk/web2c/luatexdir/luatex_svnversion.h +++ b/source/texk/web2c/luatexdir/luatex_svnversion.h @@ -1 +1 @@ -#define luatex_svn_revision 7207 +#define luatex_svn_revision 7208 diff --git a/source/texk/web2c/luatexdir/luatexcallbackids.h b/source/texk/web2c/luatexdir/luatexcallbackids.h index b3b55ce09ea6546187c7609c35f25641ca9b2e19..dc2f05ca955de9f2a1e1628817ec9b27bf9ac7be 100644 --- a/source/texk/web2c/luatexdir/luatexcallbackids.h +++ b/source/texk/web2c/luatexdir/luatexcallbackids.h @@ -73,7 +73,7 @@ typedef enum { finish_synctex_callback, wrapup_run_callback, new_graf_callback, - page_objnum_provider_callback, + page_order_index_callback, make_extensible_callback, process_pdf_image_content_callback, total_callbacks, diff --git a/source/texk/web2c/luatexdir/pdf/pdfgen.c b/source/texk/web2c/luatexdir/pdf/pdfgen.c index 0bd5a3a7b1234b12f334d03f9b26f102a2551645..3d37102b29a95b452194081b6f11bed39777492b 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfgen.c +++ b/source/texk/web2c/luatexdir/pdf/pdfgen.c @@ -1777,7 +1777,12 @@ void pdf_end_page(PDF pdf) 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); + int location = 0; + int callback_id = callback_defined(page_order_index_callback); + if (callback_id) { + run_callback(callback_id, "d->d", total_pages, &location); + } + pdf->last_pages = pdf_do_page_divert(pdf, pdf->last_page, location); /*tex Write out the |/Page| object. */ pdf_begin_obj(pdf, pdf->last_page, OBJSTM_ALWAYS); pdf_begin_dict(pdf); diff --git a/source/texk/web2c/luatexdir/pdf/pdfpagetree.c b/source/texk/web2c/luatexdir/pdf/pdfpagetree.c index 4fcd48e341f8c6a2f4309ec95fa890827a2005b7..f21412f9a98488694bb93b56989a8e226cf11f68 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfpagetree.c +++ b/source/texk/web2c/luatexdir/pdf/pdfpagetree.c @@ -162,7 +162,7 @@ void pdf_do_page_undivert(int divnum, int curdivnum) /*tex Write a |/Pages| object. */ -static void write_pages(PDF pdf, pages_entry * p, int parent, int callback_id) +static void write_pages(PDF pdf, pages_entry * p, int parent) { int i; int pages_attributes ; @@ -185,19 +185,7 @@ static void write_pages(PDF pdf, pages_entry * p, int parent, int callback_id) pdf_add_name(pdf, "Kids"); pdf_begin_array(pdf); for (i = 0; i < p->number_of_kids; i++) { - if (callback_id) { - /* new */ - int objnum = (int) p->kids[i]; - if (obj_type(pdf, objnum) == obj_type_page) { - run_callback(callback_id, "d->d", objnum, &objnum); - check_obj_exists(pdf, objnum); - pdf_add_ref(pdf, (int) objnum); - } else { - pdf_add_ref(pdf, (int) p->kids[i]); - } - } else { - pdf_add_ref(pdf, (int) p->kids[i]); - } + pdf_add_ref(pdf, (int) p->kids[i]); } pdf_end_array(pdf); pdf_end_dict(pdf); @@ -211,12 +199,12 @@ static void write_pages(PDF pdf, pages_entry * p, int parent, int callback_id) */ -static int output_pages_list(PDF pdf, pages_entry * pe, int callback_id) +static int output_pages_list(PDF pdf, pages_entry * pe) { pages_entry *p, *q, *r; if (pe->next == NULL) { /*tex Everything fits into one |pages_entry|. */ - write_pages(pdf, pe, 0, callback_id); + write_pages(pdf, pe, 0); return pe->objnum; } /*tex One level higher needed. */ @@ -228,19 +216,18 @@ static int output_pages_list(PDF pdf, pages_entry * pe, int callback_id) } q->kids[q->number_of_kids++] = p->objnum; q->number_of_pages += p->number_of_pages; - write_pages(pdf, p, q->objnum, callback_id); + write_pages(pdf, p, q->objnum); } /*tex Recurse through next higher level. */ - return output_pages_list(pdf, r, callback_id); + return output_pages_list(pdf, r); } int output_pages_tree(PDF pdf) { - int callback_id = callback_defined(page_objnum_provider_callback); divert_list_entry *d; /*tex Concatenate all diversions into diversion 0. */ pdf_do_page_undivert(0, 0); /*tex Get diversion 0. */ d = get_divert_list(0); - return output_pages_list(pdf, d->first, callback_id); + return output_pages_list(pdf, d->first); }