From 26984f03b7965ff7c26dc73bbbd6229ab7b814fb Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 3 May 2013 18:01:07 +0200 Subject: add font object fallbacks for legacy packages --- luaotfload-auxiliary.lua | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'luaotfload-auxiliary.lua') diff --git a/luaotfload-auxiliary.lua b/luaotfload-auxiliary.lua index 844c170..5ed7bb9 100644 --- a/luaotfload-auxiliary.lua +++ b/luaotfload-auxiliary.lua @@ -35,6 +35,68 @@ local stringbyte = string.byte --- font patches ----------------------------------------------------------------------- +--[[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. -- cgit v1.2.3 From 76830b0a04dbd8ce620edd79d6a18d3d4cb8bcf0 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 3 May 2013 21:39:41 +0200 Subject: additional workaround for inconsistent argument order in fontspec.lua --- luaotfload-auxiliary.lua | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'luaotfload-auxiliary.lua') diff --git a/luaotfload-auxiliary.lua b/luaotfload-auxiliary.lua index 5ed7bb9..bf567e3 100644 --- a/luaotfload-auxiliary.lua +++ b/luaotfload-auxiliary.lua @@ -62,9 +62,9 @@ local add_fontdata_fallbacks = function (fontdata) 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 + 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 @@ -85,17 +85,18 @@ luatexbase.add_to_callback( --[[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].) +Additionally, the font registry is expected at fonts.identifiers +(fontspec) or fonts.ids (microtype), 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 +fonts.ids = fonts.hashes.identifiers --[[doc-- This sets two dimensions apparently relied upon by the unicode-math @@ -133,6 +134,7 @@ end --[[doc-- This callback corrects some values of the Cambria font. --doc]]-- +--- fontobj -> unit local patch_cambria_domh = function (fontdata) local mathconstants = fontdata.MathConstants if mathconstants and fontdata.psname == "CambriaMath" then @@ -352,6 +354,16 @@ end aux.provides_language = provides_language +--- fontspec apparently has the arguments shuffled +--- theirs: id -> lang -> script -> bool +--- ours: id -> script -> lang -> bool +--- whereas in the other check_* functions, script is +--- always the second argument ... +aux.provides_language_fontspec = function + (font_id, asked_language, asked_script) + return provides_language(font_id, asked_script, asked_language) +end + --[[doc-- We strip the syntax elements from feature definitions (shouldn’t actually be there in the first place, but who cares ...) -- cgit v1.2.3 From 21b1fb201a2fd9f058c1fee24dbd29df1debe6f7 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 4 May 2013 11:49:12 +0200 Subject: bump version; add/update attributions --- luaotfload-auxiliary.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'luaotfload-auxiliary.lua') diff --git a/luaotfload-auxiliary.lua b/luaotfload-auxiliary.lua index bf567e3..fde4e24 100644 --- a/luaotfload-auxiliary.lua +++ b/luaotfload-auxiliary.lua @@ -4,7 +4,7 @@ -- DESCRIPTION: part of luaotfload -- REQUIREMENTS: luaotfload 2.2 -- AUTHOR: Khaled Hosny, Élie Roux, Philipp Gesang --- VERSION: 1.0 +-- VERSION: 2.2 -- CREATED: 2013-05-01 14:40:50+0200 ----------------------------------------------------------------------- -- -- cgit v1.2.3 From f70c8419d5abcc29f99ad50b8d9b20278310ff36 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 4 May 2013 12:46:38 +0200 Subject: remove fontspec argument order workaround --- luaotfload-auxiliary.lua | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'luaotfload-auxiliary.lua') diff --git a/luaotfload-auxiliary.lua b/luaotfload-auxiliary.lua index fde4e24..5de964d 100644 --- a/luaotfload-auxiliary.lua +++ b/luaotfload-auxiliary.lua @@ -354,16 +354,6 @@ end aux.provides_language = provides_language ---- fontspec apparently has the arguments shuffled ---- theirs: id -> lang -> script -> bool ---- ours: id -> script -> lang -> bool ---- whereas in the other check_* functions, script is ---- always the second argument ... -aux.provides_language_fontspec = function - (font_id, asked_language, asked_script) - return provides_language(font_id, asked_script, asked_language) -end - --[[doc-- We strip the syntax elements from feature definitions (shouldn’t actually be there in the first place, but who cares ...) -- cgit v1.2.3