font-imp-italics.lmt /size: 1435 b    last modification: 2024-01-16 10:22
1if not modules then modules = { } end modules ['font-imp-italics'] = {
2    version   = 1.001,
3    comment   = "companion to font-ini.mkiv and hand-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
9local tonumber = tonumber
10
11local handlers = fonts.handlers
12
13-- Instead of a factor we now expect an angle or just "yes". There are some fonts
14-- out there that are italic but have no angle but 'fixing' that runtime is just
15-- too fragile.
16
17local function initialize(tfmdata,value) -- hm, always value
18    if value then
19        local parameters  = tfmdata.parameters
20        local italicangle = parameters.italicangle or 0
21        if italicangle == 0 then
22            italicangle = tonumber(value)
23        end
24        if italicangle ~= 0 then
25            local properties = tfmdata.properties
26            if not properties.hasitalics then
27             -- properties.hasitalics = true -- no!
28                properties.useditalicangle = italicangle
29                parameters.useditalicangle = italicangle
30            end
31        end
32    end
33end
34
35local specification = {
36    name         = "itlc",
37    description  = "italic correction",
38    initializers = {
39        base = initialize,
40        node = initialize,
41    }
42}
43
44handlers.otf.features.register(specification)
45handlers.afm.features.register(specification)
46