1

Using pdftex on the following file changes encoding for bitmap font (this can be checked by copy-pasting the text from resulting PDF):

\pdfmapline{=cmr10 <cmr10.enc}
`hello world'
\end

where cmr10.enc is as follows (it differs from default only with /quoteright changed to /uni0027 and /quoteleft changed to /uni0060):

/MyCMRencoding [/Gamma/Delta/Theta/Lambda/Xi/Pi/Sigma/Upsilon/Phi/Psi/Omega/ff/fi/fl/ffi
/ffl/dotlessi/dotlessj/grave/acute/caron/breve/macron/ring/cedilla
/germandbls/ae/oe/oslash/AE/OE/Oslash/suppress/exclam/quotedblright
/numbersign/dollar/percent/ampersand/uni0027/parenleft/parenright
/asterisk/plus/comma/hyphen/period/slash/zero/one/two/three/four/five/six
/seven/eight/nine/colon/semicolon/exclamdown/equal/questiondown/question/at
/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft
/quotedblleft/bracketright/circumflex/dotaccent/uni0060/a/b/c/d/e/f/g/h/i
/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/endash/emdash/hungarumlaut/tilde/dieresis
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
] def

Now change the \pdfmapline to =cmr10 <cmr10.enc <cmr10.pfb. pdftex fails with this error:

This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian) (preloaded format=pdftex)
 restricted \write18 enabled.
entering extended mode
(./test.tex{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map} [1] ){cmr10.enc}
</usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb

pdfTeX warning: pdftex (file /usr/share/texlive/texmf-dist/fonts/type1/public/a
msfonts/cm/cmr10.pfb): glyph `uni0027' undefined


pdfTeX warning: pdftex (file /usr/share/texlive/texmf-dist/fonts/type1/public/a
msfonts/cm/cmr10.pfb): glyph `uni0060' undefined
>
Output written on test.pdf (1 page, 11512 bytes).
Transcript written on test.log.

This is strange, because the same enc-file is used in both cases. And bitmap font demonstrates that there is no problem with the name uni0027. So, why it is not possible to change encoding for Type1 font in pdftex?

4

When you use the encoding for a bit map you don't really reencode the font. To see the difference let's exchange A and B in your map:

  /B/A

If you then compile (I have renamed your map):

\pdfmapline{=cmr10 <testcmrenc.enc <cmr10.pfb}
`AB'
\end

the output looks like this:

enter image description here

So the glyphs have been reencoded and have switched place.

If you compile

\pdfmapline{=cmr10 <testcmrenc.enc}
`AB'
\end

the output looks like this:

enter image description here

So no reencoding. But if you then do a copy&paste in the pdf the result is

`BA'

If you remove the mapline command and do a copy and paste:

‘AB’

Remark that both the order and the quote have changed.

So using an encoding vector with bitmaps doesn't change the encoding of the bitmaps but is "only" used to improve the copy & paste (which is already a quite good thing).

  • This is something new to me. What do you mean by "don't really reencode the font"? To me, reencoding is replacing glyph->codepoint mapping which is in Type1 font by default with new glyph->codepoint mapping, where order of glyphs is fixed and glyph names (like /quoteright or /uniXXXX) specify codepoint for copy-search. Do I get it wrong? What else this glyph->codepoint mapping in Type1 can be used for? – Igor Liferenko Aug 13 at 6:54
  • Maybe I use the wrong terminology: I guess "reencode" is used for a different operation. I just want to change default glyph->codepoint mapping in Type1 font to new glyph->codepoint mapping. Can this operation be done? (and how to call it properly then?) – Igor Liferenko Aug 13 at 7:02
  • what is the problem with my examples? With type1 fonts you can really reencode a font - exchange glyphs in the output (and if you use wrong glyph names some can even be missing, like your quotes) - with bitmaps you can't, there the encoding only helps to improve the copy&paste. – Ulrike Fischer Aug 13 at 7:48
  • OK, I see. What I want to do can be achieved using ToUnicode resource (but I don't know how to use it with dvips) or converting the font to pfa, editing the glyph name to /uni0027 and then converting it back to pfb (this is OK for me, as I'm going to distribute only PDF documents with embedded fonts - no TeX source). – Igor Liferenko Aug 13 at 8:37
  • You want to change the glyph name in the pdf? Why don't you use cmap or \pdfglyphtounicode? – Ulrike Fischer Aug 13 at 8:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.