1

For some reason, there is an error when trying to use French and Greek Babel support with dvilualatex.

Try running the following, and it will work fine with dvilualatex+dvips/dvipdfmx:

\documentclass[12pt]{article}
\usepackage[utf8]{luainputenc}\usepackage[LGR,T1]{fontenc}\input{lgrenc.dfu}
\usepackage{lmodern} \usepackage[greek.ancient,main=french]{babel}
\title{Ça marche?} %\date{} \author{me}
\begin{document} \maketitle un, deux, trois \end{document}

Or, try running with English and Greek, and again it works perfectly fine once you include Greek text: (Replacing English with any other language I tried seems to work, such as Spanish as well)

\documentclass[12pt]{article}
\usepackage[utf8]{luainputenc}\usepackage[LGR,T1]{fontenc}\input{lgrenc.dfu}
\usepackage{lmodern} \usepackage[greek.ancient,main=english]{babel}
\title{Does it work?} %\date{} \author{me}
\begin{document} \maketitle one, two, three \foreignlanguage{greek}{ἀγαγεῖν} \end{document}

But, if you run it with Greek text in the body and French as one of the languages, then dvilualatex will compile a DVI which dvips and dvipdfmx both refuse to deal with. Compiling the same TeX document using latex+dvips or latex+dvipdfmx works fine, on the other hand.

\documentclass[12pt]{article}
\usepackage[utf8]{luainputenc}\usepackage[LGR,T1]{fontenc}\input{lgrenc.dfu}
\usepackage{lmodern} \usepackage[greek.ancient,main=french]{babel}
\title{Ça marche?} %\date{} \author{me}
\begin{document} \maketitle un, deux, trois \foreignlanguage{greek}{ἀγαγεῖν} \end{document}

Which, when run through dvilualatex, seems to complete fine, but returns with dvips:

dvips: ! DVI file contains unexpected command (131)

and with dvipdfmx:

dvipdfmx:fatal: DVI opcode 254 only valid for XeTeX

So what gives? And how might I work around this? (I'll note that it seems to work fine with LuaLaTeX in PDF mode, but for the particular case I want to use DVI. And in any case it's a bug — where does it come from???)

