[luatex] lua transliterations on the fly

Paul Isambert zappathustra at free.fr
Fri Jan 7 20:18:05 CET 2011

Le 07/01/2011 19:16, Luis Rivera a écrit :
> On 7 January 2011 07:17, Ulrike Fischer<luatex at nililand.de>  wrote:
>> Am Fri, 7 Jan 2011 11:38:26 +0100 schrieb Philipp Stephani:
>>> BTW, you should _not_ do something like replacing ^c by ĉ. If you
>>> want ĉ, type ĉ. Use a keyboard layout that contains that
>>> character, an input method, or some auto-correction function of
>>> your text editor, but don't transform text while processing.
>> In general I agree, but there are some cases where I prefer not to
>> input the real char. -- and --- are such cases. Even if – and —
>> where easier to input on my keyboard: I have difficulties to
>> distinguish -, – and — in my editor(s).
>> Btw: I think this type of "fake ligatures" (-- to –) could be used
>> for the translation discussed here. One would naturally have to
>> enable ^ in text mode (along the way _ is enable with
>> underscore.sty). The translation could then be enabled by font
>> switches.
> The Greek input encoding in cbgreek, lfb and ibycus fonts use the
> ligature system from Metafont to implement the transliterations; a
> similar approach is done with the virtual fonts of bgreek: so I am
> very keen on understanding how ligatures work in LuaTeX. A reference
> to a primer on this subject is surely welcome.

Ligatures work roughly like in TeX, i.e. chars have a ``ligatures'' 
field (see for instance pages 145-6 or the manual), which triggers a 
ligature if they're followed by the right glyph. And the only way to 
control that is to control font creation, where the field is defined 
(i.e. when you load a font you have to define a ``ligatures'' field for 
"^", etc.). That can't be done after the font has been loaded; I don't 
know if the latter restriction is definitive or if LuaTeX will perhaps 
someday evolves to allow font tweaking in real-time (that'd be nice e.g. 
to switch between number styles).

Another (probably simpler) approach is to use a callback, most likely 
the "hyphenate" callback (so hyphenation can be properly done 
thereafter), spot all "^" glyphs and replace them according to the glyph 
that follows. That's handmade ligature, so to speak.


More information about the luatex mailing list