summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/font-lig.lua
blob: 1aed9fc5b58b98989256305a07fa537ef30adb36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
if not modules then modules = { } end modules ['font-lig'] = {
    version   = 1.001,
    comment   = "companion to font-ini.mkiv",
    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
    copyright = "PRAGMA ADE / ConTeXt Development Team",
    license   = "see context related readme files",
}

-- This module is not loaded but generated a file for plain TeX as a substitute
-- for collapsing the input: "luatex-fonts-lig.lua" with "collapse=yes".

local next = next

local standalone = not characters

if standalone then
    require("char-utf")
end

local data = { }

for first, seconds in next, characters.graphemes do
    for second, combined in next, seconds do
        data[combined] = { first, second }
    end
end

-- data['c'] = { 'a', 'b' }
-- data['d'] = { 'c', 'c' }

local feature = {
    name    = "collapse",
    type    = "ligature",
    prepend = true,
    dataset = {
        { data = data },
        { data = data },
    }
}

if standalone then
    local filename = "luatex-fonts-lig.lua"
    local filedata = "-- this file is generated by context\n\n"
                  .. "fonts.handlers.otf.addfeature "
                  .. table.serialize(feature,false)
    logs.report("fonts","pseudo ligature file %a saved",filename)
    io.savedata(filename,filedata)
else
    fonts.handlers.otf.addfeature(feature)
end