diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-08-19 01:38:26 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-08-19 01:38:26 +0200 |
commit | ed42bd4c79946716033bf5dbedbd54bbe81f49e8 (patch) | |
tree | a3d63d74f0e07f799c538eb04096195b6b6d4631 /tex/context/base/mkiv/font-ext.lua | |
parent | 30b3a925bfc1857a31e23d9b17b8da0be572d02a (diff) | |
download | context-ed42bd4c79946716033bf5dbedbd54bbe81f49e8.tar.gz |
2016-08-19 00:35:00
Diffstat (limited to 'tex/context/base/mkiv/font-ext.lua')
-rw-r--r-- | tex/context/base/mkiv/font-ext.lua | 85 |
1 files changed, 62 insertions, 23 deletions
diff --git a/tex/context/base/mkiv/font-ext.lua b/tex/context/base/mkiv/font-ext.lua index 7ab11ffb0..cadce625c 100644 --- a/tex/context/base/mkiv/font-ext.lua +++ b/tex/context/base/mkiv/font-ext.lua @@ -7,6 +7,7 @@ if not modules then modules = { } end modules ['font-ext'] = { } local next, type, byte = next, type, string.byte +local utfchar = utf.char local context = context local fonts = fonts @@ -32,11 +33,13 @@ local registerotffeature = handlers.otf.features.register local registerafmfeature = handlers.afm.features.register local fontdata = hashes.identifiers +local fontproperties = hashes.properties local allocate = utilities.storage.allocate local settings_to_array = utilities.parsers.settings_to_array local getparameters = utilities.parsers.getparameters local gettexdimen = tex.getdimen +local family_font = node.family_font local setmetatableindex = table.setmetatableindex @@ -977,16 +980,16 @@ registerafmfeature(dimensions_specification) local nodepool = nodes.pool -local new_special = nodepool.special +----- new_special = nodepool.special +----- hpack_node = node.hpack local new_glyph = nodepool.glyph -local hpack_node = node.hpack local helpers = fonts.helpers local currentfont = font.current function helpers.addprivate(tfmdata,name,characterdata) - local properties = tfmdata.properties - local privates = properties.privates + local properties = tfmdata.properties + local privates = properties.privates local lastprivate = properties.lastprivate if lastprivate then lastprivate = lastprivate + 1 @@ -1008,25 +1011,36 @@ function helpers.addprivate(tfmdata,name,characterdata) return lastprivate end +local function getprivateslot(id,name) + if not name then + name = id + id = currentfont() + end + local properties = fontproperties[id] + local privates = properties and properties.privates + return privates and privates[name] +end + +helpers.getprivateslot = getprivateslot + +-- was originally meant for missing chars: +-- +-- local char = tfmdata.characters[p] +-- local commands = char.commands +-- if commands then +-- local fake = hpack_node(new_special(commands[1][2])) +-- fake.width = char.width +-- fake.height = char.height +-- fake.depth = char.depth +-- return fake +-- else + local function getprivatenode(tfmdata,name) - local properties = tfmdata.properties - local privates = properties and properties.privates - if privates then - local p = privates[name] - if p then - local char = tfmdata.characters[p] - local commands = char.commands - if commands then - local fake = hpack_node(new_special(commands[1][2])) - fake.width = char.width - fake.height = char.height - fake.depth = char.depth - return fake - else - -- todo: set current attribibutes - return new_glyph(properties.id,p) - end - end + local id = tfmdata.properties.id + local p = getprivateslot(id,name) + if p then + -- todo: set current attribibutes + return new_glyph(id,p) end end @@ -1042,6 +1056,31 @@ implement { name = "getprivatechar", arguments = "string", actions = function(name) - context(getprivatenode(fontdata[currentfont()],name)) + local p = getprivateslot(name) + if p then + context(utfchar(p)) + end + end +} + +implement { + name = "getprivatemathchar", + arguments = "string", + actions = function(name) + local p = getprivateslot(family_font(0),name) + if p then + context(utfchar(p)) + end + end +} + +implement { + name = "getprivateslot", + arguments = "string", + actions = function(name) + local p = getprivateslot(name) + if p then + context(p) + end end } |