0

Copy the text from resulting pdf and paste it somewhere:

\font\tentt=rm-lmtt10 \tentt
a\char'176 b
\font\tentt=cmtt10 \tentt
c\char'176 d
\bye

For me (TeX Live 2015) the first tilde is inserted with a shift forward.

Why the tilde is copied incorrectly from LM-fonts? Is it a bug?

Igor Liferenko
  • 7,063
  • 2
  • 14
  • 47
  • I get the tildes at different heights i.e. high for LM, centre for CM. Is that what you mean? The LM paste looks like the PDF output. The CM paste looks quite different. – cfr Dec 03 '15 at 03:37
  • @cfr: The copied tildes must be the same in both cases. But they are not. There is a wrong code for tilde in "texglyphlist" or somewhere, I guess... – Igor Liferenko Dec 03 '15 at 05:25
  • @egreg where are you looking, I'm using pdftex so what's U+0303? Oh sorry I see, will delete my answer. – David Carlisle Dec 03 '15 at 08:00
  • @egreg: how to fix it locally? This should go to the answer. – Igor Liferenko Dec 03 '15 at 08:17
  • The mapping for “copy-paste” is established by a PostScript resource in the .pfb file, which is (almost) totally out of control from the TeX side. On the other hand, the glyph is the one used for the tilde accent, so the choice of mapping it to U+0303 is not without reasons. – egreg Dec 03 '15 at 08:34

1 Answers1

6

A PFB file can (and usually does) contain a CMap resource that's used for establishing a mapping from glyphs in the PDF file to Unicode; when one selects a glyph in the PDF file and does a “copy”, the code point provided by the mapping is stored for later choosing what character to paste.

The CMap resource in cmtt10.pfb maps the glyph resulting from the character is slot 0x7E (octal 176) to U+007E (I don't know if it actually has such a resource, but it's not really important).

The resource in lmtt10.pfb maps the same glyph to U+0303 (COMBINING TILDE) which may be regarded as a more sensible choice, looking at plain.tex that defines

\def\~#1{{\accent"7E #1}}

So it's not a bug, but a designer's choice.

Can one change this from the TeX side? Maybe, by replacing the CMap resource at font loading time (see https://tex.stackexchange.com/a/22551/4427 for an example).

egreg
  • 1,121,712