pdftex[793] branches/stable: avoid failed assertion with

commits+karl at tug.org commits+karl at tug.org
Fri Jan 26 00:21:32 CET 2018


Revision: 793
          http://tug.org/svn/pdftex?view=revision&revision=793
Author:   karl
Date:     2018-01-26 00:21:29 +0100 (Fri, 26 Jan 2018)
Log Message:
-----------
avoid failed assertion with \pdffontobjnum of unused font

Modified Paths:
--------------
    branches/stable/source/src/texk/web2c/pdftexdir/ChangeLog
    branches/stable/source/src/texk/web2c/pdftexdir/writefont.c

Added Paths:
-----------
    branches/stable/tests/09-fontobjnum/
    branches/stable/tests/09-fontobjnum/Makefile
    branches/stable/tests/09-fontobjnum/test-fontobjnum.tex

Modified: branches/stable/source/src/texk/web2c/pdftexdir/ChangeLog
===================================================================
--- branches/stable/source/src/texk/web2c/pdftexdir/ChangeLog	2018-01-07 00:24:41 UTC (rev 792)
+++ branches/stable/source/src/texk/web2c/pdftexdir/ChangeLog	2018-01-25 23:21:29 UTC (rev 793)
@@ -1,3 +1,14 @@
+2018-01-25  Hironobu Yamashita <h.y.acetaminophen at gmail.com>
+        and Karl Berry  <karl at freefriends.org>
+
+	* writefont.c (font_is_used): import LuaTeX's font_has_subset
+	with different name.
+	(dopdffont): call it, to avoid failed assertion. (tests/09-fontobjnum)
+	Original report from Enrico Gregorio,
+	  tug.org/pipermail/tex-live/2018-January/040966.html
+	followup with patch at
+	  mailman.ntg.nl/pipermail/ntg-pdftex/2018-January/004209.html
+
 2018-01-06  Karl Berry  <karl at freefriends.org>
 
 	* pdftex.web (literal): if a non-PDF special is ignored,

Modified: branches/stable/source/src/texk/web2c/pdftexdir/writefont.c
===================================================================
--- branches/stable/source/src/texk/web2c/pdftexdir/writefont.c	2018-01-07 00:24:41 UTC (rev 792)
+++ branches/stable/source/src/texk/web2c/pdftexdir/writefont.c	2018-01-25 23:21:29 UTC (rev 793)
@@ -660,11 +660,40 @@
         write_fontdictionary(fo);
 }
 
-/**********************************************************************/
 
-void dopdffont(integer font_objnum, internalfontnumber f)
+

+/* This is called font_has_subset in luatex, but it returns 1 if any
+   characters from the font are used, and 0 if not (using fontbc and
+   fontec as the endpoints to check), i.e., whether any characters are
+   actually used from the font. */
+
+static int
+font_is_used(internalfontnumber f)
 {
+    int i, s;
+    /* search for |first_char| and |last_char| */
+    for (i = fontbc[f]; i <= fontec[f]; i++)
+        if (pdfcharmarked(f, i))
+            break;
+    s = i;
+    for (i = fontec[f]; i >= fontbc[f]; i--)
+        if (pdfcharmarked(f, i))
+            break;
+    if (s > i)
+        return 0;
+    else
+        return 1;
+}
+
+void
+dopdffont(integer font_objnum, internalfontnumber f)
+{
     fm_entry *fm;
+    if (!font_is_used(f))
+        return; /* avoid failed assertion in create_fontdictionary,
+                mailman.ntg.nl/pipermail/ntg-pdftex/2018-January/004209.html */
+       
+
     fm = hasfmentry(f) ? (fm_entry *) pdffontmap[f] : NULL;
     if (fm == NULL || is_pk(fm))
         writet3(fm, font_objnum, f);
@@ -672,5 +701,4 @@
         create_fontdictionary(fm, font_objnum, f);
 }
 
-/**********************************************************************/
 // vim: ts=4

Added: branches/stable/tests/09-fontobjnum/Makefile
===================================================================
--- branches/stable/tests/09-fontobjnum/Makefile	                        (rev 0)
+++ branches/stable/tests/09-fontobjnum/Makefile	2018-01-25 23:21:29 UTC (rev 793)
@@ -0,0 +1,13 @@
+# $Id$
+# Public domain.
+
+include ../Common.mak
+
+default: test-ok
+
+test-ok:
+	$(prog) test-fontobjnum.tex
+	grep 'fontobjnum=1' test-fontobjnum.log >/dev/null
+
+clean:
+	$(clean)


Property changes on: branches/stable/tests/09-fontobjnum/Makefile
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Date Author Id
\ No newline at end of property
Added: branches/stable/tests/09-fontobjnum/test-fontobjnum.tex
===================================================================
--- branches/stable/tests/09-fontobjnum/test-fontobjnum.tex	                        (rev 0)
+++ branches/stable/tests/09-fontobjnum/test-fontobjnum.tex	2018-01-25 23:21:29 UTC (rev 793)
@@ -0,0 +1,9 @@
+% $Id$
+% Public domain.
+
+\catcode`\{=1 \catcode`\}=2
+\font\tenit = /usr/local/texlive/2017/texmf-dist/fonts/tfm/public/cm/cmti10.tfm
+\edef\tenitnumber{\pdffontobjnum\tenit}
+\message{fontobjnum=\tenitnumber}
+\tenitnumber
+\end


Property changes on: branches/stable/tests/09-fontobjnum/test-fontobjnum.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Date Author Id
\ No newline at end of property


More information about the pdftex-commits mailing list