Re: pdftex - Encoding for metafont PK fonts

Ross Moore <[email protected]>
Newsgroups gmane.comp.tex.pdftex
Message-ID <[email protected]>
On Jun 27, 2016, at 9:25 AM, Ross Moore <[email protected]<mailto:[email protected]>> wrote:

Certainly one can attach a /ToUnicode map to the /Type3 font.

And if you build it correctly, it actually works!

However there is something else missing in the way the /Font dictionary
is built in that case, which prevents Acrobat from using that CMap.
The lack of encoding vector and /CharSet may well be the problem,
or it may be some other piece of font metadata that is needed.

Try this example, using the attached .cmap  file (which is not fully
complete — I leave that to you to finish :-).
It produces the attached PDF, from which you can Copy/Paste correctly.


%%%%%%   ———  start of example TeX source ——— %%%%%
\pdfcompresslevel 0
\pdfobjcompresslevel 0
\nopagenumbers
\pdfgentounicode 1
\input glyphtounicode.tex

\font\csb=csb12
\immediate\pdfobj stream file {cs1.cmap} % 1 obj
\pdffontattr \csb{/ToUnicode \the\pdflastobj\space 0 R}
%
\csb
\char232 \char233 %\char234 %\char235 %
\char236 \char237 %\char238
\char239 \char"F2 \char"F3 \char"F4 \char"F6 \char"F8 \char"F9 \char"FA \char"FC \char"FD \char"FE \char"FF

\font\csr=csr12
\csr
\char232 \char233 %\char234 %\char235 %
\char236 \char237 %\char238
\char239

 \bye
