summaryrefslogtreecommitdiff
path: root/luaotfload-auxiliary.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-05-03 18:01:07 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2013-05-03 18:01:07 +0200
commit26984f03b7965ff7c26dc73bbbd6229ab7b814fb (patch)
treebf0881a60282bfceaf2b5202dbfeeb23e4518b18 /luaotfload-auxiliary.lua
parent42b334a51fde9a8f93f4da3b10d2917c213d3b70 (diff)
downloadluaotfload-26984f03b7965ff7c26dc73bbbd6229ab7b814fb.tar.gz
add font object fallbacks for legacy packages
Diffstat (limited to 'luaotfload-auxiliary.lua')
-rw-r--r--luaotfload-auxiliary.lua62
1 files changed, 62 insertions, 0 deletions
diff --git a/luaotfload-auxiliary.lua b/luaotfload-auxiliary.lua
index 844c170..5ed7bb9 100644
--- a/luaotfload-auxiliary.lua
+++ b/luaotfload-auxiliary.lua
@@ -36,6 +36,68 @@ local stringbyte = string.byte
-----------------------------------------------------------------------
--[[doc--
+
+The font object (tfmdata) structure has changed since version 1.x, so
+in case other packages haven’t been updated we put fallbacks in place
+where they’d expect them. Specifically we have in mind:
+
+ · fontspec
+ · unicode-math
+ · microtype (most likely fixed till TL2013)
+
+--doc]]--
+
+--- fontobj -> fontobj
+local add_fontdata_fallbacks = function (fontdata)
+ if type(fontdata) == "table" then
+ local fontparameters = fontdata.parameters
+ local metadata
+ if not fontdata.shared then --- that would be a tfm
+ --- we can’t really catch everything that
+ --- goes wrong; for some reason, fontspec.lua
+ --- just assumes it always gets an otf object,
+ --- so its capheight callback, which does not
+ --- bother to do any checks, will access
+ --- fontdata.shared no matter what ...
+ fontdata.units = fontdata.units_per_em
+ else --- otf
+ metadata = fontdata.shared.rawdata.metadata
+ fontdata.units = fontparameters.units
+ local resources = fontdata.resources
+ fontdata.size = fontparameters.size
+ --- for legacy fontspec.lua and unicode-math.lua
+ fontdata.shared.otfdata = metadata
+ fontdata.shared.otfdata.metadata = metadata --- brr, that’s meta indeed
+ --- for microtype.lua
+ fontdata.shared.otfdata.luatex = {
+ unicodes = resources.unicodes,
+ features = resources.features,
+ }
+ end
+ end
+ return fontdata
+end
+
+luatexbase.add_to_callback(
+ "luaotfload.patch_font",
+ add_fontdata_fallbacks,
+ "luaotfload.fontdata_fallbacks")
+
+--[[doc--
+
+Additionally, the font registry is expected at fonts.identifiers, but
+in the meantime it has been migrated to fonts.hashes.identifiers.
+We’ll make luaotfload satisfy those assumptions. (Maybe it’d be more
+appropriate to use font.getfont() since Hans made it a harmless wrapper
+[1].)
+
+[1] http://www.ntg.nl/pipermail/ntg-context/2013/072166.html
+
+--doc]]--
+
+fonts.identifiers = fonts.hashes.identifiers
+
+--[[doc--
This sets two dimensions apparently relied upon by the unicode-math
package.
--doc]]--