43

One of the main goals that Don Knuth had when developing TeX (other than the obvious one of creating high-quality documents) was a 100% platform independence. A document produced on one system should always compile always exactly identical on any machine. It should never happen, that a linebreak or page break would be altered. Therefore the TeX program was very carefully written to ensure that there is absolutely no access to any internally used floating point value and that those parts that actually may use platform dependent code could not affect the typesetting.

Now from my understanding this goal is broken in XeTeX as it hands off "words" to the underlying platform-dependent font machinery and then takes back from there the font glyphs and relative horizontal and vertical positions. Those are then used to calculate line breaks and there it should be possible to generate examples where a document shows different line and/or page breaks if moved from one platform to the next.

I don't know how LuaTeX implements the Opentype support, perhaps the approach here is different. But for LuaTeX I believe that platform dependency may come into play through access to more or less general accessibility of TeX internals (even those that Don deliberately kept inaccessible because of their use of floating point arithmetic).

So my main question here is: is my understanding correct?

And the sub-questions then would be:

  • Has somebody experienced a platform dependency in XeTeX?
  • Has the LuaTeX font support the same "danger"?
3
  • 2
    AFAIK XeTeX used to be platform dependent but is not anymore (for quite some time now). Any supporting evidence about "hands off 'words' to the underlying platform-dependent font machinery"? I don't see anything obvious platform dependent in LuaTeX besides font finding (font paths etc.)
    – topskip
    Commented Jan 17, 2013 at 23:23
  • Once XeTeX relies on a component which is not under its control, we have a big source of dependencies. I would like to have a way to use (optionally) something similar to tfm and/or ocp, overriding what the fonts do, but iir xetex does not provides it, while luatex would require a lot of effort. Commented Jan 18, 2013 at 8:42
  • 7
    Platform dependence of floating point arithmetic used to be a problem when TeX was written. Now, pretty much every platform provides IEEE-754 floating point arithmetic, which is fully specified. The following operations should not depend on the platform: comparisons, rounding, addition, subtraction, multiplication, division, square root. The main reason I wrote l3fp is for trigonometric and other transcendental functions to be platform independent (and for fun). Commented Jan 19, 2013 at 10:07

4 Answers 4

32

LuaTeX OpenType support is fully implemented using Lua code (as Khaled wrote), which means that it is platform independent as long as identical font files are used.

But note that that is usually only the case for fonts that are part of a portable TeX distribution like TeXLive. LuaTeX also allows one to use system-installed fonts, and these will typically be a little different not only between competing operating systems, but also between different versions (or even updates) of one particular operating system.

LuaTeX uses no system font libraries, not for anything, not even fontconfig.

Anyway, LuaTeX documents should be platform independent if these conditions are met:

  • The underlying platform offers IEEE754 double precision floating point as well as 64-bit integer values (but without this, the luatex executable will probably not even compile. Neither will xetex, nor pdftex).
  • All used runtime (TeX, Lua, font, pattern, etc.) files are identical.
  • No Lua nor TeX code is used that explicitly does platform-dependent things.

The last point is what makes it hard to give a definitive answer. However, that condition exists for pdfTeX and even traditional TeX just the same. It is a bit more obvious in LuaTeX, but it is not at all hard to write platform-dependent documents in any of the other TeX- and TeX-like engines.

2
  • 1
    fully understand that using platform dependent extension results in platform dependency. Concerning Lua my point was more on giving access to, for example, glue calculations (if you do) that in TeX is system dependent and therefore not accessible from within TeX. If I understand you right, then you make IEEE754 double precision floating point a prereq. and the assumption is that this ensure platform independence, correct? Commented Jan 18, 2013 at 10:23
  • 2
    IEEE754 double precision floating point is needed to assure that the Lua language behaves the same on all platforms, and that requirement is not really about exposing internals (but with IEEE754, the glue_set calculation is no longer platform-dependent, indeed). Commented Jan 18, 2013 at 10:31
25

At the engine level, LuaTeX is completely platform independent. OpenType font processing is not done by the engine itself, but it provides enough hooks and modules for macro packages to implement it themselves.

  • ConTeXt implements its OpenType text layout and font management entirely in Lua, and thus it is platform in dependant as well.
  • LuaLaTeX takes its text layout code from ConTeXt with its own font management (in Lua too), so the same applies.
  • Other macro packages can use use either of the two or write there own.

