sile-typesetter / sile

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

feat(typesetters): Support for speaker change introduced by em-dash #1959

Closed Omikhleia closed 5 months ago

Omikhleia commented 5 months ago

Closes #1958

Some conventions denote speaker changes in dialogues by starting a paragraph with an em-dash. In these cases, the space after the em-dash shall be fixed by default.

This is a naive proposal: intercept those from the input at typesetter level.

However, this implementation breaks test-865 which is a pullquote test. The pullquote author stands on its own paragraph line and is introduced by an em-dash: — Joe Smith

If done this "naive" way, what it does show is a bit more general: the kerning (likely) may be slightly affected:

image

This is not illogical (our fixed kern, introduced to replace the space, causes shaping to occur on each part around it, rather than the whole text. Whether this is acceptable is another question...

If we wanted it addressed after shaping, it probably gets a bit more complex, because we are then far past the point where we are sure to be at the start of a paragraph. What we could perhaps do is to only mark the unshaped text in some way at the typesetter level (as here, but without doing the replacement), and handle that later (after shaping, perhaps even in unicode node breakers where spaces are replaced with glues -- EDIT: which implies propagating the "mark" from the unshaped node to the shaped one(s) ^^).

Omikhleia commented 5 months ago

The second commit (refactor) does what's suggested above = marking the unshaped node, but doing the space replacement after shaping. No regression, and probably better?

The cost of the added complexity of this kind of trick might perhaps be acceptable.

alerque commented 5 months ago

I picked up the Russian book my wife happened to be reading the other day and discovered Russian (at least according to some publishers) does exactly the same thing for dialogue. I guess having this on by default was probably a pretty good move.