summaryrefslogtreecommitdiff
path: root/luaotfload-deferred.lua
blob: 2a5880bb25a20f753a468a564d42903cfe7706fb (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
--- TODO integrate into luaotfload.dtx
--- this part is loaded after luatexbase
luaotfload.loadmodule("lib-dir.lua")    -- required by font-nms; will change with lualibs update
luaotfload.loadmodule("font-nms.lua")
luaotfload.loadmodule("font-clr.lua")

luatexbase.create_callback("luaotfload.patch_font", "simple", function() end)

local function def_font(...)
    local fontdata = fonts.define.read(...)
    if type(fontdata) == "table" and fontdata.shared then
        local otfdata = fontdata.shared.otfdata
        if otfdata.metadata.math then
            local mc = { }
            for k,v in next, otfdata.metadata.math do
                if k:find("Percent") then
                    -- keep percent values as is
                    mc[k] = v
                else
                    mc[k] = v / fontdata.units * fontdata.size
                end
            end
            -- for \overwithdelims
            mc.FractionDelimiterSize             = 1.01 * fontdata.size
            mc.FractionDelimiterDisplayStyleSize = 2.39 * fontdata.size

            fontdata.MathConstants = mc
        end
        luatexbase.call_callback("luaotfload.patch_font", fontdata)
    end
    return fontdata
end
fonts.mode = "node"

function attributes.private(name)
    local attr   = "otfl@" .. name
    local number = luatexbase.attributes[attr]
    if not number then
        number = luatexbase.new_attribute(attr)
    end
    return number
end

--luaotfload.loadmodule("font-otc.lua") -- broken

--luatexbase.create_callback("luaotfload.patch_font", "simple", function() end)

--local function def_font(...)
    --local fontdata = fonts.define.read(...)
    --if type(fontdata) == "table" and fontdata.shared then
        --local otfdata = fontdata.shared.otfdata
        --if otfdata.metadata.math then
            --local mc = { }
            --for k,v in next, otfdata.metadata.math do
                --if k:find("Percent") then
                    ---- keep percent values as is
                    --mc[k] = v
                --else
                    --mc[k] = v / fontdata.units * fontdata.size
                --end
            --end
            ---- for \overwithdelims
            --mc.FractionDelimiterSize             = 1.01 * fontdata.size
            --mc.FractionDelimiterDisplayStyleSize = 2.39 * fontdata.size

            --fontdata.MathConstants = mc
        --end
        --luatexbase.call_callback("luaotfload.patch_font", fontdata)
    --end
    --return fontdata
--end
--fonts.mode = "node"

--local register_base_sub = fonts.otf.features.register_base_substitution
--local gsubs = {
    --"ss01", "ss02", "ss03", "ss04", "ss05",
    --"ss06", "ss07", "ss08", "ss09", "ss10",
    --"ss11", "ss12", "ss13", "ss14", "ss15",
    --"ss16", "ss17", "ss18", "ss19", "ss20",
--}

--for _,v in next, gsubs do
    --register_base_sub(v)
--end
--luatexbase.add_to_callback("pre_linebreak_filter",
                            --nodes.simple_font_handler,
                           --"luaotfload.pre_linebreak_filter")
--luatexbase.add_to_callback("hpack_filter",
                            --nodes.simple_font_handler,
                           --"luaotfload.hpack_filter")
--luatexbase.reset_callback("define_font")
--luatexbase.add_to_callback("define_font",
                            --def_font,
                           --"luaotfload.define_font", 1)
--luatexbase.add_to_callback("find_vf_file",
                            --fonts.vf.find,
                           --"luaotfload.find_vf_file")
--local function set_sscale_diments(fontdata)
    --local mc = fontdata.MathConstants
    --if mc then
        --if mc["ScriptPercentScaleDown"] then
            --fontdata.parameters[10] = mc.ScriptPercentScaleDown
        --else -- resort to plain TeX default
            --fontdata.parameters[10] = 70
        --end
        --if mc["ScriptScriptPercentScaleDown"] then
            --fontdata.parameters[11] = mc.ScriptScriptPercentScaleDown
        --else -- resort to plain TeX default
            --fontdata.parameters[11] = 50
        --end
    --end
--end

--luatexbase.add_to_callback("luaotfload.patch_font", set_sscale_diments, "unicodemath.set_sscale_diments")
-- 
--  End of File `luaotfload.lua'.