sile-typesetter / sile

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

Improving using custom ouputter #1988

Open Omikhleia opened 5 months ago

Omikhleia commented 5 months ago

It's not possible to add a new outputter easily. I experimented writing a few custom outputters[^1], but the backend choices are hard-coded in SILE.init() and heavily tied to picking a shaper.

https://github.com/sile-typesetter/sile/blob/b5ce8e615c5e22c087ea8c8c6f7e30266e0f8634/core/sile.lua#L118-L135

Say I have my "dual" typesetter, the consequence of the above is that sile ... -b dual doesn't work (the outputter is nil)...

Obviously, sile ... -u outputters.dual doesn't work either (the shaper is nil)...

What does work is sile ... -u outputters.dual -u shapers.harfbuzz but it does seem a bit awkward: if the outputter is chosen so soon, shouldn't it be responsible for requiring the only shaper it supports?

Anyhow;

[^1]: One for 2-up pages, one for HTML, and a "dual" acting as a proxy to simultaneously delegate to the PDF and debug outputters ('cause I was tired to have to do two runs in -b debug and (implicitly) -b libtexpdf, so why not try to craft an outputter for the fun of triggering both, and possibly even add its own mess around them, such as doing some extras... :p)

Omikhleia commented 5 months ago

Other notes in passing, from my experimental HTML and "dual/proxy" outputters.

An outputter being at the end of the chain, it should not have "getters" accessed from outside, that's a separation of concern matter.

Regarding the outputter API, thus:

Omikhleia commented 5 months ago

Also (from a previous code quality review I had forgotten)