I tried to adapt this solution by Marcel Krüger
for changing the width (bounding box) of a letter:
\documentclass[12pt]{article}
\usepackage{unicode-math}
\begingroup
\long\def\x#1{\directlua{\unexpanded{#1}}}
\catcode`\#=12 \catcode`\%=12
\expandafter\endgroup\x{
--[[Declare a helper \DeclareWidth to invoke the package later]]
local id = luatexbase.new_luafunction'DeclareWidth'
local WidthMappings = {}
token.set_lua('DeclareWidth', id)
lua.get_functions_table()[id] = function()
--[[This is executed when the command is called. We have to parse the input. Take a peek at the usage of \DeclareWidth below before trying to read the code, then it should be relativly easy to follow]]
local t = {}
repeat
local cp = assert(token.scan_int(), 'No codepoint found')
token.scan_keyword'='
t[cp] = assert(token.scan_int(), 'No offset found')
until not token.scan_keyword';'
assert(token.scan_token().cmdname == 'relax', 'Final delimiter missing')
--[[Save the parsed mapping in a global table and then send the index back to TeX]]
WidthMappings[#WidthMappings+1] = t
tex.sprint(string.format("width_id=%i", #WidthMappings))
end
--[[Now implement the feature. Nothing particularly interesting here, it's
the same as almost any use of otf.register: Take the feature value, do some lookups, apply to characters]]
fonts.constructors.features.otf.register {
name = 'width_id',
description = 'Change selected width values',
initializers = {
base = function(tfmdata, value, features)
local mapping = assert(WidthMappings[value], "I'm going to strike")
local characters = tfmdata.characters
for cp, c_width in next, mapping do
assert(characters[cp], 'Why are you doing this to me?').width = c_width
end
end,
},
}
}
\setmathfont{Latin Modern Math}[math-style=literal, RawFeature={\DeclareWidth`\X=1200\relax}]
\begin{document}
$XX$
\end{document}
But nothing happens. The width of the X does not change. What is wrong here?
`\X
with"1D44A
.