diff options
author | Hans Hagen <pragma@wxs.nl> | 2018-04-13 15:51:39 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2018-04-13 15:51:39 +0200 |
commit | 25fcad7435f56cdce2658336909f4da6a65589c0 (patch) | |
tree | c23d5d04a7e86c7ddc2ebeca06d3de63ebdc806e /tex/context/base/mkiv/font-imp-unicode.lua | |
parent | 1e5d7f41ddede5e6400a2a7762032823d3545df4 (diff) | |
download | context-25fcad7435f56cdce2658336909f4da6a65589c0.tar.gz |
2018-04-13 15:02:00
Diffstat (limited to 'tex/context/base/mkiv/font-imp-unicode.lua')
-rw-r--r-- | tex/context/base/mkiv/font-imp-unicode.lua | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/font-imp-unicode.lua b/tex/context/base/mkiv/font-imp-unicode.lua new file mode 100644 index 000000000..9e1e3465e --- /dev/null +++ b/tex/context/base/mkiv/font-imp-unicode.lua @@ -0,0 +1,80 @@ +if not modules then modules = { } end modules ['font-imp-unicode'] = { + version = 1.001, + comment = "companion to font-ini.mkiv and hand-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local next = next + +local fonts = fonts +local helpers = fonts.helpers +local constructors = fonts.constructors +local registerotffeature = fonts.handlers.otf.features.register + +local extraprivates = helpers.extraprivates +local addprivate = helpers.addprivate + +local function initialize(tfmdata) + for i=1,#extraprivates do + local e = extraprivates[i] + local c = e[2](tfmdata) + if c then + addprivate(tfmdata, e[1], c) + end + end +end + +constructors.newfeatures.otf.register { + name = "extraprivates", + description = "extra privates", + default = true, + manipulators = { + base = initialize, + node = initialize, + } +} + +local tounicode = fonts.mappings.tounicode + +local function initialize(tfmdata,key,value) + if value == "ligatures" then + local private = fonts.constructors and fonts.constructors.privateoffset or 0xF0000 + local collected = fonts.handlers.otf.readers.getcomponents(tfmdata.shared.rawdata) + if collected and next(collected)then + for unicode, char in next, tfmdata.characters do + local u = collected[unicode] + if u then + local n = #u + for i=1,n do + if u[i] > private then + n = 0 + break + end + end + if n > 0 then + if n == 1 then + u = u[1] + end + char.unicode = u + char.tounicode = tounicode(u) + end + end + end + end + end +end + +-- forceunicodes=ligatures : aggressive lig resolving (e.g. for emoji) +-- +-- kind of like: \enabletrackers[fonts.mapping.forceligatures] + +registerotffeature { + name = "forceunicodes", + description = "forceunicodes", + manipulators = { + base = initialize, + node = initialize, + } +} |