5
  • the dvi produced by dviluatex assumes an extended dvi processor (I once saw an announcement of one I think but none of the standard dvi drivers are usable in general) Jan 27, 2020 at 19:17
  • @DavidCarlisle That's not generally true — dvips and dvipdfmx are perfectly capable of outputting well for DVIs I generate with dvilualatex in any other circumstances, including with the English example and the example where French and Greek are loaded but Greek is not used in the body. You may be possibly confused with XeTeX's xdv format, which indeed does exist (it's handled by xdvipdfmx). As for why I use the 8-bit encodings and luainputenc, this is necessary for DVI drivers (using legacy font formats). You cannot use OpenType+usual unicode encoding with DVI output.
    – d909
    Jan 27, 2020 at 19:20
  • @DavidCarlisle it seems like this is a glitch, though. I can't understand how an extended DVI code could possibly be necessary, seeing that this exact file works in latex+dvips/dvipdfmx, and since French and Greek work in isolation from one another and other Latin/Greek switches all work.
    – d909
    Jan 27, 2020 at 19:25
  • And it seems that even with fontspec you get a standard DVI, just referencing fonts the DVI driver can't access. dvips says dvips: Font [lmroman12-regular]:+tlig; not found; using cmr10 and dvipdfmx says dvipdfmx:fatal: Unable to find TFM file "[lmroman12-regular]:+tlig;"..
    – d909
    Jan 27, 2020 at 19:28
  • yes I may deleted the comments dviasm seems to suggest that the dvi is malformed rather than extended. you might want to raise on luatex list (the luatex developers are not here usually) Jan 27, 2020 at 19:32

3 Answers 3

4

The issue has been fixed in babel-french. If you still entounter it, please update your TeX distribution. The following answer should no longer be applied, because the fix will do more harm than good if combined with the fixed babel-french code.

Old answer

As Ulrike Fischer wrote, the problem is the french punctuation code. It is inserted in the "kerning" callback which replaces traditional TeX kerning code, but doesn't apply any kerning.

So even in your first example containing only french, the is a small difference between the LuaLaTeX and the pdfLaTeX version: In the LuaLaTeX version, the kerning in "marche" is missing.

Normally this isn't important in LuaTeX because in LuaLaTeX you normally use OpenType fonts which use another mechanism for kerning, but it becomes significant when you use legacy fonts.

This can be fixed by changing the callback to add a kerning pass:

\documentclass[12pt]{article}
\usepackage[utf8]{luainputenc}
\usepackage[LGR,T1]{fontenc}\input{lgrenc.dfu}
\usepackage{lmodern}
\usepackage[greek.ancient,main=french]{babel}

\directlua{
  luatexbase.add_to_callback("kerning", node.kerning, "TeX legacy kerning")
} 

\title{Ça marche?} %\date{} \author{me}

\begin{document}
\showoutput
\maketitle
un, deux, trois
\end{document}

This not only fixes kerning for legacy fonts but also fixes your problems with DVI files and greek text:

\documentclass[12pt]{article}
\usepackage[utf8]{luainputenc}
\usepackage[LGR,T1]{fontenc}\input{lgrenc.dfu}
\usepackage{lmodern}
\usepackage[greek.ancient,main=french]{babel}
\directlua{
  luatexbase.add_to_callback("kerning", node.kerning, "TeX legacy kerning")
} 

\title{Ça marche?} %\date{} \author{me}

\begin{document}
\showoutput
\maketitle
un, deux, trois

\foreignlanguage{greek}{ἀγαγεῖν}
\end{document}

works fine.

You might wonder why?

The problem with greek text is related to a special character in greek text: The small sigma. It looks differently when it comes as the final character of a word. This is implemented in TeX as a special kind of ligature: The greek font asks TeX to insert a right_boundary "pseudo-character" at the end of every word. Then the font can use kerning and ligature rules for this special right_boundary character to behave differently at the end of the word. After kerning is done, these pseudo-characters are deleted again.

But deleting these characters is also disabled when the kerning callback is overwritten. So in your example containing french and greek text, at the end of every greek word a right_boundary character survives and gets written into the output file. This leads to weird effects because LuaTeX models this character as a glyph node with index -2 and the output formats don't like negative glyph indices. In PDF, this gets written as a 8 Bit unsigned character and therefore translated to index 2^8-2=254. You don't see this in your example, beause the font subset does not contain character index 254, but if you insert a gree \char 254 anywhere in your document, you will see this character appended to every word in PDF output:

\documentclass[12pt]{article}
\usepackage[utf8]{luainputenc}
\usepackage[LGR,T1]{fontenc}\input{lgrenc.dfu}
\usepackage{lmodern}
\usepackage[greek.ancient,main=french]{babel}
% \directlua{
%   luatexbase.add_to_callback("kerning", node.kerning, "TeX legacy kerning")
% } 

\title{Ça marche?} %\date{} \author{me}

\begin{document}
\showoutput
\maketitle
un, deux, trois

\foreignlanguage{greek}{\char 254 ἀγαγεῖν ἀγαγεῖν ἀγαγεῖν ἀγαγεῖν ἀγαγεῖν}
\end{document}

enter image description here

The DVI file format is insanely flexible and does actually specify how to insert glyphs with negative index. So let's look again at the dvips message:

dvips: ! DVI file contains unexpected command (131)

Command 131 is only needed for glyphs of negative index or indices higher than 16777215. Given that dvips only supports 8 bit fonts with glyph indices between 0 and 255, this command is indeed unexpected. For dvipdfmx the problem is similar, it does only support glyph indices up to 16777215, but the message is bit misleading because it tries to just ignore the command byte 131 and tries to read the font index as (invalid) command.

7
  • Thanks for this smart analysis! I still do not understand why my luatexbase.add_to_callback("kerning", f, "frenchb.french_punctuation") call somehow deletes the "TeX legacy kerning". What am I doing wrong? Jan 28, 2020 at 17:25
  • @DanielFlipo The built-in kerning only runs if no kerning callback is provided. So as soon as anyone runs luatexbase.add_to_callback("kerning", ...), the internal kerning is pass is disabled. The idea is that the "kerning" callback is supposed to handle kerning itself. If you want to set a kerning callback but also want the internal kerning to be applied, you have to manually call node.kerning. So you could fix this by adding node.kerning(head) at some point in french_punctuation(head) or by using another callback. Jan 28, 2020 at 17:39
  • So… Thanks, I was not aware of this "feature", the name add_to_callback is a bit misleading regarding the kerning callback :-( I'll try to fix this issue asap. Thanks again for pointing out that babel-french ruins the kerning with Type1 fonts. Jan 28, 2020 at 18:14
  • There is one issue even with this, which may warrant testing @DanielFlipo — try running with TeX legacy kerning enabled and a font such as \usepackage{step}, or \usepackage[type1]{ebgaramond} --- so perhaps any autoinst font --- and you get an error about invalid list tails and missing glue.
    – d909
    Jan 29, 2020 at 23:28
  • @d909 I have pushed yesterday a new release (3.5g) of babel-french which is available on TeXLive this morning. Kerning with type1 fonts looks correct but it doesn't fix your issue unfortunately, sorry. Jan 31, 2020 at 8:31
1

It looks as if the french punctuation code gives an invalid dvi. If I remove the callback it works ok (one should load lmodern after babel, to avoid that the font family is changed):

\documentclass[12pt]{article}
\usepackage[utf8]{luainputenc}\usepackage[LGR,T1]{fontenc}\input{lgrenc.dfu}
\usepackage[greek.ancient,main=french]{babel}
\usepackage{lmodern}
\title{Ça marche?} %\date{} \author{me}
\directlua{luatexbase.remove_from_callback("kerning","frenchb.french_punctuation")}
\begin{document} \maketitle un, deux, trois
 \foreignlanguage{greek}{ἀγαγεῖν} 
 \end{document}
4
  • It works, but now is there a way to maintain the punctuation behavior to match the French standard when using LuaLaTeX?
    – d909
    Jan 27, 2020 at 23:58
  • possibly could this be done bu forcing use of the (pdf)LaTeX implementation?
    – d909
    Jan 28, 2020 at 4:15
  • You can copy the code for pdftex from the french.ldf, should work fine. But on the whole you should be aware that all packages expect luatex to use unicode fonts and not luainputenc. So more problems are possible. Why are you doing this anyway? you are more or less disabling all main luatex capabilities. So why don't you simply use pdflatex? Jan 28, 2020 at 9:30
  • Font expansion in DVI, as well as using Lua scripting functionalities and packages which link to them (obviously not present in this sample).
    – d909
    Jan 28, 2020 at 11:45
0

I have no idea of what goes wrong with dvilualatex, but as you end up with 8 bit Type1 fonts anyway, why not stick to latex + dvips? Note that you'll have to move the \title{} command after the \begin{document} in order to get active punctuation working.

\documentclass[12pt]{article} \usepackage[utf8]{inputenc} \usepackage[LGR,T1]{fontenc} \usepackage[greek.ancient,main=french]{babel} \usepackage{lmodern} \begin{document} \title{Ça marche?} \date{} \author{me} \maketitle un, deux, trois \foreignlanguage{greek}{ἀγαγεῖν} \end{document}

3
  • Title date and author ways go in the preamble, though, no? And as for my reasons, see me comment above on Ulrike Fischer's answer. Could you add a check which uses the pdfLaTeX code when LuaLaTeX is running in DVI mode?
    – d909
    Jan 28, 2020 at 11:46
  • @d909 As long as you don't use : ; ? or ! in \date and \author{} you can do what you want. Regarding your second question: no, I will definitely not revert to using active characters with LuaTeX or XeTeX even in DVI mode. Jan 28, 2020 at 14:53
  • @d909 If you prefer using dvilualatex, Marcel Krüger's suggestion to add the TeX legacy kerning to the kerning callback is what you need. Jan 28, 2020 at 15:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .