On 2017-07-18, Kornel Benko wrote:

...

> 2.) Can we replace outputting \textcompwordmark with \vphantom{} in
>     exported tex file?
>     I could not see any difference in the pdflatex output. Also
>     lualatex and xelatex displayed correctly.

However, lib/unicodesymbols says:

  Do only add commands that give correct output, no hacks that look "similar".

but \textcompwordmark is defined as the LaTeX equivalent to
200C ZERO WIDTH NON-JOINER (ZWNJ) in the LaTeX base:

  t1enc.dfu:261:\DeclareUnicodeCharacter{200C}{\textcompwordmark}

  utf8.def:247:\DeclareUnicodeCharacter{200C}{\textcompwordmark}


The macro itself is defined in the LaTeX base as

  
latex.ltx:2036:\DeclareTextCommandDefault{\textcompwordmark}{\leavevmode\kern\z@}

For T1-encoded fonts, it is mapped to character 23:

  latex.ltx:8275:\lccode 23 =23    % textcompwordmark in T1
  t1enc.def:112:\DeclareTextSymbol{\textcompwordmark}{T1}{23}

Since the recent additon of the standard Unicode text font encoding "TU",
there is a conversion to ZWNJ if Unicode fonts are used with fontspec:

  tuenc.def:169:\DeclareTextSymbol{\textcompwordmark}    
\UnicodeEncodingName{"200C}

The problem is, that this character is missing in the default (LatinModern
Unicode) font. It works fine with, e.g., DejaVu.


>     Moreover, using
>     \textcompwordmark with xelatex displays wrong.

I cannot reproduce.  In my tests, the output is correct: \textcompwordmark
suppresses the ff ligature without other side-effects in the PDF.

However, there is a difference if you copy-paste from the PDF output:

With evince, I get

* for pdflatex and T1-encoded lmodern fonts:

    test with textcompwordmark: ff
    test with vphantom: ff

  \textcompwordmark translates to the unprintable character u0017 because
  this is the position of the ZWNJ character in T1 encoding

  (This is a LaTeX or Evince bug.)

* for xetex or luatax with fontspec and LatinModern

    test with textcompwordmark: ff
    test with vphantom: ff

  Output and copy-paste OK despite the "missing character" warning.
  The invisible ZWNJ is simply dropped but prevents the ligature.

* for xetex with DejaVu:

    test with textcompwordmark: f f
    test with vphantom: ff

  The ZWNJ is converted to an ordinary space when pasting into LyX

* for luatex with DejaVu:

   test with textcompwordmark: f‌f
   test with vphantom: ff

  The ZWNJ is kept (and correctly suppresses the ligature in GUI and output)
  when pasting into LyX

Options:

a) Do not turn the "missing character" warning into an error for
   characters where this is no data loss, e.g. 200C (ZWNJ)

   + helps also, if there are literal ZWNJ characters in the source,
   - side-effects for copy-paste with pdflatex and xetex

b) Re-set \textcompwordmark to the Default in the preamble if TU is
   used:

     \DeclareTextCommand{\textcompwordmark}{TU}{\leavevmode\kern\z@}

As immediate action, maybe also

c) Invert the test(s) with a comment declaring the reason.

d) Use DejaVu or FreeSerif in the affected tests
   (preferably added to the documents instead of the script-based
   replacement).


Günter

Reply via email to