sile-typesetter / sile

The SILE Typesetter — Simon’s Improved Layout Engine
https://sile-typesetter.org
MIT License
1.67k stars 99 forks source link

Bable strikes back — chaos in language settings #1367

Open alerque opened 2 years ago

alerque commented 2 years ago

There are times I want to throw up my hands.

In working on #665 (see progress in #675) I've run into the fact that we don't handle settings sanely. We have the document.language setting which can be set directly, but far more often it gets set as a side effect of \font[language=...]{}. The trouble is actual SETTINGS are scoped with a stack system where temporary closures can bring them in and out of scope. These don't necessarily correspond to where other font settings are stopped and started. One current example is any use of the \verbatim environment between to \chapter headings will change the language use to localize the "Chapter" text. The environment is supposed to be protected with a temporary settings block, but changing the font and changing the document language result in an imbalance in the settings stack.

Confounding the problem is the possibility of multiple typesetters. If I have one typesetter working on one frame in one language and another working on another frame in another language, the document.language setting is going to get cross-polluted constantly.

Personally I think the document.language setting is over 50% bogus. Having a document default might make sense, but it in that case it should not be a running value that changes constantly. It should be a fallback for when no other settings are in scope. Then each typesetting should probably have a language setting that follows the typesetter state, not the document settings state.

See also related discussion in #76 and #83 (mostly bidi, but some document expectations).

Omikhleia commented 2 years ago

You seem to mention two separate issues: one with a case with a single typesetter, another with multiple typesetters. Do you have a minimal example for the first case? (As for multiple typesetters, things cant get more complex but I suspect it depends how one accesses them). (By the way, verbatim is a bit bogus, no?)

simoncozens commented 2 years ago

You’re right, it’s a mess, and I apologise for that. A document should have a fixed default language, but the typesetter should know what language it’s currently working with. So we do need document.language and font.language, but only font.language should shuffle about.

alerque commented 2 years ago

...and the value of font.language should follow the typesetter state not the document state. As should a lot of other settings.

Omikhleia commented 2 years ago

... and fonts, intrinsically, shouldn't have a a language :p

alerque commented 2 years ago

Hence why I mentioned in #1368 that we've been using "language" internally pretty much across the board. In some cases we really do mean "language", but in some places we actually mean "locale" and in others "script". Untangling them without breaking everything for everybody is going to be ... fun.