%%%%%%   ———  end of example TeX source ——— %%%%%
csb.tex (application/octet-stream, 539 B) - not displayed
ATT00001.htm (text/html, 286 B)
<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><div class="AppleOriginalContents"><div class="AppleOriginalContents"></div></div></body></html>
cs1.cmap (application/octet-stream, 837 B) - not displayed
ATT00002.htm (text/html, 286 B)
<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><div class="AppleOriginalContents"><div class="AppleOriginalContents"></div></div></body></html>
csb.pdf (application/pdf, 17.4 KB) - not displayed
ATT00003.htm (text/html, 7.3 KB)
<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><div><div></div><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class=""><blockquote type="cite" class=""><blockquote type="cite" class="">I looked deeply how pdftex working with Type 3 and PK fonts and<br class=""></blockquote></blockquote><blockquote type="cite" class=""><div class=""><blockquote type="cite" class="">created small patch which adds support for generating /ToUnicode<br class="">object (from \pdfglyphtounicode table) and which allows to load enc<br class="">file also PK fonts.<br class=""><br class="">Patch was created against pdftex in TeXLive 2012 (which is on my<br class="">system), but is really small and should be very easy to rewrite/apply<br class="">it on new versions.<br class=""><br class="">Patch pdftex-pkfonts-encfile-tounicode.patch is attached.<br class=""><br class="">Let me know what do you think about it and if it can be added to<br class="">pdftex project.<br class=""></blockquote><br class="">Ops, in patch from previous email is small problem with indexes and<span class="Apple-converted-space">&nbsp;</span><br class="">notdef. Fixed in new attached pdftex-pkfonts-encfile-tounicode-v2.patch<br class=""></div></blockquote><div class=""><br class=""></div><div class="">Thanks for going to this level of detail.</div><div class="">But is it really needed, when &nbsp;csfonts &nbsp;are available?</div><div class="">Besides, there is no point constructing the /ToUnicode CMAP automatically</div><div class="">if it’s not going to work properly anyway.</div></div></div></div></blockquote><div><br class=""></div><div>My error in previous examples. &nbsp;:-(</div><div>Every aspect of a CMap file must be absolutely correct.</div><div>It’s easy to get a number wrong; if so, then Acrobat</div><div>will not try to use the CMap with Copy/Paste nor validation.</div><div><br class=""></div><div>So there is definitely some value in creating the CMap automatically,</div><div>even with Type3 fonts.</div><div>Though pre-making them is valid also, since this does not depend</div><div>on the glyph names being used in the font.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class=""><div class="">Surely new documents should use &nbsp;csfonts .</div><div class=""><br class=""></div><div class="">But if there is an existing archive of documents that use older methods,</div><div class="">which may need faithful production into the future, then you have my&nbsp;</div><div class="">support for adding improvements to the way Type-3 fonts are handled.</div><br class=""><blockquote type="cite" class=""><div class=""><br class="">--<span class="Apple-converted-space">&nbsp;</span><br class="">Pali Rohár<br class=""><a href="mailto:[email protected]" class="">[email protected]</a><br class=""><span id="cid:FFA0EBE2-4823-4BFF-A1C5-D6F69089C661" class="">&lt;pdftex-pkfonts-encfile-tounicode-v2.patch&gt;</span></div></blockquote></div></div></blockquote></div><div class=""><br class=""></div>Hope this helps.<div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">	</span>Ross<div apple-content-edited="true" class=""><div style="font-family: Arial, sans-serif; orphans: 2; widows: 2; " class=""><span class="Apple-style-span" style="font-size: 9px;"><b class=""><span style="font-size: 9pt;" class=""><br class="Apple-interchange-newline">Dr Ross Moore</span></b></span></div><div style="font-family: Arial, sans-serif; orphans: 2; widows: 2;" class=""><p style="font-family: Arial, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(119, 119, 119); font-size: 7pt; margin-bottom: 3.75pt;" class=""><font color="#000000" class=""><span style="font-size: 9pt;" class=""><b class="">Mathematics Dept&nbsp;</b><b class="">|</b>&nbsp;Level 2, S2.638 AHH<br class="">Macquarie University, NSW 2109, Australia</span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;" class=""></span></font></p><p style="font-family: Arial, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(119, 119, 119); font-size: 7pt; line-height: 11.25pt; margin-bottom: 3.75pt;" class=""><b class=""><span style="font-size: 9pt;" class=""><font color="#000000" class="">T:</font></span></b><span style="font-size: 9pt;" class=""><font color="#000000" class="">&nbsp;+61 2 9850&nbsp;<b class="">8955 &nbsp;| &nbsp;F:</b>&nbsp;</font><a href="tel:%2B61%202%209850%209695" value="+61298509695" target="_blank" class=""><font color="#000000" class="">+61 2 9850 8114</font></a><br class=""><font color="#000000" class=""><b class="">M:</b><a href="tel:%2B61%20409%20125%20670" value="+61409125670" target="_blank" class="">+61 407 288 255</a><b class="">&nbsp; | &nbsp;</b>E:&nbsp;</font><a href="mailto:[email protected]" target="_blank" class=""><font color="#000000" class="">[email protected]</font><font color="#1155cc" class=""><span style="color: black;" class=""></span></font></a><font color="#1155cc" class=""><span style="color: black;" class=""></span></font><span style="color: black;" class=""></span><br class=""></span></p><p style="font-family: Arial, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(119, 119, 119); font-size: 7pt; line-height: 11.25pt; margin-bottom: 3.75pt;" class=""><span style="font-size: 9pt;" class=""><span style="color: black;" class=""><a title="Macquarie University" href="http://mq.edu.au/" target="_blank" class="">http://www.maths.mq.edu.au</a></span></span></p><p style="color: rgb(0, 0, 0); font-family: Arial, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://mq.edu.au/" target="_blank" class=""><br class="Apple-interchange-newline"><span></span></a></p></div></div></div></body></html>
image001.png (image/png, 4.5 KB) - not displayed
ATT00004.htm (text/html, 2.4 KB)
<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div apple-content-edited="true" class=""><div style="font-family: Arial, sans-serif; orphans: 2; widows: 2;" class=""><p style="color: rgb(0, 0, 0); font-family: Arial, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://mq.edu.au/" target="_blank" class=""><span></span></a></p><p style="font-family: Arial, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(119, 119, 119); font-size: 7pt;" class=""><a href="http://mq.edu.au/" target="_blank" class=""><span style="color: rgb(119, 119, 119); font-size: 7pt;" class=""><br class="Apple-interchange-newline">CRICOS Provider Number 00002J. Think before you print.&nbsp;<br class="">Please consider the environment before printing this email.</span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;" class=""></span></a></p><p style="font-family: Arial, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(119, 119, 119); font-size: 7pt;" class=""><a href="http://mq.edu.au/" target="_blank" class=""><span style="color: rgb(119, 119, 119); font-size: 7pt;" class="">This message is intended for the addressee named and may&nbsp;<br class="">contain confidential information. If you are not the intended&nbsp;<br class="">recipient, please delete it and notify the sender. Views expressed&nbsp;<br class="">in this message are those of the individual sender, and are not&nbsp;<br class="">necessarily the views of Macquarie University.</span></a></p>
</div>
</div><br class=""></div></body></html>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.