In XeTeX all font processing is done by the engine itself:

  • Font management (searching and locating system wide fonts) and this is partly system dependant, it uses Apple specific APIs on Mac and FontConfig otherwise to list and locate the fonts.
  • OpenType and Graphite text layout are done by external, cross-platform libraries (in TeX Live they are statically linked to the binary). AAT text layout is available only on Mac through Apple APIs as it is an Apple-only technology with no cross-platform implementations.
  • XeTeX uses external libraries for other features like line breaking for scripts that does not use space between words, font mappings and input encodings.
5
  • Does this mean that XeTeX has changed the implementation approach, at some point? From Jonathan's original article (tug.org/TUGboat/Articles/tb26-2/kew.pdf) my understanding is that there was at least a potential system dependency because glyph positioning calculations where done partly outside the control of the engine. Commented Jan 18, 2013 at 10:28
  • 1
    @FrankMittelbach: The libraries that XeTeX use (except AAT) are all cross platform. Is their output system dependant? I don’t know, TeX have a strange notion of system independence that I have no idea how to map it to current software practices. But if you use the same software versions and the same fonts you should get identical output, anything else is IMO a bug. Commented Jan 18, 2013 at 10:47
  • 2
    I don't see that TeX has a strange notion of system independence. What Don wanted to achieve is that differences in output are localized and do not ripple, ie, under no circumstances should you get different line breaks and then as a result different page breaks. That's a worthy goal in my opinion (if you remember how, say Word behaved in the early days). Now do static cross platform libraries solve this? It depends on what the system uses from them. If the returned word/glyph width could differ on different systems even if the same lib version is used, then I would say no, otherwise yes. Commented Jan 18, 2013 at 10:59
  • 1
    @FrankMittelbach: I’m not saying system independence is bad, what I’m saying is that the requirements for system independence has changed in the past 20 or so years, so many things that TeX do to be system independent make no sense they days. Commented Apr 11, 2013 at 6:39
  • @FrankMittelbach: The text should be identical (both in shaping results and positions), any difference is a bug, provided that other conditions are met. Commented Apr 11, 2013 at 6:44
14

Knuth put a lot of thought into preserving line and page breaks. But (at the risk of hijacking this thread) I would suggest that the importance of maintaining precise pagination is now less than it was 30 years ago. It is more important now to have a structured document which can reflow on the fly and be available on different devices. Thankfully, TeX is probably the most structured writing system now as well. :-)

So perhaps we should be concentrating more on how structured and reusable the content is, rather than how consistently it renders on different devices.

4
  • 4
    Welcome to TeX.sx!
    – Joseph Wright
    Commented Jan 19, 2013 at 20:59
  • 2
    Nice to see you here, Kaveh! Greetings from Italy!
    – egreg
    Commented Jan 19, 2013 at 21:40
  • 1
    Thank you Joseph and hello Enrico. Apologies for being away for so long. ;-) What a great site this is! Commented Jan 19, 2013 at 22:19
  • 3
    Hi Kaveh! I think both are equally valid goals but clearly for different scenarios. You are probably right the the focus on structured and reusable content is getting stronger and in certain scenarios form is nothing you want to record or preserve. But in others it is key. And note: one important aspect for me is not that I can reproduce form on any device in the same way (even though even for this there are important use cases), but that I can preserve form at all. For book production reflow is not the point but accurate rerendering is. So I'm fully with you on the shift things take. Commented Jan 20, 2013 at 21:59
2

Knuth was concerned that any program that specifically called itself "TeX" should pass the trip test. But XeTeX and others don't call themselves "TeX." As close clades of TeX, of course one has expectations about generic behaviours. But XeTeX does many important functions that TeX does not, so of course it isn't TeX-compliant in these areas. Specifically, documents using XeTeX's extensions, such as Unicode input, that would fail in with errors in TeX compile perfectly well with XeTeX.

Because they don't pretend to be TeX, XeTeX and LuaTeX are free from any moral imperative to produce identical output to TeX, or to pass the trip test.

1
  • 4
    This is really not the point. I'm not asking for identical out to to the TeX program, my question is to understand whether or not a program X compiling on one platform (with identical input) is producing the same result as the same program X on a different platform. Commented Jan 20, 2013 at 17:15

This site is temporarily in read-only mode and not accepting new answers.

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