summaryrefslogtreecommitdiff
path: root/src/luaotfload-auxiliary.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2014-12-14 21:21:55 +0100
committerPhilipp Gesang <phg42.2a@gmail.com>2014-12-14 21:21:55 +0100
commitd2a1af0a62a2540c8b88345b8d1e84ba61a8a49f (patch)
treee07b58121d10fe123fc2b31d9a75d47dd347a17d /src/luaotfload-auxiliary.lua
parentca673f7b14af906606a188fd98978d3501842f63 (diff)
downloadluaotfload-d2a1af0a62a2540c8b88345b8d1e84ba61a8a49f.tar.gz
[main, aux] add a callback that installs a .resources table in fonts that it
Fixes https://github.com/lualatex/luaotfload/issues/253 Sort of. In order to not interfere with the other callbacks which expect a sane environment this hack got added by means of another callback that is called whenever a defined font lacks essential subtables. This means that the user must consider cases like numbers and partially defined fonts. It’s best to keep both cases separate so those who aren’t concerned with workarounds for weird fonts can stick with the clean interface.
Diffstat (limited to 'src/luaotfload-auxiliary.lua')
-rw-r--r--src/luaotfload-auxiliary.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/luaotfload-auxiliary.lua b/src/luaotfload-auxiliary.lua
index 7ea747e..b3fa795 100644
--- a/src/luaotfload-auxiliary.lua
+++ b/src/luaotfload-auxiliary.lua
@@ -129,6 +129,35 @@ luatexbase.add_to_callback(
"luaotfload.patch_font",
patch_cambria_domh,
"luaotfload.aux.patch_cambria_domh")
+
+
+--[[doc--
+
+ Add missing field to fonts that lack it. Addresses issue
+ https://github.com/lualatex/luaotfload/issues/253
+
+ This is considered a hack, especially since importing the
+ unicode-math package fixes the problem quite nicely.
+
+--doc]]--
+
+--- fontobj -> unit
+local fixup_fontdata = function (data)
+
+ local t = type (data)
+ --- Some OT fonts like Libertine R lack the resources table, causing
+ --- the fontloader to nil-index.
+ if t == "table" then
+ if data and not data.resources then data.resources = { } end
+ end
+
+end
+
+luatexbase.add_to_callback(
+ "luaotfload.patch_font_unsafe",
+ fixup_fontdata,
+ "luaotfload.aux.fixup_fontdata")
+
--[[doc--