diff options
Diffstat (limited to 'tex/context/base/mkxl/font-tex.lmt')
-rw-r--r-- | tex/context/base/mkxl/font-tex.lmt | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/tex/context/base/mkxl/font-tex.lmt b/tex/context/base/mkxl/font-tex.lmt index 1c3c17a79..2d21687df 100644 --- a/tex/context/base/mkxl/font-tex.lmt +++ b/tex/context/base/mkxl/font-tex.lmt @@ -6,22 +6,23 @@ if not modules then modules = { } end modules ['font-mpf'] = { license = "see context related readme files" } -local formatters = string.formatters -local sortedhash = table.sortedhash +local formatters = string.formatters +local sortedhash = table.sortedhash -local addcharacters = fonts.constructors.addcharacters -local fontdata = fonts.hashes.identifiers +local addcharacters = fonts.constructors.addcharacters +local fontdata = fonts.hashes.identifiers +local fontchars = fonts.hashes.characters -local otf = fonts.handlers.otf -local otfregister = otf.features.register +local otf = fonts.handlers.otf +local otfregister = otf.features.register ------ getshapes = fonts.dropins.getshapes +----- getshapes = fonts.dropins.getshapes -local register = fonts.collections.register -local checkenabled = fonts.collections.checkenabled -local newprivateslot = fonts.helpers.newprivateslot +local register = fonts.collections.register +local checkenabled = fonts.collections.checkenabled +local newprivateslot = fonts.helpers.newprivateslot -local currentfont = font.current +local currentfont = font.current -- hm, seems to gobble the first \char @@ -84,7 +85,7 @@ local function setboxglyph(specification) end end -function fonts.helpers.setboxdirectly(font,unicode,box) -- hash based on wd/ht/dp +local function setboxdirectly(font,unicode,box) -- hash based on wd/ht/dp if box then local tfmdata = fontdata[font] local glyphboxes = (tfmdata.glyphboxes or 0) + 1 @@ -108,6 +109,8 @@ function fonts.helpers.setboxdirectly(font,unicode,box) -- hash based on wd/ht/d end end +fonts.helpers.setboxdirectly = setboxdirectly + local boxes = table.setmetatableindex("table") function fonts.helpers.registerglyphbox(specification) @@ -182,3 +185,34 @@ fonts.handlers.otf.features.register { -- fonts.helpers.registerboxglyph { category = "demo", unicode = 104 } -- fonts.helpers.registerboxglyph { category = "demo", unicode = 105 } -- fonts.helpers.registerboxglyph { category = "demo", unicode = 106 } + +local callbacks = fonts.callbacks or { } +fonts.callbacks = callbacks + +function callbacks.devirtualize(chardata,f,c) + if chardata.commands then + local h = node.hpack(nodes.pool.glyph(f,c)) + local p = setboxdirectly(f,c,h) + chardata.oldcommands = chardata.commands + chardata.commands = { { "char", p } } + chardata.callback = false + end +end + +local function processcallback(f,c) + local characters = fontchars[f] + local chardata = characters[c] + if chardata then + local callback = chardata.callback + if callback then + local action = type(callback) == "function" and callback or callbacks[callback] + if action then + action(chardata,f,c) + end + end + end +end + +callback.register("process_character",processcallback) + +callbacks.callback = processcallback |