font-lig.lua /size: 1333 b    last modification: 2021-10-28 13:50
1if not modules then modules = { } end modules ['font-lig'] = {
2    version   = 1.001,
3    comment   = "companion to font-ini.mkiv",
4    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5    copyright = "PRAGMA ADE / ConTeXt Development Team",
6    license   = "see context related readme files",
7}
8
9-- This module is not loaded but generates a file for plain TeX as a substitute
10-- for collapsing the input: "luatex-fonts-lig.lua" with "collapse=yes".
11
12local next = next
13
14local standalone = not characters
15
16if standalone then
17    require("char-utf")
18end
19
20local data = { }
21
22for first, seconds in next, characters.graphemes do
23    for second, combined in next, seconds do
24        data[combined] = { first, second }
25    end
26end
27
28-- data['c'] = { 'a', 'b' }
29-- data['d'] = { 'c', 'c' }
30
31local feature = {
32    name    = "collapse",
33    type    = "ligature",
34    prepend = true,
35    dataset = {
36        { data = data },
37        { data = data },
38    }
39}
40
41if standalone then
42    local filename = "luatex-fonts-lig.lua"
43    local filedata = "-- this file is generated by context\n\n"
44                  .. "fonts.handlers.otf.addfeature "
45                  .. table.serialize(feature,false)
46    logs.report("fonts","pseudo ligature file %a saved",filename)
47    io.savedata(filename,filedata)
48else
49    fonts.handlers.otf.addfeature(feature)
50end
51