[PATCH] pdftex - Add new \pdfpkscalable primitive
Hi! As Karl suggested, I implemented new pdfTeX primitive for controlling if PK font specified in \pdfmapline or \pdfmapfile should be treated as scalable or not. Now by default PK fonts in mapfile/mapline are scalable. Setting value to boolean register \pdfpkscalable takes affect for followings \pdfmapfile and \pdfmapline calls. When is 1 (true) then PK fonts specified in mapfile/mapline are scalable, when 0 (false) then non-scalable (like if they are not specified in mapfile/mapline). Default value is \pdfpkscalable=1 (so behaviour like before). It is useful for specifying enc file for non scalable PK font file (as most bitmap PK fonts does not scale). In patch I defined new fm type flags F_TYPE3 and F_SCALT3FONT, so fm entry can be correctly check if is type 3 or not. Next I split behaviour of current function hasfmentry() into hasfmentry() and isscalable(). hasfmentry() returns true if font id has fm entry (like before), and isscalable() returns true if font id is scalable. In more places was used call hasfmentry() just for checking if font is scalable. Now after introducing non-scalable PK fonts in fm entry, check for scalable font cannot be done by hasfmentry(). So after this change font is *not* scalable (OR): * was not specified in \pdfmapfile or \pdfmapline * is PK Type3 and \pdfpkscalable was set to 0 prior map line processing Example for pdftex -ini: \pdfoutput=1 \catcode`\{=1 \catcode`\}=2 \pdfpkresolution=600 \hsize=4in \vsize=4in \parfillskip=0pt plus1fil \pdfcompresslevel=0 \pdfobjcompresslevel=0 \output={\shipout\box255} \input glyphtounicode \pdfgentounicode=1 \pdfmapline{} % disable all Type1 fonts \pdfpkscalable=0 \pdfmapline{cmr10 <7t.enc} \font\fa=cmr10 \fa ffi test \vskip10pt \font\fb=cmr10 at 60pt \fb ffi test \end When line with pdfmap 7t.enc is commented, then output PDF would not have Unicode definition for ffi ligature. When line \pdfpkscalable=0 is commented, then font at 60pt would look very ugly in result PDF file (just scaled \fa cmr10 with 600dpi). Suggestions or improvements to my patch are welcome! -- Pali Rohár pali.rohar@gmail.com
Subject: [PATCH] pdftex - Add new \pdfpkscalable primitive Why? As I wrote at the end of my message (and you didn't reply to it), I see no point in retaining the concepts of scalable Type3 / PGC fonts. As far as I can see all that's needed now is to change the documentation. I appreciate the effort of trying to retain existing behavior, but in this case, the existing behavior is 100% unused. So I'm not enthusiastic about adding yet more complexity around unused features. As Karl suggested Sorry about the apparent confusion. I only suggested making this boolean in the event that there was no other fix. But you already made another fix. So I think we are done (without this patch). Thanks, Karl
On Thursday 30 March 2017 23:26:24 Karl Berry wrote:
Subject: [PATCH] pdftex - Add new \pdfpkscalable primitive
Why?
As I wrote at the end of my message (and you didn't reply to it), I see no point in retaining the concepts of scalable Type3 / PGC fonts. As far as I can see all that's needed now is to change the documentation.
I appreciate the effort of trying to retain existing behavior, but in this case, the existing behavior is 100% unused. So I'm not enthusiastic about adding yet more complexity around unused features.
As Karl suggested
Sorry about the apparent confusion. I only suggested making this boolean in the event that there was no other fix. But you already made another fix. So I think we are done (without this patch).
There is no fix for supporting non-scalable PK fonts with enc file. Therefore I introduced this \pdfpkscalable boolean register. Once PK font with enc file is defined in mapline it is used as scalable. You can check this fact by generating PDF file that it contains mapping for ffi ligature. Also check pdftex output that mapline was not ignored. Because if mapline is ignored, then pdftex automatically fallback to non-scalable PK fonts, but without enc file. And when pdftex ignore mapline it just show non-fatal warning and produce PDF file without errors. I was already hit by this behaviour that warnings from mapfile are non-fatal... -- Pali Rohár pali.rohar@gmail.com
You seem to be using the word "scalable" in the exact opposite way of my understanding of the pdftex manual. I repeat: as far as I can see, we do not need and do not want to support the behavior of including a PK file as a Type 3 once in the PDF output and then having other instances ("at 60pt") be geometrically scaled. You reported it was broken back in 1.40.0 and no one has missed it. I repeat: the current behavior seems correct and desirable to me. karl
I repeat: the current behavior seems correct and desirable to me.
In the following case, as in the previous pdftex, only cmr10.600pk is used, and cmr10.3600pk is not used. Is it ok? \input glyphtounicode \pdfgentounicode=1 \pdfmapline{} % disable all Type1 fonts \pdfmapline{cmr10 <8r.enc} \font\ff=cmr10 \font\fg=cmr10 at 60pt \ff Test \smallskip \fg Test \bye Best, Akira
only cmr10.600pk is used, and cmr10.3600pk is not used. Is it ok? It isn't ok -- we want .3600pk to be used -- but that's not the behavior I am seeing. That is, the behavior *before* the latest patch (which you installed one part of, but my binary is from before that). Baffled. -k
Hi Karl,
It isn't ok -- we want .3600pk to be used -- but that's not the behavior I am seeing. That is, the behavior *before* the latest patch (which you installed one part of, but my binary is from before that).
Confirmed! I agree that the behavior *before* the latest patch is good. Best, Akira
On Friday 31 March 2017 08:24:14 Akira Kakuto wrote:
Hi Karl,
It isn't ok -- we want .3600pk to be used -- but that's not the behavior I am seeing. That is, the behavior *before* the latest patch (which you installed one part of, but my binary is from before that).
Confirmed! I agree that the behavior *before* the latest patch is good.
Do you mean without patch "+ } else if (is_std_t1font(fm))" ? Here is test input: $ cat test.tex \input glyphtounicode \pdfgentounicode=1 \pdfmapline{} % disable all Type1 fonts \pdfmapline{cmr10 < 8r.enc} \font\ff=cmr10 \font\fg=cmr10 at 60pt \ff Test \smallskip \fg Test \bye No it is not correct, as wrote in previous email, look at pdftex output. There are non-fatal warnings! $ pdftex test.tex This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2017/dev) (preloaded format=pdftex) restricted \write18 enabled. entering extended mode (./test.tex (/usr/share/texlive/texmf-dist/tex/generic/pdftex/glyphtounicode.tex) pdfTeX warning: pdftex: invalid entry for `cmr10': both ps_name and font file missing [1] ) Output written on test.pdf (1 page, 5627 bytes). Transcript written on test.log. There is warning: pdfTeX warning: pdftex: invalid entry for `cmr10': both ps_name and font file missing which means that \pdfmapline from test.tex was ignored and so no enc file was used. So there is no /ToUnicode entry. You can verify it: $ pdffonts test.pdf name type emb sub uni object ID ------------------------------------ ----------------- --- --- --- --------- [none] Type 3 yes no no 4 0 [none] Type 3 yes no no 5 0 "uni" is set to no. What happened is that \pdfmapline for cmr10 was ignored, so pdftex fallbacks to PK fonts (by default) which is automatically non-scalable and without any encoding file. -- Pali Rohár pali.rohar@gmail.com
On Friday 31 March 2017 09:34:02 Pali Rohár wrote:
On Friday 31 March 2017 08:24:14 Akira Kakuto wrote:
Hi Karl,
It isn't ok -- we want .3600pk to be used -- but that's not the behavior I am seeing. That is, the behavior *before* the latest patch (which you installed one part of, but my binary is from before that).
Confirmed! I agree that the behavior *before* the latest patch is good.
Do you mean without patch "+ } else if (is_std_t1font(fm))" ?
Here is test input:
$ cat test.tex \input glyphtounicode \pdfgentounicode=1 \pdfmapline{} % disable all Type1 fonts \pdfmapline{cmr10 < 8r.enc} \font\ff=cmr10 \font\fg=cmr10 at 60pt \ff Test \smallskip \fg Test \bye
No it is not correct, as wrote in previous email, look at pdftex output. There are non-fatal warnings!
$ pdftex test.tex This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2017/dev) (preloaded format=pdftex) restricted \write18 enabled. entering extended mode (./test.tex (/usr/share/texlive/texmf-dist/tex/generic/pdftex/glyphtounicode.tex)
pdfTeX warning: pdftex: invalid entry for `cmr10': both ps_name and font file missing
[1] ) Output written on test.pdf (1 page, 5627 bytes). Transcript written on test.log.
There is warning:
pdfTeX warning: pdftex: invalid entry for `cmr10': both ps_name and font file missing
which means that \pdfmapline from test.tex was ignored and so no enc file was used. So there is no /ToUnicode entry. You can verify it:
$ pdffonts test.pdf name type emb sub uni object ID ------------------------------------ ----------------- --- --- --- --------- [none] Type 3 yes no no 4 0 [none] Type 3 yes no no 5 0
"uni" is set to no.
What happened is that \pdfmapline for cmr10 was ignored, so pdftex fallbacks to PK fonts (by default) which is automatically non-scalable and without any encoding file.
Some more clarification about current state (svn rev 43645 in texlive): 1 Every font specified in \pdfmapline or \pdfmapfile is scalable. This was truth also before and also with my patches up to svn rev 43645. 2 It supports specifying PK/Type3 font in \pdfmapline or \pdfmapline. Due to 1), such font is scalable and so included in output PDF only once. 3 Entry in ChangeLog file is wrong and misleading https://www.tug.org/svn/texlive/trunk/Build/source/texk/web2c/pdftexdir/ChangeLog?view=markup&pathrev=43645 "This way, each bitmap font is embedded separately, thus rasterized by MF instead of geometrically scaling up." This is not truth and in specified link is "enabling scalable PK fonts": https://mailman.ntg.nl/pipermail/ntg-pdftex/2017-March/004125.html When font is "scalable" then it is included in PDF file only once. When font is not "scalable" then it is generated for more different resolutions and so included in PDF file more times. Probably this is reason for misunderstanding and together with not-so-visible non-fatal warning message "both ps_name and font file missing". I hope now with example in previous email with above clarification it is more clear what happened. -- Pali Rohár pali.rohar@gmail.com
Dear Pali, Karl said that scalable PK fonts must be 100% unused, and he does not want to introduce a new primitive in pdfTeX. Thus I installed your patch with a little modification (r43667): Changes in pdftex.web are minimal with no new primitive. PK fonts are always non-scalable, even if they are written in font-map file. Installed changes are in an attached pdftex.diff. Please review the changes. Best, Akira
On Saturday 01 April 2017 09:47:56 Akira Kakuto wrote:
Dear Pali,
Karl said that scalable PK fonts must be 100% unused, and he does not want to introduce a new primitive in pdfTeX. Thus I installed your patch with a little modification (r43667): Changes in pdftex.web are minimal with no new primitive. PK fonts are always non-scalable, even if they are written in font-map file. Installed changes are in an attached pdftex.diff. Please review the changes.
Best, Akira
Hi! Patch is OK, now all PK and PGC fonts are always non-scalable. Tested and it is working. So thanks! Will you update also documentation to reflect these changes? Anyway, now I did some checks of generated PDF files from pdftex against PDF specification PDF32000_2008.pdf and found one problem: /ToUnicode object must be in /Font object, not in /Encoding object. This probably comes from my ToUnicode patch which I sent in Jun 2016. Despite this problem, my PDF viewer (okular) was able to parse PDF and do correct Unicode mapping of text, so I have not caught this problem before. Below is correction, /ToUnicode object reference is written before calling pdfenddict() for /Font object. --- writet3.c +++ writet3.c @@ -362,6 +362,8 @@ cptr = pdfnewobjnum(); pdf_printf("/Widths %i 0 R\n/Encoding %i 0 R\n/CharProcs %i 0 R\n", (int) wptr, (int) eptr, (int) cptr); + if (tounicode_objnum != 0) + pdf_printf("/ToUnicode %i 0 R\n", (int) tounicode_objnum); pdfenddict(); pdfbeginobj(wptr, 1); /* chars width array */ pdf_puts("["); @@ -406,8 +408,6 @@ } } pdf_puts("]\n"); - if (tounicode_objnum != 0) - pdf_printf("/ToUnicode %i 0 R\n", (int) tounicode_objnum); pdfenddict(); pdfbegindict(cptr, 1); /* CharProcs dictionary */ for (i = first_char; i <= last_char; i++) -- Pali Rohár pali.rohar@gmail.com
On Sunday 02 April 2017 15:10:43 Akira Kakuto wrote:
Dear Pali,
--- writet3.c +++ writet3.c
Installed in r43680. Now I can see uni = yes in pdffonts test.pdf. Many thanks. I have added a small change in mapfile.c to warn if only a tfm name is specified in a map for type3.
Best, Akira
Ok, so finally enc files works and PDF files seems to be correctly generated. Many thanks! -- Pali Rohár pali.rohar@gmail.com
On 4/2/2017 2:11 AM, Pali Rohár wrote:
On Saturday 01 April 2017 09:47:56 Akira Kakuto wrote:
Dear Pali,
Karl said that scalable PK fonts must be 100% unused, and he does not want to introduce a new primitive in pdfTeX. Thus I installed your patch with a little modification (r43667): Changes in pdftex.web are minimal with no new primitive. PK fonts are always non-scalable, even if they are written in font-map file. Installed changes are in an attached pdftex.diff. Please review the changes.
Best, Akira
Hi! Patch is OK, now all PK and PGC fonts are always non-scalable. Tested and it is working. So thanks! Will you update also documentation to reflect these changes?
Anyway, now I did some checks of generated PDF files from pdftex against PDF specification PDF32000_2008.pdf and found one problem: /ToUnicode object must be in /Font object, not in /Encoding object. This probably comes from my ToUnicode patch which I sent in Jun 2016. Despite this problem, my PDF viewer (okular) was able to parse PDF and do correct Unicode mapping of text, so I have not caught this problem before. Below is correction, /ToUnicode object reference is written before calling pdfenddict() for /Font object.
the only browser that does tounicode (and actualtext) reliable is acrobat ... my experiences with other browser are that it differs per version so sometimes it works, sometimes not 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 -----------------------------------------------------------------
I'm sorry, but I am not comfortable with releasing these changes for the Type 3 fonts + encoding + Unicode. I realize the features now work in your cases, but I feel much more testing and understanding is needed, before inflicting changes to these low-level routines on the world. I can't undertake this for TL17. The proximate cause is that, in some further testing, I discovered a case that crashed for me now, but did not crash before: \pdfmapline{<} Also, it's unclear to when the new warning "invalid entry for `%s': encoding file for type3 missing" is intended to be given. I could not find any input that caused it. I'm sure that it would not be hard to remedy these particular things, one way or another, but the general principle remains -- I'm simply too uneasy to release these changes, which have grown and grown. As I said before, the primary criterion for pdftex nowadays must be stability. Unfortunately, in that testing, I also discovered other erroneous mapline cases that were already unhandled (before your patches). I know I have not found them all yet. Sigh. If Thanh or Martin wants to include these changes in the upcoming release, and can help with testing/code review, then that is fine. Otherwise, it will have to wait for another time. For the present, I have reverted the changes in the TL repository. (Hopefully correctly.) At least you have written the code now, so can compile your own pdftex and use it for your own work ... --sorry, karl.
On Saturday 15 April 2017 01:18:44 Karl Berry wrote:
I'm sorry, but I am not comfortable with releasing these changes for the Type 3 fonts + encoding + Unicode. I realize the features now work in your cases, but I feel much more testing and understanding is needed, before inflicting changes to these low-level routines on the world. I can't undertake this for TL17.
The proximate cause is that, in some further testing, I discovered a case that crashed for me now, but did not crash before: \pdfmapline{<}
That is because in mapfile.c check_fm_entry() is missing check if
tfm_name is not NULL.
Such thing is possible to hit also without my patches... And is not
related to my patches.
Try:
\pdfmapline{
Also, it's unclear to when the new warning "invalid entry for `%s': encoding file for type3 missing" is intended to be given. I could not find any input that caused it.
That was added by Akira.
I'm sure that it would not be hard to remedy these particular things, one way or another, but the general principle remains -- I'm simply too uneasy to release these changes, which have grown and grown. As I said before, the primary criterion for pdftex nowadays must be stability.
Unfortunately, in that testing, I also discovered other erroneous mapline cases that were already unhandled (before your patches). I know I have not found them all yet. Sigh.
If Thanh or Martin wants to include these changes in the upcoming release, and can help with testing/code review, then that is fine. Otherwise, it will have to wait for another time.
For the present, I have reverted the changes in the TL repository. (Hopefully correctly.)
At least you have written the code now, so can compile your own pdftex and use it for your own work ... --sorry, karl.
So what is needed for inclusion? More testing? And do we have a case where pdftex behave incorrect (or crash) which is related to those toUnicode patches for PK fonts? Because I have not found any problem in current code yet and above crash (which you found) is there for a long time. Do you want a fix for above crash? -- Pali Rohár pali.rohar@gmail.com
On Saturday 15 April 2017 05:49:23 Pali Rohár wrote:
On Saturday 15 April 2017 01:18:44 Karl Berry wrote:
I'm sorry, but I am not comfortable with releasing these changes for the Type 3 fonts + encoding + Unicode. I realize the features now work in your cases, but I feel much more testing and understanding is needed, before inflicting changes to these low-level routines on the world. I can't undertake this for TL17.
The proximate cause is that, in some further testing, I discovered a case that crashed for me now, but did not crash before: \pdfmapline{<}
That is because in mapfile.c check_fm_entry() is missing check if tfm_name is not NULL.
Such thing is possible to hit also without my patches... And is not related to my patches.
Try:
\pdfmapline{
and even on old TeX Live 2012 it crashed too:
../../../texk/web2c/pdftexdir/subfont.c:181: handle_subfont_fm: Assertion `fm->tfm_name != ((void *)0)' failed.
So it is there for a long time.
Also, it's unclear to when the new warning "invalid entry for `%s': encoding file for type3 missing" is intended to be given. I could not find any input that caused it.
That was added by Akira.
I'm sure that it would not be hard to remedy these particular things, one way or another, but the general principle remains -- I'm simply too uneasy to release these changes, which have grown and grown. As I said before, the primary criterion for pdftex nowadays must be stability.
Unfortunately, in that testing, I also discovered other erroneous mapline cases that were already unhandled (before your patches). I know I have not found them all yet. Sigh.
If Thanh or Martin wants to include these changes in the upcoming release, and can help with testing/code review, then that is fine. Otherwise, it will have to wait for another time.
For the present, I have reverted the changes in the TL repository. (Hopefully correctly.)
At least you have written the code now, so can compile your own pdftex and use it for your own work ... --sorry, karl.
So what is needed for inclusion? More testing?
And do we have a case where pdftex behave incorrect (or crash) which is related to those toUnicode patches for PK fonts? Because I have not found any problem in current code yet and above crash (which you found) is there for a long time.
Do you want a fix for above crash?
Just to note that I sent patch for PK encfile support in Aug 2016... So still I would like to hear what is the problem with last version and how can I fix it or improve if needed. And question about pdftex crash when tfmfile is not specified still remind: Should I look at it and propose fix? -- Pali Rohár pali.rohar@gmail.com
On Thursday 20 April 2017 14:58:42 Pali Rohár wrote:
On Saturday 15 April 2017 05:49:23 Pali Rohár wrote:
On Saturday 15 April 2017 01:18:44 Karl Berry wrote:
I'm sorry, but I am not comfortable with releasing these changes for the Type 3 fonts + encoding + Unicode. I realize the features now work in your cases, but I feel much more testing and understanding is needed, before inflicting changes to these low-level routines on the world. I can't undertake this for TL17.
The proximate cause is that, in some further testing, I discovered a case that crashed for me now, but did not crash before: \pdfmapline{<}
That is because in mapfile.c check_fm_entry() is missing check if tfm_name is not NULL.
Such thing is possible to hit also without my patches... And is not related to my patches.
Try:
\pdfmapline{
and even on old TeX Live 2012 it crashed too:
../../../texk/web2c/pdftexdir/subfont.c:181: handle_subfont_fm: Assertion `fm->tfm_name != ((void *)0)' failed.
So it is there for a long time.
Also, it's unclear to when the new warning "invalid entry for `%s': encoding file for type3 missing" is intended to be given. I could not find any input that caused it.
That was added by Akira.
I'm sure that it would not be hard to remedy these particular things, one way or another, but the general principle remains -- I'm simply too uneasy to release these changes, which have grown and grown. As I said before, the primary criterion for pdftex nowadays must be stability.
Unfortunately, in that testing, I also discovered other erroneous mapline cases that were already unhandled (before your patches). I know I have not found them all yet. Sigh.
If Thanh or Martin wants to include these changes in the upcoming release, and can help with testing/code review, then that is fine. Otherwise, it will have to wait for another time.
For the present, I have reverted the changes in the TL repository. (Hopefully correctly.)
At least you have written the code now, so can compile your own pdftex and use it for your own work ... --sorry, karl.
So what is needed for inclusion? More testing?
And do we have a case where pdftex behave incorrect (or crash) which is related to those toUnicode patches for PK fonts? Because I have not found any problem in current code yet and above crash (which you found) is there for a long time.
Do you want a fix for above crash?
Just to note that I sent patch for PK encfile support in Aug 2016... So still I would like to hear what is the problem with last version and how can I fix it or improve if needed.
And question about pdftex crash when tfmfile is not specified still remind: Should I look at it and propose fix?
PING. -- Pali Rohár pali.rohar@gmail.com
Pali - I regretfully backed out the new feature long ago, as I said. I cannot contemplate this further for TL17. Sorry. I did my best to fix possible crashes in cases of pathological input in the current code (in the TL repository for now). --best, karl.
On Wednesday 17 May 2017 21:49:36 Karl Berry wrote:
Pali - I regretfully backed out the new feature long ago, as I said. I cannot contemplate this further for TL17. Sorry.
Ok, then for next year release? One year of testing should be enough.
I did my best to fix possible crashes in cases of pathological input in the current code (in the TL repository for now). --best, karl.
Ok. -- Pali Rohár pali.rohar@gmail.com
Ok, then for next year release? I suppose. I need to ask you to redo your patch against the current source (still only in TeX Live for now), with ChangeLog entries. It would also greatly help me if you provided as-simple-as-possible source files, along the lines of what is in pdftex/tests/*, exhibiting the intended changes in behavior. Because that's what I need to be confident in the changes. Not as critical, but still quite helpful, would be a draft patch for the manual. --best, karl.
participants (4)
-
Akira Kakuto
-
Hans Hagen
-
Karl Berry
-
Pali Rohár