texlive[55722] Build/source/texk/dvipdfm-x: Fix a bug that btrans

commits+kakuto at tug.org commits+kakuto at tug.org
Wed Jul 1 23:47:04 CEST 2020


Revision: 55722
          http://tug.org/svn/texlive?view=revision&revision=55722
Author:   kakuto
Date:     2020-07-01 23:47:04 +0200 (Wed, 01 Jul 2020)
Log Message:
-----------
Fix a bug that btrans inside bcontent-econtent does not work.
pdf:bann accepts a reference ID (for referring the first annotation
dictionary of a line-breaking annotation). (S. Hirata).

Modified Paths:
--------------
    trunk/Build/source/texk/dvipdfm-x/ChangeLog
    trunk/Build/source/texk/dvipdfm-x/pdfdoc.c
    trunk/Build/source/texk/dvipdfm-x/spc_pdfm.c

Modified: trunk/Build/source/texk/dvipdfm-x/ChangeLog
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/ChangeLog	2020-07-01 21:03:48 UTC (rev 55721)
+++ trunk/Build/source/texk/dvipdfm-x/ChangeLog	2020-07-01 21:47:04 UTC (rev 55722)
@@ -1,3 +1,12 @@
+2020-07-02  Shunsaku Hirata  <shunsaku.hirata74 at gmail.com>
+
+	* pdfdoc.c, spc_pdfm.c: Possible fix for a bug that pdf:btrans
+	inside pdf:bcontent and pdf:econtent does not work correctly.
+	Extend pdf:bann to accept a reference ID which can be used
+	later to refer the annotation dictionary object. When
+	line-breaks occur, it just points to the first annotation
+	dictionary of the line-breaking annotation series.
+
 2020-06-28  Shunsaku Hirata  <shunsaku.hirata74 at gmail.com>
 
 	* dvi.[ch], spc_dvipdfmx.c, spc_pdfm.c, specials.[ch]: Two new

Modified: trunk/Build/source/texk/dvipdfm-x/pdfdoc.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/pdfdoc.c	2020-07-01 21:03:48 UTC (rev 55721)
+++ trunk/Build/source/texk/dvipdfm-x/pdfdoc.c	2020-07-01 21:47:04 UTC (rev 55722)
@@ -2797,6 +2797,8 @@
 pdf_doc_end_annot (void)
 {
   pdf_doc_break_annot();
+  if (breaking_state.annot_dict)
+    pdf_release_obj(breaking_state.annot_dict);
   breaking_state.annot_dict = NULL;
 }
 
@@ -2807,12 +2809,14 @@
   double   g = p->opt.annot_grow;
 
   if (breaking_state.dirty) {
-    pdf_obj  *annot_dict;
+    pdf_obj  *annot_dict, *annot_copy;
     pdf_rect  rect;
 
     /* Copy dict */
-    annot_dict = pdf_new_dict();
-    pdf_merge_dict(annot_dict, breaking_state.annot_dict);
+    annot_dict = breaking_state.annot_dict;
+    annot_copy = pdf_new_dict();
+    pdf_merge_dict(annot_copy, breaking_state.annot_dict);
+    breaking_state.annot_dict = annot_copy;
     rect = breaking_state.rect;
     rect.llx -= g;
     rect.lly -= g;

Modified: trunk/Build/source/texk/dvipdfm-x/spc_pdfm.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/spc_pdfm.c	2020-07-01 21:03:48 UTC (rev 55721)
+++ trunk/Build/source/texk/dvipdfm-x/spc_pdfm.c	2020-07-01 21:47:04 UTC (rev 55722)
@@ -798,11 +798,15 @@
   return 0;
 }
 
-/* NOTE: This can't have ident. See "Dvipdfm User's Manual". */
+/* NOTE: This can't have ident. See "Dvipdfm User's Manual".
+ * 1 Jul. 2020: ident allowed (upon request)
+ * Only first annotation can be accessed in line break cases.
+ */
 static int
 spc_handler_pdfm_bann (struct spc_env *spe, struct spc_arg *args)
 {
   struct spc_pdf_ *sd = &_pdf_stat;
+  char  *ident = NULL;
   int    error = 0;
 
   if (sd->annot_dict) {
@@ -811,19 +815,31 @@
   }
 
   skip_white(&args->curptr, args->endptr);
+  if (args->curptr[0] == '@') {
+    ident = parse_opt_ident(&args->curptr, args->endptr);
+    skip_white(&args->curptr, args->endptr);
+  }
 
   sd->annot_dict = parse_pdf_dict_with_tounicode(&args->curptr, args->endptr, &sd->cd);
   if (!sd->annot_dict) {
     spc_warn(spe, "Ignoring annotation with invalid dictionary.");
+    if (ident)
+      RELEASE(ident);
     return  -1;
   } else if (!PDF_OBJ_DICTTYPE(sd->annot_dict)) {
     spc_warn(spe, "Invalid type: not a dictionary object.");
     pdf_release_obj(sd->annot_dict);
     sd->annot_dict = NULL;
+    if (ident)
+      RELEASE(ident);
     return  -1;
   }
 
-  error = spc_begin_annot(spe, sd->annot_dict);
+  error = spc_begin_annot(spe, pdf_link_obj(sd->annot_dict));
+  if (ident) {
+    spc_push_object(ident, pdf_link_obj(sd->annot_dict));
+    RELEASE(ident);
+  }
 
   return  error;
 }
@@ -1006,6 +1022,7 @@
 spc_handler_pdfm_btrans (struct spc_env *spe, struct spc_arg *args)
 {
   pdf_tmatrix     M;
+  double          x_user, y_user, xpos, ypos;
   transform_info  ti;
 
   transform_info_clear(&ti);
@@ -1013,10 +1030,16 @@
     return -1;
   }
 
+  /* btrans inside bcontent-econtent bug fix.
+   * I don't know if this is the only place needs to be fixed...
+   */
+  pdf_dev_get_coord(&xpos, &ypos);
+  x_user = spe->x_user - xpos;
+  y_user = spe->y_user - ypos;
   /* Create transformation matrix */
   pdf_copymatrix(&M, &(ti.matrix));
-  M.e += ((1.0 - M.a) * spe->x_user - M.c * spe->y_user);
-  M.f += ((1.0 - M.d) * spe->y_user - M.b * spe->x_user);
+  M.e += ((1.0 - M.a) * x_user - M.c * y_user);
+  M.f += ((1.0 - M.d) * y_user - M.b * x_user);
 
   pdf_dev_gsave();
   pdf_dev_concat(&M);



More information about the tex-live-commits mailing list.