summaryrefslogtreecommitdiff
path: root/luaotfload-extralibs.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-12-28 13:22:07 +0100
committerPhilipp Gesang <phg42.2a@gmail.com>2013-12-28 13:22:07 +0100
commit34eb0a55da27491d37aa4e71a8d6be6b403bca41 (patch)
tree4af93021c439939d31c52cdf68e4bb0cfc3f7bc2 /luaotfload-extralibs.lua
parent18b34b6217d6a38d480e182b86f449bff071ab3e (diff)
downloadluaotfload-34eb0a55da27491d37aa4e71a8d6be6b403bca41.tar.gz
[letterspace] add Xetex compatibility for “letterspace”
When defining a font, Luaotfload interprets the value supplied to the “letterspace” option as a percentage of the font size, mimicking Xetex in yet another respect. In order to preserve the former behavior (no scaling) a new option **kernfactor** is introduced whose value is passed on to the letterspacing feature unmodified.
Diffstat (limited to 'luaotfload-extralibs.lua')
-rw-r--r--luaotfload-extralibs.lua35
1 files changed, 33 insertions, 2 deletions
diff --git a/luaotfload-extralibs.lua b/luaotfload-extralibs.lua
index 6d486b2..21f738c 100644
--- a/luaotfload-extralibs.lua
+++ b/luaotfload-extralibs.lua
@@ -411,14 +411,45 @@ end
--- feature mechanism
otffeatures.register {
- name = "letterspace", --"kerncharacters",
- description = "letterspace", --"kerncharacters",
+ name = "kernfactor",
+ description = "kernfactor",
initializers = {
base = initializefontkerning,
node = initializefontkerning,
}
}
+--[[doc--
+
+ The “letterspace” feature is essentially identical with the above
+ “kernfactor” method, but scales the factor to percentages to match
+ Xetex’s behavior. (See the Xetex reference, page 5, section 1.2.2.)
+
+ Since Xetex doesn’t appear to have a (documented) “max” keyword, we
+ assume all input values are numeric.
+
+--doc]]--
+
+local initializecompatfontkerning = function (tfmdata, percentage)
+ local factor = tonumber (percentage)
+ if not factor then
+ logs.names_report ("both", 0, "letterspace",
+ "Invalid argument to letterspace: %s (type %q), was expecting percentage as Lua number instead.",
+ percentage, type (percentage))
+ return
+ end
+ return initializefontkerning (tfmdata, factor * 0.01)
+end
+
+otffeatures.register {
+ name = "letterspace",
+ description = "letterspace",
+ initializers = {
+ base = initializecompatfontkerning,
+ node = initializecompatfontkerning,
+ }
+}
+
kerns.set = nil
local characterkerning_enabled = false