3

Here is an MWE:

\documentclass[a4paper,11pt]{article}
\usepackage{polyglossia}
\usepackage[normalem]{ulem}
\defaultfontfeatures{Ligatures=TeX}
\setmainlanguage{magyar}
\usepackage{color}
\usepackage{soul}

\begin{document}

árvíztűrő tükörfórógép

ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP

\hl{árvíztűrő tükörfórógép}

\hl{ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP}

\end{document}

Here are some interesting message from the log:

Missing character: There is no ű in font ectt1000!
Missing character: There is no ő in font ectt1000!
Missing character: There is no ű in font ectt1000!
Missing character: There is no Ű in font ectt1000!
Missing character: There is no Ő in font ectt1000!
Missing character: There is no Ű in font ectt1000!

I'm not sure why it is complaining about font ectt1000. It can be seen clearly that the highlighted text and the normal text use the very same font. I do not see any error messages in the log. (Nor warnings - but this kind of misrendering should definitely throw an error!)

Here is the output:

Output

  • 1
    the ectt1000 comes from \newfont\SOUL@tt{ectt1000} which is hard-coded in soul.sty. I tried \def\SOUL@tt{\ttfamily} or even \newfont\SOUL@tt{"[lmmono10-regular]" at 10.95pt } but then we get "reconstruction failed" although \SOUL@tt őű has no issue and does work. (It appears the ecmtt font is used for inner constructs by souls when it typesets things in a box with 1sp width to force break into character per character for later reconstruction; but how this come into play when the final output does not use tt font, I forgot) – user4686 Nov 16 '16 at 8:24
  • 2
    The soul package typesets your text in a very narrow box with the font ectt1000 in order to split it up in syllables. It uses a tt font to prevent ligatures to be made. It seems soul is not compatible with fontspec based typesetting. It seems to need the older TeX font system. Maybe you should report this as a bug. – Pieter van Oostrum Nov 16 '16 at 9:08
3

As you are using xelatex/lualatex you need an open type typewriter font which contains all the glyphs. Also one must also reset the default width of the hyphen to this font. In your example you can use Latin Modern Mono, but if you have other scripts you perhaps will need another one.

\documentclass[a4paper,11pt]{article}
\usepackage{fontspec}
\usepackage{color}
\usepackage{soul}
\makeatletter
\font\SOUL@tt="LMMono10-Regular"
\setbox\z@\hbox{\SOUL@tt-}
\SOUL@ttwidth\wd\z@ %reset default width of -
\makeatother
\begin{document}

árvíztűrő tükörfórógép

ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP

\hl{árvíztűrő tükörfórógép}

\hl{ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP}

\end{document}

enter image description here

  • +1! I missed the \setbox\z@\hbox{\SOUL@tt-}\SOUL@ttwidth\wd\z@ piece... – user4686 Nov 17 '16 at 10:22
  • 1
    @jfbu: I missed it too in one of my older answer here but then found if again in one of my even more older answers on the xetex mailing list -- some themes follow you through your life ... – Ulrike Fischer Nov 17 '16 at 10:26
  • 1
    \def\SOUL@tt{\ttfamily} appears to work, as long of course as the document monospace font is suitable for the document script. – user4686 Nov 17 '16 at 10:26
  • You can post it as an answer because it does work. However, this is another mysterious unpredictable unjustified behaviour of latex that drives me crazy. I still don't understand why is this a solution and how. But also I don't want to know. :-) Just get the job done. – nagylzs Nov 17 '16 at 11:39
  • Interestingly, it still does not work inside an \item. LOL – nagylzs Nov 17 '16 at 11:40

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.