Re: [NTG-pdftex] \pdffontobjnum assertion failed

Looking more deeply, I found that LuaTeX also causes Assertion failed: (fo->last_char>=fo->first_char), function create_fontdictionary, file ../../../texk/web2c/luatexdir/font/writefont.w, line 683. Abort trap: 6 when if (!font_has_subset(f)) return; inside do_pdf_font() is removed. Therefore, it seems that the pdfTeX issue can be avoided by applying the attached patch. Hironobu Yamashita

On 1/24/2018 4:28 PM, Hironobu Yamashita wrote:
Looking more deeply, I found that LuaTeX also causes
Assertion failed: (fo->last_char>=fo->first_char), function create_fontdictionary, file ../../../texk/web2c/luatexdir/font/writefont.w, line 683. Abort trap: 6
when
if (!font_has_subset(f)) return;
inside do_pdf_font() is removed. Therefore, it seems that the pdfTeX issue can be avoided by applying the attached patch. makes me wonder if we should remove this from luatex ... it's kind of useless to start building and checking a resource before one knows if and what the subset is
Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------

Thanks much Hironobu, but it seems conceivable that a font might be entirely used, in which case it would not have a "subset", but should still be processed in dopdffont. However, what the font_has_subset code actually seems to be doing is checking if any characters are used at all from the font, not whether it is subsetted (vs. completely used). In which case, ok. (Except for the confusing name. :) Am I understanding correctly? Thanks again, Karl --- ptexlib.h (revision 46427) +++ ptexlib.h (working copy) [...] --- writefont.c (revision 46427) +++ writefont.c (working copy) @@ -665,6 +665,8 @@ void dopdffont(integer font_objnum, internalfontnumber f) { fm_entry *fm; + if (!font_has_subset(f)) return; /* avoid Assertion failed */ + fm = hasfmentry(f) ? (fm_entry *) pdffontmap[f] : NULL; if (fm == NULL || is_pk(fm)) writet3(fm, font_objnum, f); @@ -672,5 +674,22 @@ create_fontdictionary(fm, font_objnum, f); } +static int font_has_subset(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; +} + /**********************************************************************/ // vim: ts=4

Hi,
Thanks much Hironobu, but it seems conceivable that a font might be entirely used, in which case it would not have a "subset", but should still be processed in dopdffont.
However, what the font_has_subset code actually seems to be doing is checking if any characters are used at all from the font, not whether it is subsetted (vs. completely used). In which case, ok. (Except for the confusing name. :)
Am I understanding correctly?
My understanding is similar; I guess "subset" here means (used characters)⊆(entire set) and (used characters != null set) Regards, Hironobu

Hi, +static int font_has_subset(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; +} + If no character is used, as in the present example, first_char = s = fontec[f] + 1 ( = 128 for \tenit ) last_char = i = fontbc[f] - 1 ( = -1 for \tenit ) so s > i or return 0. I think it is nice to apply the patch by Hironobu. Best, Akira

the pdfTeX issue can be avoided by applying the attached patch. I installed it (pdftex r793, tl r46443). Thanks again. --karl

the pdfTeX issue can be avoided by applying the attached patch. I installed it (pdftex r793, tl r46443). Thanks again. --karl
participants (4)
-
Akira Kakuto
-
Hans Hagen
-
Hironobu Yamashita
-
Karl Berry